Files
klibc/src/string.asm
2025-07-05 01:45:58 +02:00

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