zombie-core-utils/length.asm

54 lines
902 B
NASM
Raw Normal View History

2021-09-17 09:18:29 -04:00
extern puts
extern printf
default rel
2021-09-18 05:46:33 -04:00
%include "../inc/length_func.inc"
2021-09-17 09:18:29 -04:00
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-09-17 09:18:29 -04:00
call length_func
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