.title hash hash a string .psect $$code rd, nowrt, exe, rel, pic, con, shr, long .align long .entry - hash_string, ^m ;+ ; hash-value = hash_string ( string.length, string.address ) ; ; "hash-value" is hashed string value (32 bits) ;- movl 4(ap), r0 ; get length of string movl 8(ap), r1 ; get address of string ; r0 = length of string ; r1 = address of string ; r2, r3 scratch registers pushl r0 ashl #-2, r0, r3 beql 20$ 10$: bicl3 #^A/AAAA/\^A/aaaa/, (r1)+, r2 ; movl (r1)+, r2 xorl r2, r0 rotl #9, r0, r0 sobgtr r3, 10$ 20$: bicl3 #-4, (sp)+, r3 brb 40$ 30$: bicb3 #^A/A/\^A/a/, (r1)+, r2 ; movb (r1)+, r2 xorb r2, r0 rotl #13, r0, r0 40$: sobgeq r3, 30$ mull #^x71279461, r0 rotl #32-13, r0, -(sp) xorw 2(sp), (sp) ; XOR top word over bottom word movl (sp)+, r0 ret .end