Adds strclr()

This commit is contained in:
2025-07-07 15:21:48 +02:00
parent 9b1519b2f4
commit 3b1ce7ca40
2 changed files with 72 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ section .text
global strlen
global strcpy
global strcat
global strclr
;----- strlen(*str[]) -----;
; Gets the length of given string
@@ -85,3 +86,19 @@ strcat:
mov byte [rdi], EOS
mov rax, r8
ret
;----- strclr(*str[], maxLength) -----;
; Clears a string by placing [maxLength] EOS into string.
; Thus DANGEROUS function: MAKE SURE maxLength IS SIZE OF str[] - greater values WILL cause issues and eventually crashes
; Return value: N/A
; Used registers:
; rdi* (arg) Pointer to str[]
; rsi (arg) Length of str[]
; rcx* Counter for STOSB
; rax* Character storage (AL) for STOSB
strclr:
mov rcx, rsi
xor al, al
cld
rep stosb
ret