我没有测试过这个(它不一定是NASM语法),但是这些内容应该适用于x86 Linux机器:
; Open file
mov ecx,0 ; FILEMODE_R
mov ebx,filePath
mov edx,01FFh
mov eax,5 ;__NR_open
int 80h ; syscall
mov fileHandle,eax
...
; Read file data
mov ebx,fileHandle
mov ecx,buffer
mov edx,numBytesToRead
mov eax,3 ; __NR_read
int 80h
; Write to STDOUT
mov edx,numCharsToWrite
mov ecx,buffer
mov ebx,1 ; STDOUT
mov eax,4 ; __NR_write
int 80h
; Repeat as many times as necessary
; Close file
mov ebx,fileHandle
mov eax,6 ; __NR_close
int 80h
Run Code Online (Sandbox Code Playgroud)