include 'sys.asm' format ELF64 executable segment writable readable struc db [data] { common . db data .size = $ - . } stat_msg db 'Get file stats', 10 open_msg db 'Open file', 10 read_msg db 'Read file', 10 close_msg db 'Close file', 10 msg_dn db ':', 10 indexname db 'index.html' ;; indexstat stat indexlen rq 1 indexfd dd 0 indexbuf dd ? indexbuf_len rq 1 segment readable executable entry _main _main: ls_write STDOUT, open_msg, open_msg.size ls_open indexname, O_RDONLY, 0 mov qword [indexfd], rax cmp [indexfd], 0 jl error ls_write STDOUT, read_msg, read_msg.size ls_read qword [indexfd], indexbuf, indexbuf_len cmp qword rax, 0 jl error mov [indexlen], rax ls_write STDOUT, close_msg, close_msg.size ls_close qword [indexfd] cmp qword rax, 0 jl error ls_write STDOUT, indexname, indexname.size ls_write STDOUT, msg_dn, msg_dn.size ls_write STDOUT, indexbuf, [indexlen] cmp qword rax, 0 jl error ls_exit 0 error: ls_close qword [indexfd] ls_exit 1