Adds strclr() and strlclr()
This commit is contained in:
34
string.asm
34
string.asm
@ -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
|
||||
|
Reference in New Issue
Block a user