Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
813 B

  1. #include "mbrmake.h"
  2. WORD HashAtomStr (char *pStr) {
  3. WORD hash = 0;
  4. while (*pStr)
  5. hash += (hash << 5) + *pStr++;
  6. return (hash % (MAXSYMPTRTBLSIZ-1));
  7. }
  8. #if rjsa
  9. HashAtomStr PROC NEAR USES DS SI, npsz:DWORD
  10. xor ax,ax ; (ax) = byte-extended-to-word
  11. mov cx,ax ; (cx) = hash
  12. mov dx,ax ; (dx) = high part for later div
  13. cld
  14. lds si,npsz ; (si) = pointer to string
  15. align 4
  16. hfs1: lodsb ; get next byte
  17. or al,al ; are we at end of string?
  18. jz hfs2 ; yes, compute div and we're done
  19. mov bx,cx
  20. shl bx,1
  21. shl bx,1
  22. shl bx,1
  23. shl bx,1
  24. shl bx,1
  25. add cx,bx ; (newcx) = (oldcx) + (oldcx) << 5
  26. add cx,ax ; (cx) += (cx) << 5 + (ax)
  27. jmp hfs1
  28. hfs2: mov ax,4094 ; magic divider
  29. xchg ax,cx ; (dx:ax) = number, (cx) = dividend
  30. div cx
  31. mov ax,dx
  32. ret
  33. HashAtomStr ENDP
  34. end
  35. #endif