This commit is contained in:
andromeda
2026-03-23 17:00:32 +01:00
parent 50e635332c
commit b952210561
2 changed files with 101 additions and 0 deletions

View File

@@ -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
;