Author Topic: Lea Command  (Read 6088 times)

Offline legionary

  • New Member
  • Posts: 1
Lea Command
« 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?

Offline encryptor256

  • Full Member
  • **
  • Posts: 250
  • Country: lv
  • Win64 .
    • On Youtube: encryptor256
Re: Lea Command
« Reply #1 on: December 05, 2013, 08:56:11 AM »
Hi!

Quote
How do i use the Lea command in NASM.

My recent, top most, used lea instruction is like this:
x64:
Code: [Select]
lea rsp,[rsp-8*5]
x32, would be like this:
Code: [Select]
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:
Code: [Select]
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
Code: [Select]
; ebx is base address
lea eax,[ebx+y*ROW_LEN + x]

Bye, Encryptor256.
« Last Edit: December 05, 2013, 09:16:42 AM by encryptor256 »
Encryptor256's Investigation \ Research Department.