在Linux 32位x86程序集中显示文本文件的内容

Red*_*Hat 0 linux x86 assembly nasm

如何在Linux 32位x86程序集(NASM语法)中显示文本文件的内容?

提前致谢,

Mic*_*ael 6

我没有测试过这个(它不一定是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)