简体   繁体   中英

Using a 32 bit assembler

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM