add hash
This commit is contained in:
@@ -1445,6 +1445,42 @@ elemb:
|
||||
mov rax, 1 ; return 1; dl an element of list
|
||||
ret
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
; djb2
|
||||
;
|
||||
; description:
|
||||
; gets the djb2 hash of a given string
|
||||
;
|
||||
; parameters:
|
||||
; rdi = size of string
|
||||
; rsi -> start of string
|
||||
;
|
||||
; returned:
|
||||
; rax = hash
|
||||
; ------------------------------------------------------------------------------
|
||||
|
||||
djb2:
|
||||
xor ecx, ecx ; rcx = index
|
||||
mov rax, 5381 ; rax = hash
|
||||
|
||||
.loop:
|
||||
cmp rcx, rdi
|
||||
jge .break
|
||||
|
||||
mov rdx, rax
|
||||
shl rax, 5
|
||||
add rax, rdx
|
||||
|
||||
xor edx, edx
|
||||
mov dl, [rsi + rcx] ; dl = current byte
|
||||
add rax, rdx
|
||||
|
||||
inc rcx
|
||||
jmp .loop
|
||||
|
||||
.break:
|
||||
ret
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
; trim_trailing_whitespace
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user