강의정리/Z0FCourse_Re

[x86-64] LEA, Square Brackets

우와해커 2020. 1. 21. 11:16

Square Brackets - Square brackets signify "address pointed to". For example, [var] is the address pointed to by var. In other words, when using [var] we want to access the memory address that var is holding.

 

LEA - Ignore literally everything about square brackets when working with LEA.

LEA is short for Load Effective Address and it's used for calculating and loading addresses.

 

LEA is used to load and calculate addresses, NOT data.

 

 

Here is a simple example of dereferencing and a pointer in Assembly:
If that Assembly was executed, var would be 12.

lea RAX, [var]
mov [RAX], 12

 

Earlier I said that LEA can be used to calculate addresses, and it often is

lea RAX, [RCX+8]    ;This will set RAX to the address of RCX+8.
mov RAX, [RCX+8]    ;This will set RAX to the value inside of RCX+8.