ejandra
ejandra

Reputation: 356

In assembly, how can I store esp's address displaced by 4 to a variable?

Is it possible to do this? What I want to do is store to for example another register, esi , the address of esp+4 ?

mov ecx,[esp+4] 

From what I understand, the code above does not store the address esp+4 to ecx but rather the value contained in the address of esp+4 right? Im relatively new to Assembly programming so thank you for all those who will be glad to help me out.

Upvotes: 1

Views: 192

Answers (1)

Mika Lammi
Mika Lammi

Reputation: 1298

Use lea instruction (load effective address).

For example:

lea ecx, [esp + 4]

You could do this manually like this:

mov ecx, esp
add ecx, 4

Upvotes: 3

Related Questions