Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pointless instruction?

Name: Anonymous 2010-04-26 13:49

What does this x86 assembler instruction do?

lea  eax, [eax+0]

AFAIK this has no effect. Then what the hell did GCC generate this for? (in /O3 mode!)

Name: Anonymous 2010-04-26 14:11

>>3
LEA calculates a stack address when that address is not a constant, e.g, position "EBP − 8" on the stack.  LEA does not read memory; it merely performs an address calculation.

For example, you couldn't use:
MOV EAX, EBP - 8
because EBP - 8 is an expression.  You use:
LEA EAX, [EBP - 8]
which is also equivalent to:
MOV EAX, EBP
SUB EAX, 8

however, LEA is faster than the MOV...SUB method.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List