Adds strlen()

This commit is contained in:
2025-07-05 01:45:58 +02:00
parent 3b275a6166
commit b0a3da746f
3 changed files with 50 additions and 0 deletions

View File

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