made case its own function

This commit is contained in:
zombie maniac 2021-09-19 12:18:33 -04:00
parent 34e6f127b5
commit 67363c7013
2 changed files with 36 additions and 29 deletions

View file

@ -1,43 +1,17 @@
extern puts
%include "../inc/length_func.inc"
%include "../inc/case_func.inc"
section .data
text db "rEEEeee!EEeeeEeEEeE!EEEEEeEEE$eeeEE)EEeEeEEeeeEeEEEEEeeeEeeEeeEeeeeeEeEeEeeE",0
textlength db 0
section .text
global main
main:
sub rsp, 8 ;enter
mov r8, text ;get textlength
call length_func
mov [textlength], rax
xor rcx, rcx ;we do this to clear rcx incase it had garbage in it before
_loop:
;do loop things
mov r9, text
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, [textlength]
jle _loop
mov r8, text
call case_func
mov rdi, text
cld

33
inc/case_func.inc Normal file
View file

@ -0,0 +1,33 @@
%include "../inc/length_func.inc"
case_func:
mov r11, r8
;length_funcx accepts r8
call length_func
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
ret