vit*_*aut 19 linux assembly compiler-errors gnu-assembler
使用GNU汇编程序组装文件时出现以下错误:
hello.s:6:错误:"push"的指令后缀无效
这是我正在尝试汇编的文件:
.text
LC0:
.ascii "Hello, world!\12\0"
.globl _main
_main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl $0, %eax
movl %eax, -4(%ebp)
movl -4(%ebp), %eax
call __alloca
call ___main
movl $LC0, (%esp)
call _printf
movl $0, %eax
leave
ret
Run Code Online (Sandbox Code Playgroud)
这里有什么问题,我该如何解决?
小智 19
64位指令
默认情况下,大多数操作保持32位,并且REX前缀中的第四位调用64位对应项.这意味着每个32位指令都具有自然的64位扩展,并且扩展寄存器在64位指令中是免费的
movl $1, %eax # 32-bit instruction
movq $1, %rax # 64-bit instruction
pushl %eax # Illegal instruction
pushq %rax # 1 byte instruction encoded as pushl %eax in 32 bits
pushq %r10 # 2 byte instruction encoded as pushl preceeded by REX
Run Code Online (Sandbox Code Playgroud)
Car*_*rum 13
你是用64位汇编程序组装的吗?你的代码看起来像是32位.使用64位汇编程序时,我的代码出现此错误:
example.s:6:suffix or operands invalid for `push'
Run Code Online (Sandbox Code Playgroud)
但它适用于32位汇编程序.