1 ; ========================
2 ; AcssMicro - System Calls
3 ; ========================
11 mov rdi, [rsp ] ; Base
12 mov rsi, [rsp+ 8] ; ArgC
13 mov rdx, [rsp+16] ; ArgV
14 mov rcx, [rsp+24] ; EnvP
33 mov rcx, rdx ; RDX - Third
39 [global _errno:data 4]
40 _errno: dw 0 ; Placed in .text, to allow use of relative addressing
42 #define SYSCALL0(_name,_num) SYSCALL0 _name, _num
43 #define SYSCALL1(_name,_num) SYSCALL1 _name, _num
44 #define SYSCALL2(_name,_num) SYSCALL2 _name, _num
45 #define SYSCALL3(_name,_num) SYSCALL3 _name, _num
46 #define SYSCALL4(_name,_num) SYSCALL4 _name, _num
47 #define SYSCALL5(_name,_num) SYSCALL5 _name, _num
48 #define SYSCALL6(_name,_num) SYSCALL6 _name, _num
50 ;%define SYSCALL_OP jmp 0xCFFF0000
51 ;%define SYSCALL_OP int 0xAC
52 %define SYSCALL_OP syscall
54 ; System Call - No Arguments
61 mov [DWORD rel _errno], ebx
66 %macro _SYSCALL_HEAD 2
74 %macro _SYSCALL_TAIL 0
75 mov [DWORD rel _errno], ebx
81 ; System Call - 1 Argument
89 ; System Call - 2 Arguments
98 ; System Call - 3 Arguments
108 ; System Call - 4 Arguments
114 mov r10, rcx ; r10 is used in place of RCX
119 ; System Call - 5 Arguments
131 ; System Call - 6 Arguments
144 ; // Override the clone syscall
145 #define clone _clone_raw
146 #define _exit _exit_raw
147 #include "syscalls.s.h"
158 mov r12, rsi ; Save in a reg for after the clone
160 ; Check if the new stack is being used
163 ; Quick hack, just this stack frame
165 mov [rsi-1*8], rax ; Return
166 mov [rsi-2*8], rsi ; EBP
167 and QWORD [rsi-3*8], BYTE 0 ; EBX
172 mov [rel _errno], ebx
174 ; Change stack pointer