Anderson Green
Anderson Green

Reputation: 31850

Get the location of a variable in x86 assembly language

In x86 assembly language, is it possible to determine the location of a variable in memory?

Here, I'm trying to find the location of X in memory, so that I can find the value that is stored at the address immediately after it.

.686p
.model flat,stdcall
.stack 2048

.data
X   byte         "1234"

ExitProcess proto, exitcode:dword
.code
start:

mov ah, X;
;now how can I obtain the location of X in memory?

invoke  ExitProcess, 0
end start ;what does the end statement do?

Upvotes: 2

Views: 5849

Answers (1)

Alexey Frunze
Alexey Frunze

Reputation: 62106

Use the lea instruction, something like:

lea edx, byte ptr x

Upvotes: 5

Related Questions