如何在64位上编译用nasm编写的汇编代码?

时间:2012-12-19 10:43:14

标签: assembly nasm

我可以在64位上运行吗?

 ;
 ; assemble and link with:
 ; nasm -f elf printf-test.asm && gcc -m32 -o printf-test printf-test.o
 ;
 section .text
 global main
 extern printf

 main:

  mov eax, 0xDEADBEEF
  push eax
  push message
  call printf
  add esp, 8
  ret

  message db "Register = %08X", 10, 0

我收到了这个错误

~/Desktop$ nasm -f elf printTest.asm
~/Desktop$ gcc -m32 -o printTest printTest.o
 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libgcc.a when searching for -lgcc
 /usr/bin/ld: cannot find -lgcc
 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libgcc_s.so when searching for -lgcc_s
 /usr/bin/ld: cannot find -lgcc_s
 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../libc.so when searching for -lc
 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../libc.a when searching for -lc
 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.so when searching for -lc
 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.a when searching for -lc
 /usr/bin/ld: cannot find -lc
 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libgcc.a when searching for -lgcc
 /usr/bin/ld: cannot find -lgcc
 /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libgcc_s.so when searching for -lgcc_s
 /usr/bin/ld: cannot find -lgcc_s
 collect2: ld returned 1 exit status

0 个答案:

没有答案