51 lines
885 B
NASM
51 lines
885 B
NASM
extern puts
|
|
extern printf
|
|
extern libz_strlen
|
|
default rel
|
|
|
|
|
|
section .rodata
|
|
format db "%#d", 10, 0
|
|
|
|
section .data
|
|
testasd dq 0
|
|
tempstore db 0
|
|
argument_error db "Argument Error!... either too many args or too little please fix", 0
|
|
section .text
|
|
global main
|
|
|
|
main:
|
|
sub rsp, 8 ;enter
|
|
|
|
cmp rdi, 2
|
|
jne _argument_error ;if its not exactly 2 then exit
|
|
|
|
|
|
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]
|
|
call libz_strlen
|
|
mov [testasd], rax
|
|
|
|
|
|
mov rsi, [testasd]
|
|
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
|