aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys.inc32
1 files changed, 32 insertions, 0 deletions
diff --git a/sys.inc b/sys.inc
new file mode 100644
index 0000000..eef6573
--- /dev/null
+++ b/sys.inc
@@ -0,0 +1,32 @@
+%ifndef SYS_INC
+%define SYS_INC
+%ifidn __OUTPUT_FORMAT__, macho64
+ %define SYS_EXIT 0x02000001
+ %define SYS_READ 0x02000003
+ %define SYS_WRITE 0x02000004
+ %define SYS_OPEN 0x02000005
+ %define SYS_CLOSE 0x02000006
+ %define SYS_MUNMAP 0x02000049
+ %define SYS_MMAP 0x020000C5
+ %define SYS_LSEEK 0x020000C7
+%elifidn __OUTPUT_FORMAT__, elf64
+ %define SYS_READ 0
+ %define SYS_WRITE 1
+ %define SYS_OPEN 2
+ %define SYS_CLOSE 3
+ %define SYS_LSEEK 8
+ %define SYS_MMAP 9
+ %define SYS_MUNMAP 11
+ %define SYS_EXIT 60
+%endif
+
+%macro exit_prog 0-1 0
+ mov rax, SYS_EXIT
+ %if %1 != 0
+ mov rdi, %1
+ %else
+ xor rdi, rdi
+ %endif
+ syscall
+%endm
+%endif