【发布时间】:2015-10-18 02:02:42
【问题描述】:
我对组装很陌生,所以如果我问了一个不好的问题,请原谅我。我在 Linux 机器上使用 GCC 编译器来运行我的代码。所以我有一个简单的 hello world C 代码可以完美运行,然后我使用这个命令把它变成汇编:
gcc -S hello.s
当我使用这个命令运行它时,我得到了一些错误的寄存器名称错误:
gcc -m32 hello.s -o hello
我收到的错误消息是:
hello.s:11: Error: bad register name '%rbp'
hello.s:14: Error: bad register name '%rsp'
hello.s:19: Error: bad register name '%rbp'
C 代码:
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
return 0;
}
组装:
.file "hello.c"
.section .rodata
.LC0:
.string "hello, world"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $.LC0, %edi
call puts
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Debian 4.7.2-5) 4.7.2"
.section .note.GNU-stack,"",@progbits
很抱歉给您带来的麻烦,并在此先感谢您提供任何反馈。
【问题讨论】:
标签: assembly