flat assembler
Message board for the users of flat assembler.
Index
> Main > need help with this example of lea |
Author |
|
redsock 08 Feb 2015, 19:16
Code: lea eax, [esp+4] Code: mov eax, esp add eax, 4 Code: mov eax, [esp+4] |
|||
08 Feb 2015, 19:16 |
|
revolution 09 Feb 2015, 01:10
theguy wrote: ... i'm guessing lea loads the address into eax and the mov instruction along with the brackets, loads what is contained at address 0006ff90. Is that what is happening? And you can use the instruction to do arithmetic operations also: Code: lea ecx,[edx+eax*8+0x24] ;ecx = eax * 8 + edx + 0x24 |
|||
09 Feb 2015, 01:10 |
|
lucifer 09 Feb 2015, 20:32
It's best to think of the lea instruction as an arithmetic function. It's used a lot for performing calculations on addresses as well as doing a bunch of calculations on a number all in a single instruction.
For further information it might be useful to read the operation pseudocode in the Intel manuals. For the lea instruction, the brackets aren't really for dereferencing anything as the instruction only deals with the address values. |
|||
09 Feb 2015, 20:32 |
|
neville 11 Feb 2015, 08:59
[quote="redsock"]
Code: lea eax, [esp+4] Code: mov eax, esp add eax, 4 I generally avoid using LEA, but being able to perform arithmetic without affecting the flags has sometimes been useful. _________________ FAMOS - the first memory operating system |
|||
11 Feb 2015, 08:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.