diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | debug | bin | 15552 -> 0 bytes | |||
-rw-r--r-- | main.asm | 16 | ||||
-rw-r--r-- | sys.asm | 2 |
4 files changed, 17 insertions, 2 deletions
@@ -2,3 +2,4 @@ gf/ | |||
2 | fasm/ | 2 | fasm/ |
3 | main | 3 | main |
4 | *.c | 4 | *.c |
5 | debug | ||
Binary files differ | |||
@@ -12,9 +12,10 @@ struc db [data] | |||
12 | segment writable readable | 12 | segment writable readable |
13 | connect_header db 'HTTP/1.1 200 OK', 13, 10 | 13 | connect_header db 'HTTP/1.1 200 OK', 13, 10 |
14 | db 'Content-Type: text/html', 13, 10 | 14 | db 'Content-Type: text/html', 13, 10 |
15 | db 'Server: asmsite', 13, 10 | ||
15 | db 'Connection: close', 13, 10 | 16 | db 'Connection: close', 13, 10 |
16 | db 13, 10 | 17 | db 13, 10 |
17 | db '<!DOCTYPE html><html><head><title>asmsite</title></head><body>Hello, World!</body></html>', 10 | 18 | db '<!DOCTYPE html><html><head><title>asmsite</title></head><body>Hello, World!</body></html>', 10 |
18 | connect_header_len = $ - connect_header | 19 | connect_header_len = $ - connect_header |
19 | 20 | ||
20 | stat_msg db 'Get file stats', 10 | 21 | stat_msg db 'Get file stats', 10 |
@@ -50,6 +51,13 @@ serveraddr_len = $ - serveraddr.sin_family | |||
50 | clientaddr servaddr_in | 51 | clientaddr servaddr_in |
51 | clientaddr_len dd serveraddr_len | 52 | clientaddr_len dd serveraddr_len |
52 | 53 | ||
54 | struc timespec | ||
55 | { | ||
56 | .time dq 0 | ||
57 | .time_nano dd 0 | ||
58 | } | ||
59 | sleep_time timespec | ||
60 | |||
53 | segment readable executable | 61 | segment readable executable |
54 | 62 | ||
55 | entry _main | 63 | entry _main |
@@ -92,7 +100,7 @@ _main: | |||
92 | jl error | 100 | jl error |
93 | 101 | ||
94 | ls_write STDOUT, listen_msg, listen_msg.size | 102 | ls_write STDOUT, listen_msg, listen_msg.size |
95 | ls_listen qword [socketfd], 5 | 103 | ls_listen qword [socketfd], 4096 |
96 | cmp rax, 0 | 104 | cmp rax, 0 |
97 | jl error | 105 | jl error |
98 | 106 | ||
@@ -106,6 +114,10 @@ listen: | |||
106 | 114 | ||
107 | ls_write qword [connfd], connect_header, connect_header_len | 115 | ls_write qword [connfd], connect_header, connect_header_len |
108 | 116 | ||
117 | ;; mov [sleep_time.time], 10 | ||
118 | ;; mov [sleep_time.time_nano], 1000 | ||
119 | ;; ls_nanosleep sleep_time.time, 0 | ||
120 | |||
109 | ls_close qword [connfd] | 121 | ls_close qword [connfd] |
110 | 122 | ||
111 | jmp listen | 123 | jmp listen |
@@ -44,6 +44,8 @@ macro ls_close fd { scall1 3, fd } | |||
44 | 44 | ||
45 | ;; macro ls_stat filename, statbuf { scall2 4, filename, statbuf } | 45 | ;; macro ls_stat filename, statbuf { scall2 4, filename, statbuf } |
46 | 46 | ||
47 | macro ls_nanosleep rqtp, rmtp { scall2 35, rqtp, rmtp } | ||
48 | |||
47 | macro ls_socket family, type, protocol { scall3 41, family, type, protocol } | 49 | macro ls_socket family, type, protocol { scall3 41, family, type, protocol } |
48 | 50 | ||
49 | macro ls_accept fd, upeer_sockaddr, upeer_addrlen { scall3 43, fd, upeer_sockaddr, upeer_addrlen } | 51 | macro ls_accept fd, upeer_sockaddr, upeer_addrlen { scall3 43, fd, upeer_sockaddr, upeer_addrlen } |