;; exnl7.asm 32 bit read and print file ;; Test _read and _write system calls windows, read, write linux ;; removed _ for linux ;; ;; nasm -f elf -Wall -Werror exnl7.asm ;; gcc -m32 -o exnl7 exnl7.o ;; exnl7 < exnl7file.txt > exnl7.out ;; cat exnl7.out section .data prompt db 'Enter a string: ',0 prompt_len equ $ - prompt BUFSZ equ 1024 STDIN equ 0 STDOUT equ 1 section .bss buffer resb BUFSZ section .text global main extern read, write main: push prompt_len push prompt push STDOUT call write ; terminal or > file add esp, 12 push BUFSZ - 1 ; leave space for terminating 0 push buffer push STDIN ; command line or < file call read add esp, 12 push eax ; _read returns string length in eax push buffer push STDOUT call write add esp, 12 mov eax, 0 ret