disco/disco.asm

52 lines
901 B
NASM
Raw Normal View History

2022-02-22 03:39:07 -05:00
section .data
2022-02-25 22:44:07 -05:00
2022-02-22 03:39:07 -05:00
section .bss
stackArguments resb 64
trip resb 8 ; temporary return instruction pointer (for stack manipulation)
; tem resb 64
section .text
global _start
_start:
push text
call _print
call _exit
_print:
; first we remove the params from the stack
; remembering to not fuck up our return pointer
pop qword [trip] ; pop old instruction pointer, save for later.
pop rax ; pop first argument
push qword [trip] ; push the old execution pointer back
; reset base stack to here.
push rbp
mov rbp, rsp
; push in our arguments
push rax
; rbp+0 => old base pointer
; rbp+8 => old instruction pointer
; rbp+16 => last param
; rbp+24 => first param
mov rax, 1
mov rdi, 1
mov rsi, [rbp - 8]
mov rdx, 4
syscall
; pop variables (arguments) off stack
add rsp, 8
pop rbp
ret
_exit:
mov rax, 60
mov rdi, 0
syscall
ret