What the function is of the 0x10 in regards to this LEAL instruction? Is it a multiply or addition or is something else?
leal 0x10(%ebx), %eax
Can someone please clarify? This is x86 assembler on a Linux box.
leal is the Load Effective Address instruction. The first operand should be a memory location and the second operand should be a register. However, in contrast to movl and addl, leal moves that memory address to the destination register.
CX is known as the count register, as the ECX, CX registers store the loop count in iterative operations. DX is known as the data register. It is also used in input/output operations. It is also used with AX register along with DX for multiply and divide operations involving large values.
Assuming you are talking about x86, the MOVSBL instruction extends a byte (8 bits) representing a signed number to 32-bit signed number. The remaining 24 bits are zeros or ones depending on the sign so that the two's complement value remains.
mov [eax], [ebx] would mean "move the contents of the memory location pointed to by ebx to the memory location pointed to be eax . That is a memory-to-memory move, which Intel does not support.
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.
lea
stands for "load effective address"; it is a way to use the sophisticated adressing modes of the IA32 instruction set to do arithmetic. The l
suffix is a way to distinguish the size of instruction operands in the syntax of GNU as, that you have on your Linux box.
So, in short, yes, it's a kind of addition instruction. It can also handle multiplications by 2, 4, or 8 at the same time.
See also this related question (where they are using the Intel syntax to discuss the same instruction):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With