22 lines
387 B
NASM
22 lines
387 B
NASM
%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
|