当我用这个命令编译.s文件时,会出现“没有这样的指令”错误:
$ gcc -s -o scall scall.s
scall.s: Assembler messages:
scall.s:2: Error: no such instruction: `section '
scall.s:4: Error: no such instruction: `global _start'
scall.s:7: Error: unsupported instruction `mov'
scall.s:8: Error: unsupported instruction `mov'
scall.s:11: Error: operand size mismatch for `int'
scall.s:13: Error: no such instruction: `section .data'
scall.s:15: Error: no such instruction: `msglength .word 12'
以下是文件代码:
section .text
global _start
_start:
mov 4,%eax
mov 1,%ebx
mov $message,%ecx
mov $msglength,%edx
int $0x80
section .data
message: .ascii "Hello world!"
msglength .word 12
我该如何消除错误?
gcc
来编译它?gcc
是一个 C 编译器,应该使用as
或类似的工具。 - myautmov
是一个有效的指令,应该可以汇编,只是这不是你想要的指令。最近的 gcc / binutils 只会抱怨实际的错误(section
和 global,以及msglength
后面缺少:
)。 - Peter Cordes