libk  Diff

Differences From Artifact [fcbc285104]:

To Artifact [1f6b1a0933]:


     1         -;; abi definition file
     2         -;; macros:
     3         -;; * sys: syscall64 wrapper
     4         -;; * ccall: automatically generate code to call a C function
     5         -;;          with any number of arguments
            1  +;; abi definition file for x86 linux 64-bit
            2  +; vim: ft=nasm
            3  +
            4  +; syscall64 numbers - syscall table must be created first!
            5  +%include "calls.x86.lin.64.s"
     6      6   
     7      7   ; syscall ops
     8      8   %define sys.call syscall
     9         -; syscall numbers
    10         -%define sys.write 1
    11         -%define sys.brk 12
    12         -%define sys.exit 60
    13      9   
    14     10   ; register order for syscall convention
           11  +%define sys.reg.n 7
    15     12   %define sys.reg.0 rax
    16     13   %define sys.reg.1 rdi
    17     14   %define sys.reg.2 rsi
    18     15   %define sys.reg.3 rdx
    19     16   %define sys.reg.4 r10
    20     17   %define sys.reg.5 r8
    21     18   %define sys.reg.6 r9
................................................................................
    26     23   %define ccall.reg.1 rsi
    27     24   %define ccall.reg.2 rdx
    28     25   %define ccall.reg.3 rcx
    29     26   %define ccall.reg.4 r8
    30     27   %define ccall.reg.5 r9
    31     28   
    32     29   %macro sys 1-8
           30  +; syscall64 wrapper, ex. `sys sys.write, 1, msg, msg.len`
    33     31   	%assign i 0
    34     32   	%rep %0
    35     33   		mov sys.reg. %+ i, %1 ; i'm actually shocked this worked
    36     34   		%rotate 1
    37     35   		%assign i i+1
    38     36   	%endrep 
    39     37   	syscall