|
@@ -0,0 +1,48 @@
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+macro _syscall code,[arg] {
|
|
|
|
|
+ common
|
|
|
|
|
+ _reg equ r9
|
|
|
|
|
+ _reg equ r8
|
|
|
|
|
+ _reg equ rcx
|
|
|
|
|
+ _reg equ rdx
|
|
|
|
|
+ _reg equ rsi
|
|
|
|
|
+ _reg equ rdi
|
|
|
|
|
+
|
|
|
|
|
+ forward
|
|
|
|
|
+ mov _reg, arg
|
|
|
|
|
+ restore _reg
|
|
|
|
|
+ common
|
|
|
|
|
+ mov rax, code
|
|
|
|
|
+ syscall
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+macro sys_read fd,buf,count {
|
|
|
|
|
+ _syscall 0, fd, buf, count
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+macro sys_write fd,buf,count {
|
|
|
|
|
+ _syscall 1, fd, buf, count
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+O_RDONLY = 0o
|
|
|
|
|
+O_WRONLY = 1o
|
|
|
|
|
+O_RDWR = 2o
|
|
|
|
|
+O_CREAT = 100o
|
|
|
|
|
+O_EXCL = 200o
|
|
|
|
|
+O_NOCTTY = 400o
|
|
|
|
|
+O_APPEND = 2000o
|
|
|
|
|
+O_NONBLOCK = 4000o
|
|
|
|
|
+
|
|
|
|
|
+macro sys_open filename,flags,mode {
|
|
|
|
|
+ _syscall 2, filename, flags, mode
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+macro sys_close fd {
|
|
|
|
|
+ _syscall 3, fd
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+macro sys_exit code {
|
|
|
|
|
+ _syscall 60, code
|
|
|
|
|
+}
|
|
|
|
|
+
|