flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > New experiments in StdCall.

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 07 Aug 2004, 16:40
Hi, all.
Vid, you are right about the common frame block.
S.T.A.S, I am agree - we don't need two proc macroses. Only two returns.

After some though, I decided (again) to not implement and support [esp] based stack frames.
IMHO, it is not native assembler style and it harms the readability and the neatness of the code and is possible source of hard to find bugs.
If the user want to use esp as argument pointer he can do this with his own code - like in some procedures in strlib.asm from Fresh.

Also, I found the method to track whether the arguments are dotted or not, so now it is not a problem to keep arguments in the "proc" statement. The only problem (not very big IMHO) remains the one with different sizes of the arguments.
The latest structure of the procedures:
Code:
Procedure definition structure:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 +---proc ProcName, [arg]---+  Arguments have to be local (dotted).
 |                          |  Otherwise, error will araise.
 |     .cloc1 dd ?          |  Common locals block, between "proc" and
 |     .cloc2 dd ?          |  "begin". Not overlaped by "locals" blocks.
 +---begin------------------+
 | +--locals -------+       | Code block between "begin" and
 | |    .loc1 dd ?  |       | "endp" - optional content.
 | |    .loc2 dw ?  |       |
 | +--endl ---------+       | Floating locals blocks inside the
 |                          | code, enclosed between "locals"
 | +--locals--------+       | and "endl" where every block
 | |    .loc3 db ?  |       | overlaps the others in stack
 | |    .loc4 db ?  |       | memory.
 | +--endl----------+       |
 |                          |
 +--endp--------------------+


Frame structure:
~~~~~~~~~~~~~~~~
+----+ ---------> [ebp - Frame1 - commsize]
|    | Frame 1
|    |----+ ----------> [ebp-Frame2-commsize]
|    |    | Frame 2
|    |    |----+ ---------> [ebp-Frame3-commsize]
|    |    |    | Frame 3
+--------------+ ---------> [ebp-commsize]
|              | Frame, that is common for
|              | entire procedure.
+--------------+ -------------------> [ebp]
|              | Arguments
+--------------+ ------> [ebp+Arguments]    
Post 07 Aug 2004, 16:40
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 07 Aug 2004, 17:04
I agree, but I would prefer your style "4"

Code:
Procedure definition structure:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 +--proc ProcedureName------+ 
 |    .arg1 dd ?            | Arguments block between "proc" 
 |    .arg2 dd ?            | and "begin" - optional content 
 |    .arg3 dd ?            | 
 | +--locals -------+       | Common locals block, between "proc" and
 | |    .cloc1 dd ? |       | "begin". Not overlaped by "locals" blocks.
 | |    .cloc2 dw ? |       |
 | +--endl ---------+       | Floating locals blocks inside the
 +---begin------------------+
 | +--locals -------+       | Code block between "begin" and
 | |    .loc1 dd ?  |       | "endp" - optional content.
 | |    .loc2 dw ?  |       |
 | +--endl ---------+       | Floating locals blocks inside the
 |                          | code, enclosed between "locals"
 | +--locals--------+       | and "endl" where every block
 | |    .loc3 db ?  |       | overlaps the others in stack
 | |    .loc4 db ?  |       | memory.
 | +--endl----------+       |
 |                          |
 +--endp--------------------+
    
Post 07 Aug 2004, 17:04
View user's profile Send private message Yahoo Messenger Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 07 Aug 2004, 17:26
JohnFound wrote:
Hi, all.
S.T.A.S, I am agree - we don't need two proc macroses. Only two returns.


IMO, from user point of view, it would be better to have two proc macroses. It simply would be more readable, when I will see "proc" or "cproc" I will know what calling convensions it uses. Using two returns, I would have to scroll through its code to find what kind of proc it is. And what if I write one proc with two different returns?
Post 07 Aug 2004, 17:26
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 07 Aug 2004, 17:27
pelaillo wrote:
I agree, but I would prefer your style "4"


Yes, I like it too. But there is one "little" problem: How to make "stdcall" macros for procedures with mixed size arguments... Also, I am afraid at the end we will finish with thousends of unnecessary "dd ?".
Post 07 Aug 2004, 17:27
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 07 Aug 2004, 17:38
decard:
What about:
Code:
cproc equ proc    
?
Post 07 Aug 2004, 17:38
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 07 Aug 2004, 17:43
JohnFound wrote:
Also, I found the method to track whether the arguments are dotted or not, so now it is not a problem to keep arguments in the "proc" statement.

why not to make user write arguments' names with dots? I think that
this tracking would be only unnecesary load of preprocessor.

regards
Post 07 Aug 2004, 17:43
View user's profile Send private message Visit poster's website Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
S.T.A.S. 08 Aug 2004, 02:28
decard wrote:
IMO, from user point of view, it would be better to have two proc macroses. It simply would be more readable, when I will see "proc" or "cproc" I will know what calling convensions it uses. Using two returns, I would have to scroll through its code to find what kind of proc it is.
Yeah, I see your point.
What I mean is something like this:
Code:
; stdcall
proc  foo  arg,arg2,arg3
...........
; cdecl
proc  bar  arg,arg2, ...  ; <- notice name of the last argument
..........     
Quote:
And what if I write one proc with two different returns?
For which purpose ?
Post 08 Aug 2004, 02:28
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 08 Aug 2004, 09:04
S.T.A.S. wrote:
What I mean is something like this:
Code:
; stdcall
proc  foo  arg,arg2,arg3
...........
; cdecl
proc  bar  arg,arg2, ...  ; <- notice name of the last argument
..........     


right, but it is still a confusing. proc's calling convension should be visible at first sight IMHO.

Quote:

Quote:
And what if I write one proc with two different returns?

For which purpose ?


I just meant a hipotetical situation like this:
Code:
proc foo
...some code...
    stdcall_ret
...some other code...
    c_ret
endp    


of course it doesn't have any sense, but solution with different returns would allow this.
Post 08 Aug 2004, 09:04
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 08 Aug 2004, 10:48
decard wrote:
of course it doesn't have any sense, but solution with different returns would allow this.


Well, actually I can imagine (pretty hypothetic) examples where this can be usefull...
Post 08 Aug 2004, 10:48
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 08 Aug 2004, 11:01
but in this (rather not usual) case you could code it manually, readability is more important IMO.
Post 08 Aug 2004, 11:01
View user's profile Send private message Visit poster's website Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro 08 Aug 2004, 11:15
Wouldn't it be nicer if we had just one return whitch will clean the stack frame if used inside stdcall proc and won't if used inside cdecl proc?
Post 08 Aug 2004, 11:15
View user's profile Send private message Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
S.T.A.S. 08 Aug 2004, 11:34
... And this is really possible. Just give proper name to the last argument
Post 08 Aug 2004, 11:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.