From bc103e75bd5ab9cc9f3f2343dd6d6db82d4f46f6 Mon Sep 17 00:00:00 2001 From: zombie Date: Sat, 18 Sep 2021 05:43:26 -0400 Subject: [PATCH] length finally fucking works --- CMakeLists.txt | 1 - length.asm | 9 ++++----- length_func.inc | 8 ++------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 242663f..5e00b71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,4 +20,3 @@ add_link_options(-fno-pie -m64 -no-pie -pedantic-errors) add_executable(length length.asm) add_executable(yes yes.asm) add_executable(case case.asm) - diff --git a/length.asm b/length.asm index e032df2..cd41318 100644 --- a/length.asm +++ b/length.asm @@ -10,7 +10,8 @@ section .rodata format db "%#x", 10, 0 section .data - text db "rEEEeee!EEeeeEeEEeE!EEEEEeEEE$eeeEE)EEeEeEEeeeEeEEEEEeeeEeeEeeEeeeeeEeEeEeeE",0 + text db "rEE",0 + testasd dq 0 section .text global main @@ -21,22 +22,20 @@ main: mov r8, text call length_func - - + mov [testasd], rax mov rdi, text cld call puts ;this is the puts way of printing a string - mov rsi, r8 + mov rsi, [testasd] lea rdi, [rel format] xor eax, eax ; AL=0 no FP args in XMM regs call printf - _end: add rsp, 8 ;exit ret diff --git a/length_func.inc b/length_func.inc index e5ce68b..a722858 100644 --- a/length_func.inc +++ b/length_func.inc @@ -1,9 +1,9 @@ length_func: + mov r10, r8 _loop67865432: - mov r9b, [r8] cmp r9b, 0 jz _exitloop4323567 @@ -11,11 +11,7 @@ _loop67865432: jmp _loop67865432 _exitloop4323567: - dec r8 ; idk how to do it properly do im doing this instead - - dec r8 - dec r8 - dec r8 + sub r8, r10 mov rax, r8 ret