zombie-lib/tolower.asm

39 lines
586 B
NASM
Raw Normal View History

2021-10-02 13:33:15 -04:00
extern libz_strlen
2021-09-26 17:30:13 -04:00
2021-09-27 16:40:27 -04:00
global libz_tolower
2021-09-26 17:30:13 -04:00
section .text
2021-09-27 16:40:27 -04:00
libz_tolower:
2021-09-26 17:30:13 -04:00
sub rsp, 8 ;enter
mov r11, rdi
2021-10-02 13:33:15 -04:00
call libz_strlen
2021-09-26 17:30:13 -04:00
mov r10, rax
xor rcx, rcx ;we do this to clear rcx incase it had garbage in it before
_loop:
;do loop things
mov r9, r11
add r9, rcx
mov r8b, [r9] ;this block here makes sure that our character is a capital letter and if its not a capital letter do nothing and return
cmp r8b, 90
ja _endloop
cmp r8b, 65
jb _endloop
add r8b, 32 ;make the letter capital
mov [r9], r8b
_endloop:
;end loop
inc rcx
cmp rcx, r10
jle _loop
add rsp, 8 ;exit
ret