flat assembler
Message board for the users of flat assembler.

Index > Windows > cproc

Author
Thread Post new topic Reply to topic
djca



Joined: 14 Jul 2004
Posts: 21
djca
I have the following question.
Here is a small c calling convention procedure:
Code:
cproc On_Menu_Select,MenuID
  enter sizeof.PROGRAMM,0
  cmp [MenuID],IDM_TEST
  jne .exit
  invoke MessageBox,0,strStart,NULL,MB_OK
.exit:
  ret
endp    


When it is assembled, the following code emerge:

Code:
push ebp
mov ebp,esp
enter 02DF,00
...    


but isn't the enter instruction supposed to create the stack frame so the push ebp and mov ebp,esp here duplicates with the enter instruction?
Post 13 Jul 2005, 09:07
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
You should not use "enter" yourself when you use the "proc" macros - the macro sets up the stack frame for you automatically. You can declare your local variable this way:
Code:
local var:PROGRAMM    

and the macro will handle the rest.

BTW, in the latest version of includes (I'm just documenting it now), there is no more "cproc" variant of "proc" macro, to define the c convention procedure you will have to do it this way (like in TASM):
Code:
proc On_MenuSelect c, MenuID    
Post 13 Jul 2005, 10:04
View user's profile Send private message Visit poster's website Reply with quote
djca



Joined: 14 Jul 2004
Posts: 21
djca
thaxnx for the fast reply. I tried to declare local vars like
.var
enter
but it didn't work with the stack rather declaring the data prior the procedure code. With the local directive it is working fine.
Post 13 Jul 2005, 13:45
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
See the new documentation on Win32 Headers for all the information about how to use the new macros.
Post 13 Jul 2005, 14:32
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.