%include "CONSTANTS.h" ; linux/unix definintions ; see main open for more info SYS_OPEN equ 2 SYS_CLOSE equ 3 O_RDONLY equ 0 section .data ;fileName: db `afile`,0 fileName: db `ocap.txt`,0 fd: dq 0 ; the file descriptor stringFMT: db `"%s"\n`,0 section .bss newWord resb 101 section .text global main main: ; open the file mov rax, SYS_OPEN mov rdi, fileName mov rsi, O_RDONLY mov rdx, 0 syscall ; save the file descriptor mov [fd], rax ; read at most 100 bytes from the fiel mov rax, SYS_READ mov rdi, [fd] mov rsi, newWord mov rdx, 100 syscall ; rax will contain the number of bytes read mov byte [newWord + rax], 0 ; print out the string we just got mov rdi, stringFMT mov rsi, newWord call CallPrintf ; close the file mov rax, SYS_CLOSE mov rdi, [fd] syscall jmp Exit