flat assembler
Message board for the users of flat assembler.

Index > IDE Development > New stdcall macroses for Fresh:

Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 27 Sep 2003, 12:25
This is modified version for stdcall.inc file. Advantages are:

1. Only used procedures will be compiled. This will protect the code from dead code.
2. More optimized code for different cases: with/without local variables, with/without parameters - in all cases you can use "proc" macro. if there is no locals and arguments, stack frame is not created at all.
3. Display of what procedures are skiped during compilation.

The main disadvantage is slightly different syntax. Every proc must finish with "endproc" macro:
Code:
proc ProcName, arg1, arg2, arg3
; local variables definition.
        enter
        ; user code here
.exit1

        return
.exit2:
        return  ; more than one return is possible.
.exit3:
        return
endproc 'ProcName'    


What you think about this?

[edit] Outdated file removed. Look in the last version of Fresh for last version of those macroses.[/edit]


Last edited by JohnFound on 12 Oct 2003, 15:12; edited 2 times in total
Post 27 Sep 2003, 12:25
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 27 Sep 2003, 12:39
IMO fasm should have some directive that will display a name of specified identifier, it would make the whole thing simpler....
Post 27 Sep 2003, 12:39
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 27 Sep 2003, 13:10
decard wrote:
IMO fasm should have some directive that will display a name of specified identifier, it would make the whole thing simpler....


The current solution in "endproc" directive is simply a workaround.
AFAIK, it is not easy to make FASM to display label names. We must talk with Privalov for this.

Regards.
Post 27 Sep 2003, 13:10
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 27 Sep 2003, 13:51
I get an error ("invalid macro arguments", at enter) when compiling this:
Code:
format PE console
entry start

include '%include%\win32ax.inc'
include '%FreshRoot%\include\libs\StdcallEx.inc'
include '%FreshRoot%\include\libs\strlib.inc'

section '.code' code readable executable
;------------------------------------------------------------------------
proc GetHandles
  enter

  invoke  GetModuleHandle,0
  mov     [hInstance],eax

  invoke  GetStdHandle,STD_OUTPUT_HANDLE
  mov     [hStdOut],eax
  invoke  GetStdHandle,STD_INPUT_HANDLE
  mov     [hStdIn],eax
  invoke  GetStdHandle,STD_ERROR_HANDLE
  mov     [hStdErr],eax

  return
endproc 'GetHandles'
;------------------------------------------------------------------------
start:  
;...    

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 27 Sep 2003, 13:51
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 27 Sep 2003, 14:05
Scientica:

It is because "win32ax.inc" includes old stdcall.inc and "enter" macro is double redefined - in result "enter" instruction in the macro is interpreted as old "enter" macro.

Maybe we must rename "enter" macro to something different. I think "begin" will be good. Smile (Yea, I am old Pascal programmer Very Happy)

regards.
Post 27 Sep 2003, 14:05
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 27 Sep 2003, 14:15
JohnFound wrote:
Maybe we must rename "enter" macro to something different. I think "begin" will be good. Smile (Yea, I am old Pascal programmer Very Happy)

I've done some pascal too, long time ago thought. Anyway, begin, sounds like good start Smile
What about using end instead of endproc?
And maybe procedure instead of proc? (perhaps a bit too much pascal inspiration, or? Wink)

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 27 Sep 2003, 14:15
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 27 Sep 2003, 14:15
IMHO it would be better to create alternative 'win32ax.inc' with stdcall.inc replaced with stdcallex.inc. I think having different names for the same purpouses (at least from user point of view) is a bad idea....

btw, I also started with pascal... Very Happy
Post 27 Sep 2003, 14:15
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 27 Sep 2003, 14:26
scientica wrote:
What about using end instead of endproc?

FASM uses "end" for some purposes. The same case as "enter"
Quote:
And maybe procedure instead of proc? (perhaps a bit too much pascal inspiration, or? Wink)


Very Happy Yea. I think "procedure" is too long for typing. I think the same for Pascal too. "proc" is shorter.

Quote:
IMHO it would be better to create alternative 'win32ax.inc' with stdcall.inc replaced with stdcallex.inc. I think having different names for the same purpouses (at least from user point of view) is a bad idea....


OK, in the next release of Fresh I will put one copy of Windows include files (at first Ascii only) as part of the Fresh package. If you are agree with new "stdcall.inc" I will convert whole project to use this approach.

