I'm developing a hash class. It is quite a bulky item (200 lines), so I will keep it separate from the Maths.
You can find it in src/HashStore.o2bas
Here is the hash encoder:
'-------------------------------
method hashcode(string s) as sys
'===============================
xor eax,eax
mov edx, [s] ' name pointer
mov ecx, [edx-4] ' length
(
cmp ecx,0
jnz exit
return 0 'EMPTY WORD WILL TRIGGER HASHCODE ERROR LATER
)
mov ah, cl ' assume max length 255
mov al, [edx] ' 1st letter
cmp cl,1
(
jz exit
shl eax,3
xor al, [edx+1] ' 2nd letter
shl eax,3
(
rol eax,1
xor al, [edx]
inc edx
dec ecx
jnz repeat
)
)
return eax
'
end method
Charles