Adds strlen()
This commit is contained in:
@@ -1 +1,21 @@
|
||||
%include "src/constants.asm"
|
||||
|
||||
section .text
|
||||
global strlen
|
||||
|
||||
;----- strlen(*str[]) -----;
|
||||
; Gets the length of given string
|
||||
; Return value: Length of given string
|
||||
; Used registers:
|
||||
; rax* Byte to check in str[] >> (ret) length of given string
|
||||
; rdi* (arg) Pointer to str[]
|
||||
; rcx* Counter for scasb
|
||||
strlen:
|
||||
xor rax, rax
|
||||
mov rcx, -1
|
||||
cld
|
||||
repne scasb
|
||||
mov rax, rcx
|
||||
not rax
|
||||
dec rax
|
||||
ret
|
||||
|
Reference in New Issue
Block a user