flat assembler
Message board for the users of flat assembler.

Index > Main > address of local variable ?

Author
Thread Post new topic Reply to topic
WarrantyVoider



Joined: 02 Aug 2005
Posts: 1
WarrantyVoider
I use the proc syntax for my stackframe with local variables like this:

-------------------------------------------
proc test
locals
a rd 1
b rb 1000
endl
MOV EAX,1
MOV [a],EAX
....
-------------------------------------------

but what if I need the address of a local var?
LEA EAX,a
doesn´t work of course. The code I want might be

MOV EAX,EBP
sub EAX,theOffsetOfARelativeToEbpOfCourse

So how do I get the address of local vars (as it is needed often for api calls etc.) without completely throwing out "proc" and "locals" and doing all the stack management by hand?

Please help a newbie here.
Thanks!
WV
Post 02 Aug 2005, 16:53
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
LEA needs a memory operand:
Code:
lea eax,[a]    
Post 02 Aug 2005, 16:57
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Indeed lea is confusing for new users but its rather logical when considering the acronym that it is. Load Effective ADDRESS and this is exactly what is does. It only loads the address in the brackets to the provided registry.
Post 03 Aug 2005, 22:40
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.