section .bss buf resb 4096 ; BUFSIZ fd resd 1 section .text global _start fn db "/etc/motd",0x0 _syscall: int 0x80 ret _start: push dword fn push dword 0x0 ; O_RDONLY mov eax, 0x5 ; open call _syscall add esp, 8 cmp eax, 0 je exit mov [fd], eax stread: mov eax, [fd] push eax push dword buf push dword 4096 ; BUFSIZ mov eax, 0x3 ; read call _syscall add esp, 12 cmp eax, 0 je exit mov ebx, eax push dword 1 push dword buf push ebx mov eax, 0x4 ; write call _syscall add esp, 12 cmp eax, 0 je exit exit: push dword 0 ; exit code mov eax,0x1 ; sys_exit call _syscall