zombie-lib/example.asm

96 lines
1.1 KiB
NASM

extern puts
extern libz_strlen
extern libz_strcmp
extern libz_tolower
extern libz_atoi
extern malloc
section .data
text2 db "asdasdASDd",0
text db "asdasdasd",0
text3 dq "5",0
textstore dq 0,0
stoer db "0",0
differ db "they differ",0
notdiffer db "they dont differ",0
section .text
global main
main:
sub rsp, 8 ;enter
mov rdi, text
call libz_tolower
mov rdi, text
cld
call puts ;this is the puts way of printing a string
mov rdi, text2
cld
call puts
mov rdi, text3
call libz_atoi
mov [textstore], rax
mov rdi, textstore
cld
call puts
mov rdi, text2
call libz_strlen
add [stoer], rax
mov rdi, stoer
cld
call puts
mov rdi, text
mov rsi, text2
call libz_strcmp
cmp rax, 1
je _differ
jmp _notdiffer
_differ:
mov rdi, differ
cld
call puts
jmp _afterdiff
_notdiffer:
mov rdi, 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