1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
STDIN equ 0
STDOUT equ 1
STDERR equ 2
O_RDONLY equ 0
O_WRONLY equ 1
O_RDWR equ 2
AF_INET equ 2
SOCK_STREAM equ 1
INADDR_ANY equ 0
macro scall1 v_rax, v_rdi
{
mov rax, v_rax
mov rdi, v_rdi
syscall
}
macro scall2 v_rax, v_rdi, v_rsi
{
mov rax, v_rax
mov rdi, v_rdi
mov rsi, v_rsi
syscall
}
macro scall3 v_rax, v_rdi, v_rsi, v_rdx
{
mov rax, v_rax
mov rdi, v_rdi
mov rsi, v_rsi
mov rdx, v_rdx
syscall
}
macro ls_read fd, buf, count { scall3 0, fd, buf, count }
macro ls_write fd, buf, count { scall3 1, fd, buf, count }
macro ls_open filename, flags, mode { scall3 2, filename, flags, mode }
macro ls_close fd { scall1 3, fd }
;; macro ls_stat filename, statbuf { scall2 4, filename, statbuf }
macro ls_nanosleep rqtp, rmtp { scall2 35, rqtp, rmtp }
macro ls_socket family, type, protocol { scall3 41, family, type, protocol }
macro ls_accept fd, upeer_sockaddr, upeer_addrlen { scall3 43, fd, upeer_sockaddr, upeer_addrlen }
macro ls_bind fd, umyaddr, addrlen { scall3 49, fd, umyaddr, addrlen }
macro ls_listen fd, backlog { scall2 50, fd, backlog }
macro ls_exit status { scall1 60, status }
|