algorithms

Compiler Error C2431

When you do this inline assembly in MS Visual C

LEA EAX, [EBX+2*EBP]

everything is just fine.

LEA ESP, [EBX+4*EBP]

also compiles well.

LEA ESP, [EBX+ESP]

okay again.

But when you try this

LEA EAX, [EBX+2*ESP]

you get error C2431.

Other compilers also fail to compile it! Like GAS, for example.

I have googled extensively but no valid explanation anywhere. Not a trace of it.

What is going on here?

 

Advertisements
Standard

2 thoughts on “Compiler Error C2431

  1. post-modern climate scientology says:

    LEA EAX, [EBX+2*ESP]
    ^^^^^ invalid effective address

    esp is not allowed as an index in sib (scale/base/index) addressing

    • You can’t write “MOV EIP, EAX”.

      At least I haven’t found how to do it yet, anyway.

      But you CAN write the opcode for the “LEA [ECX+4*ESP]” directly. And then execute that opcode. This way LEA becomes something else than LEA usually means, but who cares?

      Go direct opcodes, young man!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s