summaryrefslogtreecommitdiff
path: root/sys.asm
diff options
context:
space:
mode:
Diffstat (limited to 'sys.asm')
-rw-r--r--sys.asm68
1 files changed, 68 insertions, 0 deletions
diff --git a/sys.asm b/sys.asm
new file mode 100644
index 0000000..b9ab190
--- /dev/null
+++ b/sys.asm
@@ -0,0 +1,68 @@
1STDIN equ 0
2STDOUT equ 1
3STDERR equ 2
4
5O_RDONLY equ 0
6O_WRONLY equ 1
7O_RDWR equ 2
8
9macro scall1 v_rax, v_rdi
10{
11 mov rax, v_rax
12 mov rdi, v_rdi
13 syscall
14}
15
16macro scall2 v_rax, v_rdi, v_rsi
17{
18 mov rax, v_rax
19 mov rdi, v_rdi
20 mov rsi, v_rsi
21 syscall
22}
23
24macro scall3 v_rax, v_rdi, v_rsi, v_rdx
25{
26 mov rax, v_rax
27 mov rdi, v_rdi
28 mov rsi, v_rsi
29 mov rdx, v_rdx
30 syscall
31}
32
33macro ls_read fd, buf, count { scall3 0, fd, buf, count }
34
35macro ls_write fd, buf, count { scall3 1, fd, buf, count }
36
37macro ls_open filename, flags, mode { scall3 2, filename, flags, mode }
38
39macro ls_close fd { scall1 3, fd }
40
41;; kernel: arch/x86/include/uapi/asm/stat.h
42;; struc stat
43;; {
44;; .st_dev rd 1
45;; .st_ino rd 1
46;; .st_mode rw 1
47;; .st_nlink rw 1
48;; .st_uid rw 1
49;; .st_gid rw 1
50;; .st_rdev rd 1
51;; .st_size rd 1
52;; .st_blksize rd 1
53;; .st_blocks rd 1
54;;
55;; .st_atime rd 1
56;; .st_atime_nsec rd 1
57;; .st_mtime rd 1
58;; .st_mtime_nsec rd 1
59;; .st_ctime rd 1
60;; .st_ctime_nsec rd 1
61;;
62;; .__unused4 rd 1
63;; .__unused5 rd 1
64;; }
65macro ls_stat filename, statbuf { scall2 4, filename, statbuf }
66
67macro ls_exit status { scall1 60, status }
68