以下是我希望NASM程序中的相关代码。调用int 080h后,调试器显示-9表示eax。我的test.txt中的文字是321314145.我一直盯着这几个小时,我在这里遇到了死路一条。为什么会这样?
%define BUFLEN 128
%define READLEN 3
%define SYSCALL_READ 3
SECTION .bss ; uninitialized data section
buf: resb READLEN ; buffer for read
rlen: resb 4
newstr: resb BUFLEN
; read file name from arg
;
pop ebx ;not using
pop ebx ;not using
pop ebx ;pop filename
; open file
;
mov eax, SYSCALL_OPEN
mov ecx, STDIN
int 080h
mov eax, SYSCALL_READ ; read function
mov ebx, eax ; Arg: file descriptor
mov ecx, buf ; Arg: address of buffer
mov edx, READLEN ; Arg: buffer length
int 080h
答案 0 :(得分:0)
mov eax, SYSCALL_READ ; read function
mov ebx, eax ; Arg: file descriptor
你在开玩笑吧?
-9
是“错误的文件编号”(每个errno.h)。确保您的sys_open成功,然后将eax
放入ebx
....在更改eax
之前!