Thursday, 12 September 2013

How can I compile a 32-bit .o file with gcc in my 64-bit machine?

How can I compile a 32-bit .o file with gcc in my 64-bit machine?

Trying to learn NASM Assembly. I have a 64-bit machine, with Ubuntu.
Recently I decided to test the push and pop instructions. I do this:
nasm -felf64 Test.asm
Apparently they are not supported in 64-bit mode. Alright, no problem,
I'll just do it for 32 then:
nasm -felf Test.asm
And now, as always,
gcc Test.o
But it now tells me
i386 architecture of input file 'Test.o' is incompatible with i386:x86-64
output
I don't quite grasp the error here. How can I test push and pop in my
64-bit machine, if apparently I can't compile 32-bit programs?

No comments:

Post a Comment