Adds strclr() and strlclr()

This commit is contained in:
2025-06-24 18:29:18 +02:00
parent 46051d0082
commit e2de729a87
2 changed files with 440 additions and 205 deletions

View File

@ -4,6 +4,8 @@ section .text
global strlcpy
global strcat
global strcmp
global strclr
global strlclr
;----- strlen(char* str) -----;
; return value: amount of characters before EOS was found
@ -123,3 +125,35 @@ strcmp:
.quit:
leave
ret
;----- strclr(char* str) -----;
; Replaces all characters of a string with \0 untill EOS is found
; returns amount of changed characters
strclr:
push rbp
mov rbp, rsp
call strlen
mov rcx, rax
mov rdx, rax
xor rax, rax
cld
rep stosb
mov rax, rdx
leave
ret
;----- strlclr(char* str, int size) -----;
; Replaces characters of a string with \0, using arg size
; <!> DANGEROUS FUNCTION, it might exceed string boundaries if used incorrectly. Use strclr() instead!
; Function has no return value, rax is unmodified
strlclr:
push rbp
mov rbp, rsp
mov rcx, rsi
xor rax, rax
cld
rep stosb
leave
ret