2019-11-14 05:08:11 +01:00
|
|
|
.intel_syntax noprefix
|
|
|
|
.text
|
2019-11-15 00:04:40 +01:00
|
|
|
.globl _start, syscall5
|
2019-11-14 05:08:11 +01:00
|
|
|
|
|
|
|
_start:
|
|
|
|
xor rbp,rbp
|
|
|
|
pop rdi
|
|
|
|
mov rsi,rsp
|
|
|
|
and rsp,-16
|
2019-11-14 08:23:44 +01:00
|
|
|
call main__main
|
2019-11-14 05:08:11 +01:00
|
|
|
|
|
|
|
mov rdi,rax /* syscall param 1 = rax (ret value of main) */
|
|
|
|
mov rax,60 /* SYS_exit */
|
|
|
|
syscall
|
|
|
|
|
|
|
|
ret /* should never be reached, but if the OS somehow fails
|
|
|
|
to kill us, it will cause a segmentation fault */
|
|
|
|
|
2019-11-15 00:04:40 +01:00
|
|
|
syscall5:
|
2019-11-14 05:08:11 +01:00
|
|
|
mov rax,rdi
|
|
|
|
mov rdi,rsi
|
|
|
|
mov rsi,rdx
|
|
|
|
mov rdx,rcx
|
|
|
|
mov r10,r8
|
|
|
|
mov r8,r9
|
|
|
|
syscall
|
|
|
|
ret
|
|
|
|
|
2019-11-15 01:17:47 +01:00
|
|
|
syscall6:
|
|
|
|
mov rax,rdi
|
|
|
|
mov rdi,rsi
|
|
|
|
mov rsi,rdx
|
|
|
|
mov rdx,rcx
|
|
|
|
mov r10,r8
|
|
|
|
mov r8,r9
|
|
|
|
mov r9, [rsp+8]
|
|
|
|
syscall
|
|
|
|
ret
|
|
|
|
|