【发布时间】:2015-02-03 10:54:38
【问题描述】:
使用此命令编译 .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或类似工具。 -
这就是我们现在在学校使用的。
-
unsupported instruction 'mov'没有意义。来自绝对地址的mov是应该汇编的有效指令,它不是您想要的。最近的 gcc / binutils 只抱怨实际错误(section和全局,以及在msglength之后缺少的:)