diff options
Diffstat (limited to 'twasm/asm/main.asm')
| -rw-r--r-- | twasm/asm/main.asm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/twasm/asm/main.asm b/twasm/asm/main.asm index 1ed4932..7262a8f 100644 --- a/twasm/asm/main.asm +++ b/twasm/asm/main.asm @@ -1446,6 +1446,42 @@ elemb: 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 ; ; description: |
