zombie-core-utils/length.asm

52 lines
885 B
NASM
Raw Normal View History

2021-09-17 09:18:29 -04:00
extern puts
extern printf
2021-10-02 13:33:46 -04:00
extern libz_strlen
2021-09-17 09:18:29 -04:00
default rel
section .rodata
format db "%#d", 10, 0
2021-09-17 09:18:29 -04:00
section .data
2021-09-18 05:43:26 -04:00
testasd dq 0
tempstore db 0
argument_error db "Argument Error!... either too many args or too little please fix", 0
2021-09-17 09:18:29 -04:00
section .text
global main
main:
sub rsp, 8 ;enter
cmp rdi, 2
jne _argument_error ;if its not exactly 2 then exit
2021-09-17 09:18:29 -04:00
add rsi, 8 ;get the second argument because the first argument is the path
mov r8, [rsi] ;this block here fenagles the pointer into memeory instead of a register
mov [tempstore], r8 ; i also really with i had the abilty to mov [thing1], [thing2]
mov rdi, [tempstore]
2021-10-02 13:33:46 -04:00
call libz_strlen
2021-09-18 05:43:26 -04:00
mov [testasd], rax
2021-09-17 09:18:29 -04:00
2021-09-18 05:43:26 -04:00
mov rsi, [testasd]
2021-09-17 09:18:29 -04:00
lea rdi, [rel format]
xor eax, eax ; AL=0 no FP args in XMM regs
call printf
_end:
add rsp, 8 ;exit
ret
_argument_error:
mov rdi, argument_error
cld
call puts
jmp _end