NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: legionary on December 05, 2013, 08:41:04 AM
-
How do i use the Lea command in NASM. Im familair with it on Amiga. "Lea data,a0" on Amiga how would i use this to read something to esi register in Linux Mint 15 KDE using NASM?
-
Hi!
How do i use the Lea command in NASM.
My recent, top most, used lea instruction is like this:
x64:
lea rsp,[rsp-8*5]
x32, would be like this:
lea esp,[esp-8*5]
1. Example, C/C++:
struct POINT
{
int x;
int y;
};
...
POINT ptArray[10]
...
Get pointer to ptArray[7] into eax.
NASM:
mov ebx,ptArray ; C/C++: ebx = &ptArray
mov edx,8 ; C/C++: sizeof(POINT)
lea eax,[ebx+edx*7]
2. Other example, Column's and Rows
; ebx is base address
lea eax,[ebx+y*ROW_LEN + x]
Bye, Encryptor256.