added length

this is broken rn fix
This commit is contained in:
zombie maniac 2021-09-17 09:18:29 -04:00
parent eea117b5a3
commit b6470befab
3 changed files with 66 additions and 1 deletions

View file

@ -14,4 +14,4 @@ set(CMAKE_ASM_NASM_LINK_EXECUTABLE "gcc <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS>
add_link_options(-fno-pie -m64 -no-pie -pedantic-errors) add_link_options(-fno-pie -m64 -no-pie -pedantic-errors)
#Make a EXE with cpp and asm files #Make a EXE with cpp and asm files
add_executable(case case.asm) add_executable(length length.asm)

45
length.asm Normal file
View file

@ -0,0 +1,45 @@
extern puts
extern printf
default rel
%include "/home/zombie/Documents/bigdocs/redownloadables/gitshit/nbrooks211/zombie-core-utils/length_func.inc"
section .rodata
format db "%#x", 10, 0
section .data
text db "rEEEeee!EEeeeEeEEeE!EEEEEeEEE$eeeEE)EEeEeEEeeeEeEEEEEeeeEeeEeeEeeeeeEeEeEeeE",0
textlength db 76
section .text
global main
main:
sub rsp, 8 ;enter
push text
call length_func
pop r8
mov rdi, text
cld
call puts ;this is the puts way of printing a string
mov rsi, r8
lea rdi, [rel format]
xor eax, eax ; AL=0 no FP args in XMM regs
call printf
_end:
add rsp, 8 ;exit
ret

20
length_func.inc Normal file
View file

@ -0,0 +1,20 @@
length_func:
pop r8
_loop67865432:
mov r9b, [r8]
cmp r9b, 0
jz _exitloop4323567
inc r8
jmp _loop67865432
_exitloop4323567:
dec r8 ; idk how to do it properly do im doing this instead
push r8
ret