[LMH]%SXHASH-STRING?
Steve Krueger
stevelisp@grape-krueger.com
Mon Jul 28 21:31:02 2003
Alastair,
I have the old microcode and the algorithm there is pretty simple. I
don't know whether we changed it in VM2. Try this one and see if it
gives consistent hashes into the symbol tables in the band.
Sorry for the poor transliteration from microassembler to C.
(%SXHASH mask array)
;; the array can be of any numeric type, but is usually called with an
array of characters (ART-STRING)
;; note: array may be displaced.
M-2 = Q_Pointer( pdl_pop); // unboxed
M-A = pdl_pop; // the array pointer
M-1 = 0; // the hash code accum - unboxed
M-Q = 0; // index we are working at
M-I = decode_array_length(M-A); // the array length unboxed
M-B = array_hdr_word(M-A); // copy of the array header word to save
many re-readings.
do {
M-T = array_type_aref( M-B, M-A, M-Q); // aref from M-A at index M-Q
as appropriate for array type
M-T = M-T & M-2;
M-1 = M-1 ^ M-T;
M-1 = ( ( M-1 & byte-mask( 00730 )) << 7 ); // M-1 = ROTATE_LEFT( 7,
M-1 )
// M-1 = load-byte( 03007 , M-1 , M-1 );
M-1 = ( M-1 & ~ byte-mask( 00731 ) ) | ( ( M-1 & byte-mask( 03007 )) >>
030 );
// right shift must be unsigned.
} until ( ++M-Q >= M-I );
if ( M-1 & byte-mask ( 02701)) {
M-1 = M-1 ^ 040000001;
}
return ( fixnum(M-1) );
I hope this makes sense.
-Steve
Nyef wrote:
>Hello all.
>
>Does anyone have any information on the hash algorithm used by
>%SXHASH-STRING? I just ran into it somewhere in the reader (called during
>the course of trying to read the config partition).
>
>
>