added atoi to example

This commit is contained in:
zombie maniac 2021-10-02 21:37:52 -04:00
parent ed333fbc6d
commit cf0d5fa5cb
4 changed files with 17 additions and 7 deletions

View file

@ -18,6 +18,6 @@ add_compile_options(-g)
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_library(z tolower.asm strlen.asm strcmp.asm) add_library(z tolower.asm strlen.asm strcmp.asm atoi.asm)
add_executable(example example.asm) add_executable(example example.asm)
target_link_libraries(example z) target_link_libraries(example z)

View file

@ -8,10 +8,6 @@ libz_atoi:
mov r8, rdi mov r8, rdi
mov r8, text ;loop setup
xor r9, r9 xor r9, r9
_loopasd23: _loopasd23:

View file

@ -2,12 +2,13 @@ extern puts
extern libz_strlen extern libz_strlen
extern libz_strcmp extern libz_strcmp
extern libz_tolower extern libz_tolower
extern libz_atoi
section .data section .data
text2 db "asdasdASDd",0 text2 db "asdasdASDd",0
text db "asdasdasd",0 text db "asdasdasd",0
text3 dq "65",0
textstore dq 0,0
stoer db "0",0 stoer db "0",0
differ db "they differ",0 differ db "they differ",0
notdiffer db "they dont differ",0 notdiffer db "they dont differ",0
@ -30,6 +31,14 @@ main:
call puts call puts
mov rdi, text3
call libz_atoi
mov [textstore], rax
mov rdi, textstore
cld
call puts
mov rdi, text2 mov rdi, text2

View file

@ -4,6 +4,9 @@ section .text
libz_strlen: libz_strlen:
sub rsp, 8 ;enter sub rsp, 8 ;enter
push rdi
mov r10, rdi mov r10, rdi
_loop67865432: _loop67865432:
@ -19,5 +22,7 @@ _exitloop4323567:
mov rax, rdi mov rax, rdi
pop rdi
add rsp, 8 ;exit add rsp, 8 ;exit
ret ret