From 67363c701388cc443779fd602a6b32dd64371202 Mon Sep 17 00:00:00 2001 From: zombie Date: Sun, 19 Sep 2021 12:18:33 -0400 Subject: [PATCH] made case its own function --- case.asm | 32 +++----------------------------- inc/case_func.inc | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 inc/case_func.inc diff --git a/case.asm b/case.asm index 790cb74..b1893a0 100644 --- a/case.asm +++ b/case.asm @@ -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 diff --git a/inc/case_func.inc b/inc/case_func.inc new file mode 100644 index 0000000..c49c636 --- /dev/null +++ b/inc/case_func.inc @@ -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