libk  Diff

Differences From Artifact [fcbc285104]:

To Artifact [1f6b1a0933]:


1
2
3

4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20
21
..
26
27
28
29
30
31
32

33
34
35
36
37
38
39
;; abi definition file
;; macros:
;; * sys: syscall64 wrapper

;; * ccall: automatically generate code to call a C function
;;          with any number of arguments

; syscall ops
%define sys.call syscall
; syscall numbers
%define sys.write 1
%define sys.brk 12
%define sys.exit 60

; register order for syscall convention

%define sys.reg.0 rax
%define sys.reg.1 rdi
%define sys.reg.2 rsi
%define sys.reg.3 rdx
%define sys.reg.4 r10
%define sys.reg.5 r8
%define sys.reg.6 r9
................................................................................
%define ccall.reg.1 rsi
%define ccall.reg.2 rdx
%define ccall.reg.3 rcx
%define ccall.reg.4 r8
%define ccall.reg.5 r9

%macro sys 1-8

	%assign i 0
	%rep %0
		mov sys.reg. %+ i, %1 ; i'm actually shocked this worked
		%rotate 1
		%assign i i+1
	%endrep 
	syscall
|
|
<
>
|
|



<
<
<
<


>







 







>







1
2

3
4
5
6
7
8




9
10
11
12
13
14
15
16
17
18
..
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
;; abi definition file for x86 linux 64-bit
; vim: ft=nasm


; syscall64 numbers - syscall table must be created first!
%include "calls.x86.lin.64.s"

; syscall ops
%define sys.call syscall





; register order for syscall convention
%define sys.reg.n 7
%define sys.reg.0 rax
%define sys.reg.1 rdi
%define sys.reg.2 rsi
%define sys.reg.3 rdx
%define sys.reg.4 r10
%define sys.reg.5 r8
%define sys.reg.6 r9
................................................................................
%define ccall.reg.1 rsi
%define ccall.reg.2 rdx
%define ccall.reg.3 rcx
%define ccall.reg.4 r8
%define ccall.reg.5 r9

%macro sys 1-8
; syscall64 wrapper, ex. `sys sys.write, 1, msg, msg.len`
	%assign i 0
	%rep %0
		mov sys.reg. %+ i, %1 ; i'm actually shocked this worked
		%rotate 1
		%assign i i+1
	%endrep 
	syscall