diff options
author | fxqnlr <[email protected]> | 2024-09-19 20:06:53 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-09-19 20:06:53 +0200 |
commit | f0b8e96b51b1a8b19365c9d010639c8d67a42506 (patch) | |
tree | 36a217aa03f7174ddfdbb34736f2288072bda4af /sys.asm | |
download | asmsite-f0b8e96b51b1a8b19365c9d010639c8d67a42506.tar asmsite-f0b8e96b51b1a8b19365c9d010639c8d67a42506.tar.gz asmsite-f0b8e96b51b1a8b19365c9d010639c8d67a42506.zip |
initial commit
Diffstat (limited to 'sys.asm')
-rw-r--r-- | sys.asm | 68 |
1 files changed, 68 insertions, 0 deletions
@@ -0,0 +1,68 @@ | |||
1 | STDIN equ 0 | ||
2 | STDOUT equ 1 | ||
3 | STDERR equ 2 | ||
4 | |||
5 | O_RDONLY equ 0 | ||
6 | O_WRONLY equ 1 | ||
7 | O_RDWR equ 2 | ||
8 | |||
9 | macro scall1 v_rax, v_rdi | ||
10 | { | ||
11 | mov rax, v_rax | ||
12 | mov rdi, v_rdi | ||
13 | syscall | ||
14 | } | ||
15 | |||
16 | macro 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 | |||
24 | macro 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 | |||
33 | macro ls_read fd, buf, count { scall3 0, fd, buf, count } | ||
34 | |||
35 | macro ls_write fd, buf, count { scall3 1, fd, buf, count } | ||
36 | |||
37 | macro ls_open filename, flags, mode { scall3 2, filename, flags, mode } | ||
38 | |||
39 | macro 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 | ;; } | ||
65 | macro ls_stat filename, statbuf { scall2 4, filename, statbuf } | ||
66 | |||
67 | macro ls_exit status { scall1 60, status } | ||
68 | |||