2

I'm trying to link some assembly files, but I'm having some problems. I use nasm and I make my object file with:

nasm -f elf -o task1.o task1.asm

and when I try to link it with some other files with:

gcc -o task1 task1.o asm_io.o

I get error:

i386 architecture of input file 'task1.o' is incompatible with i386:x86-64 output

and same error for file asm_io.o.

My Ubutnu is 64-bit.
When I try command:

nasm -f elf64 -o task1.o task1.asm

I get error that instructions pusha and popa are not supported in 64-bit mode.
Can you tell me what instructions to use instead of pusha and popa, and what gcc command to use?

Richard
  • 8,961
  • 3
  • 38
  • 47
user3450584
  • 21
  • 1
  • 2

1 Answers1

1

Can you tell me what instructions to use instead of pusha and popa, and what gcc command to use?

Please see stackoverflow/6837392 for suggestions on how to code equivalents for PUSHA and POPA.

If you wish to build a 32 bit binary on your 64 bit host, you will need to explicitly specify the -m32 switch to GCC, and will need to have a 32 bit development environment installed. Please see the discussion about multi-arch support and the Installing Compilers community wiki page for more information about building 32 bit programs on Ubuntu.

Community
  • 1
  • 1
jkoshy
  • 1,793
  • 15
  • 23