Question

I am trying to assemble some 32-bit code as such

gcc -o a.out code.s

but I am getting the following message:

Error: invalid instruction suffix for 'push'

back from the assembler. The line of code that is causing this is the following:

    pushl   %ebp

I have done some research that says I need to use a 32-but assembler. Can someone show me how I do this?

Was it helpful?

Solution

You are probably trying to do this on a 64 bit system, where gcc defaults to -m64.

So just do this:

gcc -Wall -m32 code.s

OTHER TIPS

If you have 32 bit assembly code, then you need to compile with a 32 bit toolset. It looks like you are compiling with a 64 bit toolset which would appear to be the problem. You cannot mix 32 bit and 64 bit code in one module.

Your options:

  1. Compile with 32 bit tools, and emit 32 bit objects.
  2. Port the assembly code to 64 bit.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top