What is the 0x10 in the “leal 0x10(%ebx), %eax” x86 assembly instruction?

leal, or lea full name is “Load effective address” and it does exactly this: It does an address calculation.

In your example the address calculation is very simple, because it just adds a offset to ebx and stores the result in eax:

eax = ebx + 0x10

lea can do a lot more. It can add registers, multiply registers with the constants 2, 4 and 8 for address calculations of words, integers and doubles. It can also add an offset.

Note that lea is special in the way that it will never modify the flags, even if you use it as a simple addition like in the example above. Compilers sometimes exploit this feature and replace an addition by a lea to help the scheduler. It’s not uncommon to see lea instructions doing simple arithmetic in compiled code for that reason.

Leave a Comment