flat assembler
Message board for the users of flat assembler.

Index > Main > Local variables

Author
Thread Post new topic Reply to topic
Maggot



Joined: 31 Jul 2005
Posts: 1
Maggot
when i try this:
Code:
proc proc1
    local   var1:stuct1
    invoke  proc2,var1
endp
    

fasm returns me an error:
invalid value: pushd ..var?00006FC

Is it macro or compiler error? How to correct this mistake?
Post 13 Sep 2005, 18:22
View user's profile Send private message Reply with quote
kidscracker



Joined: 29 Oct 2004
Posts: 46
Location: Peru
kidscracker
When you create a local variable it use the stack, so the variable itselfi isn't an address, it is a poiter relative to EBP , something like EBP-4, etc. To poit to that variable you must use:
Code:
proc proc1
   local var1:struct1

lea eax,[var1]   ; < eax contains the address of var1
invoke proc2,eax  ;< send eax as a parameter

endp
    
Post 13 Sep 2005, 18:47
View user's profile Send private message MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
You could also use:
Code:
proc proc1
  local var1:struct1
  invoke proc2,[var1]
endp
    

_________________
My updated idol Very Happy http://www.agner.org/optimize/
Post 20 Sep 2005, 12:48
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7755
Location: Kraków, Poland
Tomasz Grysztar
Perhaps you mean
Code:
proc proc1
  local var1:struct1
  invoke proc2,addr var1
endp    

it's the address of local variable, not the contents of it that he wants to pass to the procedure. The "addr" will work only with extended Win32 headers and will generate the code with LEA similar to the one kidscracker posted.
Post 20 Sep 2005, 12:55
View user's profile Send private message Visit poster's website 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. Also on YouTube, Twitter.

Website powered by rwasa.