Shocked The next release "history.inc" file will be one meter longer. Very Happy

Regards.
Post 27 Sep 2003, 14:26
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 27 Sep 2003, 15:04
I have a little suggestion: why not to change 'endproc' to 'endp'? It will be shorter, and it will be similar to TASM proc syntax. When the problem with displaying symbol names will be solved, we will be able to use the following statement:

Code:
proc myproc
    enter
    (some code)
    return
endp    
Post 27 Sep 2003, 15:04
View user's profile Send private message Visit poster's website Reply with quote
Joshua



Joined: 12 Jul 2003
Posts: 56
Location: Belgium
Joshua 28 Sep 2003, 09:46
this would be a simple solution, however the second line is not allowed.
Code:
strName fix str name str
str fix "
    


Personally i feel you should be able to equ everything. Even stuff like:
Code:
temp1 fix "blah
temp2 fix temp1 blah"
    
Post 28 Sep 2003, 09:46
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 28 Sep 2003, 15:17
I am agree Jushua, but FASM doesn't allow assign via "fix" neither "equ" one only quote. We have to wait for Privalov IMHO.

regards.
Post 28 Sep 2003, 15:17
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 29 Sep 2003, 16:13
Useful macros!
I vote for proc, begin and endp without labels Smile

(I'm too allergic to masm syntax)

[edited]
I agree with Joshua: one must be able to use equ as a text replacement
Post 29 Sep 2003, 16:13
View user's profile Send private message Yahoo Messenger Reply with quote
Betov



Joined: 17 Jun 2003
Posts: 98
Betov 29 Sep 2003, 16:55
"EndP" seems to me an evident choice. This how i call it in RosAsm default HLL Macros.

But, what is that "Return" thingie about?


Betov.
Post 29 Sep 2003, 16:55
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 29 Sep 2003, 17:16
Betov wrote:
But, what is that "Return" thingie about?


Hi, Betov.
It's "leave/ret nn" combination.
Post 29 Sep 2003, 17:16
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Betov



Joined: 17 Jun 2003
Posts: 98
Betov 29 Sep 2003, 18:35
??? Then, what is the "EndP" about ???

Could you simply provide these macros expansions?

(I mean, if i can do it all with one single "EndP" in RosAsm, you surely can do it also, in FASM/fresh parsing, as long as it is surely more easy with a Pre-Parser than with a User Macros Parser...).


Betov.
Post 29 Sep 2003, 18:35
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 29 Sep 2003, 19:50
Hi Betov.

So, look. In generaly I can make "endp" to make leave/return, but this is not useful in some situations. For example you may have severar exit points from procedure. In this case you may write:

Code:
proc SomeProc, arg1, arg2

    begin
    ;some user code
    return
    ; some other user code
    return
    ; user code again
    return

endp 'SomeProc'    


"return" simply exit procedure, "endp" finishes the procedure body at all. They are diferent things. If I embed leave/ret in "endp" macro, I must force the user to use only 1 exit point from procedure. Better check the code for details.

Regards.
Post 29 Sep 2003, 19:50
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 01 Oct 2003, 15:37
Well, after some discutions, the new "^" is fact. Privalov will include it in next official release of FASM. (Thank you Tomasz Smile) Therefore, we can turn to next generation of stdcall library, using this feature. For now you can use my implementation (even buggy Smile ) to compile Fresh sources. Please download the version with new macroses from: http://board.win32asmcommunity.net/attachment.php?s=&postid=120143
and use this approach for future works. Maybe there are not the last versions of some files (I am sure about strlib.asm) but you can easy convert your work symply by deleting function name from "endp" macro.
Read header of "stdcall.asm" for some instructions how to use macroses and how to find missing "endp" (this can be a hard problem.)

Note: If you find that in the package is not last version, please, post it in the forum to let me include it in next release. Now I am working on visual library components. This will let users to create it's own visual components.

Regards.
Post 01 Oct 2003, 15:37
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 03 Oct 2003, 16:36
Important note: The strlib isn't updated in the package above, so you must change line 229 in strlib.asm from:
Code:
  stdcall StrPtr, [esp+4]    

to
Code:
        stdcall StrPtr, [esp+8]    

or else StrLen (and all functions using it), probably will give an unexpected output. (Besides from that fresh compiles with any pain (only 8.7 secs waiting) Smile)

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 03 Oct 2003, 16:36
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.