所以我编写的代码可以从STDIN中读取内容。有用。但是当我写一些string
,一个number
并按下ENTER时会抛出错误:Segmentation fault (core dumped)
。代码如下所示:
SYSCALL32 = 0x80
EXIT = 1
STDIN = 0
READ = 3
STDOUT = 1
WRITE = 4
B_SIZE = 80
.data
BUF: .space B_SIZE
.text
.globl _start
_start:
pushq %rbp
movq %rsp, %rbp
movl $READ, %eax
movl $STDIN, %ebx
movl $BUF, %ecx
movl $B_SIZE, %edx
int $SYSCALL32
我用Makefile
编译它:
# linking
main: main.o #
ld -o main main.o
# compiling
main.o: main.s #
as -o main.o main.s
我在Manjaro 64位上运行它。我做错了什么?