zombie-lib/example.asm

97 lines
1.1 KiB
NASM
Raw Normal View History

2021-09-26 17:30:13 -04:00
extern puts
2021-10-02 13:33:15 -04:00
extern libz_strlen
2021-09-27 16:40:27 -04:00
extern libz_strcmp
extern libz_tolower
2021-10-02 21:37:52 -04:00
extern libz_atoi
2021-11-25 13:11:38 -05:00
extern malloc
2021-09-26 17:30:13 -04:00
section .data
2021-09-27 16:40:27 -04:00
text2 db "asdasdASDd",0
text db "asdasdasd",0
text3 dq "5",0
2021-10-02 21:37:52 -04:00
textstore dq 0,0
2021-09-26 17:30:13 -04:00
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
2021-09-27 16:40:27 -04:00
call libz_tolower
2021-09-26 17:30:13 -04:00
mov rdi, text
cld
call puts ;this is the puts way of printing a string
2021-09-26 20:58:38 -04:00
mov rdi, text2
cld
call puts
2021-10-02 21:37:52 -04:00
mov rdi, text3
call libz_atoi
mov [textstore], rax
mov rdi, textstore
cld
call puts
2021-09-26 20:58:38 -04:00
2021-09-26 17:30:13 -04:00
mov rdi, text2
2021-10-02 13:33:15 -04:00
call libz_strlen
2021-09-26 17:30:13 -04:00
add [stoer], rax
mov rdi, stoer
cld
call puts
mov rdi, text
mov rsi, text2
2021-09-27 16:40:27 -04:00
call libz_strcmp
2021-09-26 17:30:13 -04:00
cmp rax, 1
je _differ
jmp _notdiffer
_differ:
mov rdi, differ
cld
call puts
2021-11-25 13:11:38 -05:00
jmp _afterdiff
2021-09-26 17:30:13 -04:00
_notdiffer:
mov rdi, notdiffer
cld
call puts
2021-11-25 13:11:38 -05:00
_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
2021-09-26 17:30:13 -04:00
_end:
add rsp, 8 ;exit
ret