testing malloc in example.asm

This commit is contained in:
zombie maniac 2021-11-25 13:11:38 -05:00
parent e40f7dbe2b
commit 33a00bf2c2
2 changed files with 24 additions and 2 deletions

View file

@ -18,6 +18,6 @@ add_compile_options(-g)
add_link_options(-fno-pie -m64 -no-pie -pedantic-errors)
#Make a EXE with cpp and asm files
add_library(z tolower.asm strlen.asm strcmp.asm atoi.asm hextoi.asm)
add_library(z tolower.asm strlen.asm strcmp.asm atoi.asm)
add_executable(example example.asm)
target_link_libraries(example z)

View file

@ -3,6 +3,7 @@ extern libz_strlen
extern libz_strcmp
extern libz_tolower
extern libz_atoi
extern malloc
section .data
text2 db "asdasdASDd",0
@ -60,7 +61,7 @@ _differ:
mov rdi, differ
cld
call puts
jmp _end
jmp _afterdiff
@ -69,6 +70,27 @@ _notdiffer:
cld
call puts
_afterdiff:
mov rdi, 20
cld
call malloc
;i think i just malloced (hopefully)
xor rcx, rcx
_malloctestloop:
mov [rax], rcx
cmp rcx, 20
je _end
inc rcx
inc rax
jmp _malloctestloop
_end:
add rsp, 8 ;exit
ret