flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [F1] MULTISECTION .code .data .stream (update on first post) Goto page Previous 1, 2, 3, 4 Next |
Author |
|
Overclick 29 Apr 2022, 13:19
Hi guys, seems I fixed Streams
I'll update it in minutes. Few words about Streams: it is most powerful macro feature I ever seen. Once used you never stop
|
||||||||||
29 Apr 2022, 13:19 |
|
Overclick 03 May 2022, 15:11
To complete multisection theme I have to show how to use them without my macro at all:
Code: macro .data { ... YOUR DATA HERE ... } macro .code { ... YOUR CODE HERE ... } ... macro .data { .data ... SOME MORE DATA ... } macro .code { .code ... SOME MORE CODE ... } ... ;COMPLETE REAL SECTIONS: section '.data' data readable writeable .data section '.text' code readable executable entry $ .code |
|||
03 May 2022, 15:11 |
|
Overclick 10 Aug 2022, 15:54
BETA RELEASE OF NEXT-GEN MULTISECTION ENGINE
- No more extra files (include all you want directly to your project) - Superfast - Auto-generating subsections names - Each section adds additional subsection directives like ..data/.dataonce - Auto-gathering library/imput/export and removes already defined writes - Single line subsections ignores global labels that allow them to be used between local labels Rules: - Remove quotes where declaring new sections - Put .endmultisection to the end of main file - Don't use .stream/.frame/..frame or generated .idataonce for library/imput/export, it gather itself by different way - This release has replaced names for single line subsections -- ..data instead of data How it works: Where you declare new section it creates short names for subsections and gather them together after all. For example: Code: section .code code readable executable ; you can put your code here as usual ; but also, it generates new subsections that can be used in other sections or macros .code ... your extra code is here ..code ...single line code subsection .codeonce <unique name> ... one more way to add extra code just once, good for macros that you wish to use multiple times ;..codeonce <unique name>, ...single line code subsection this one coming soon Another useful subsections group: Code: .frame <unique name> ...anything you want excluding another subsections and library/imput/export ..frame <unique name>, ...anything again but single line .stream <unique name> -- the point where all of exact named frames gathered together To integrate multisections with your project just put it on header of your mainfile or include it there. Put .multisection before first section and remove quotes from all of them. Put .endmultisection in bottom of mainfile. Example of header: Code: match any,runonce ;speedup trick, unnecessary for most of scenarios { define runonce ;but some includes may need it include 'multisection.inc' format PE64 GUI 5.0 include 'win64a.inc' } .multisection section .data data readable writeable section .code code readable executable section .idata import data readable writeable ... ... .endmultisection Known issues I need your help to resolve: proc...endp makes me headache in big project but never in any small one. Tomasz, please help Code: D:\TOOLS\Fasm\INCLUDE/macro/proc64.inc [487] endp [1]: finish@proc D:\TOOLS\Fasm\INCLUDE/macro/proc64.inc [390] finish@proc [0]: \{ localbytes = current processed: localbytes?BEV=current?BEW error: undefined symbol 'current?BEW'. MACRO: Code: macro .multisection { match ,skipmultisection \{ end if match any,skipstream ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;for sections \\{ match arg,cuRRent \\\{ macro arg ; .code \\\\{ end if define skipstream ;stream on if 1=1 \\\\} macro .\\\#arg string& ; ..code \\\\{ end if match cur,skipstream \\\\\{ define skipstream ;stream on if 1=1 string end if skipstream equ cur ;stream back \\\\\} if 0 \\\\} macro arg\\\#once param ; .codeonce \\\\{ match ,arg\\\\#once\\\\#param \\\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\\} match some,arg\\\\#once\\\\#param \\\\\{ end if define skipstream ;stream on define arg\\\\\#once\\\\\#param if 1=1 \\\\\} \\\\} macro .endmultisection \\\\{ end if purge section purge arg purge .\\\\#arg purge arg\\\\#once purge library purge import purge export \\\\} \\\} macro section string ; section \\\{ match arg rest,string \\\\{ arg \\\\} \\\} macro library string& \\\{ match ,skipstream \\\\{ match ,libraryonce \\\\\{ \\\\\} match some,libraryonce \\\\\{ define libraryonce match arg,librarygathering \\\\\\{ library arg \\\\\\} \\\\\} \\\\} \\\} macro import namelib,string& \\\{ match ,skipstream \\\\{ match ,importlibonce\\\\#namelib \\\\\{ \\\\\} match some,importlibonce\\\\#namelib \\\\\{ define importlibonce\\\\\#namelib match arg,importgathering\\\\\#namelib \\\\\\{ import arg \\\\\\} \\\\\} \\\\} \\\} macro export namelib,string& \\\{ match ,skipstream \\\\{ match ,exportlibonce\\\\#namelib \\\\\{ \\\\\} match some,exportlibonce\\\\#namelib \\\\\{ define exportlibonce\\\\\#namelib match arg,exportgathering\\\\\#namelib \\\\\\{ export arg \\\\\\} \\\\\} \\\\} \\\} \\} match ,skipstream ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;for streams \\{ ;define skipstream 'nostream' ;stream off macro .stream param \\\{ \\\} macro .frame param \\\{ end if if streamcuRRent eq param \\\} macro ..frame param,string& \\\{ end if if streamcuRRent eq param string end if if 0 \\\} macro library string& \\\{ \\\} macro import string& \\\{ \\\} macro export string& \\\{ \\\} macro proc string& \\\{ \\\} macro endp \\\{ \\\} macro section string ; section skip \\\{ end if if 0 \\\} match arg,cuRRent \\\{ macro arg ; .code skip \\\\{ end if if 0 \\\\} macro .\\\#arg string& \\\\{ \\\\} ; ..code skip macro arg\\\#once param ; .codeonce skip \\\\{ end if if 0 \\\\} macro .endmultisection \\\\{ end if purge section purge arg purge .\\\\#arg purge arg\\\\#once purge .stream purge .frame purge ..frame purge library purge import purge export purge proc purge endp \\\\} \\\} \\} if 0 \} match any,skipmultisection ; * * * * * first run * * * * * \{ define skipmultisection @__file__@ equ __file__ define cuRRent macro section allargs ; section 1 skip \\{ end if ;define skipstream 'nostream' ;stream off match arg rest,allargs \\\{ macro arg ; .code skip \\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\} macro .\\\#arg string& ; ..code skip \\\\{ match ,cuRRent \\\\\{ match firstarg somerest,string \\\\\\{ match =library,firstarg \\\\\\\{ string \\\\\\\} match =import,firstarg \\\\\\\{ string \\\\\\\} match =export,firstarg \\\\\\\{ string \\\\\\\} \\\\\\} \\\\\} \\\\} macro arg\\\#once param ; .codeonce skip \\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\} macro .endmultisection ; extend .endmultisection \\\\{ .endmultisection section \\\\`arg rest cuRRent equ arg define skipstream 'nostream' ;stream off if 0 match f, @__file__@ \\\\\{ include f \\\\\} purge .endmultisection \\\\} \\\} if 0 \\} macro .endmultisection \\{ end if macro .stream frames \\\{ match ,skipstream \\\\{ streamcuRRent equ frames if 0 match f, @__file__@ \\\\\{ include f \\\\\} purge .endmultisection define skipstream \\\\} \\\} purge section purge library purge import purge export ; purge invoke purge proc purge endp macro proc string& \\\{ match ,skipstream \\\\{ match arg,string \\\\\{ proc arg \\\\\} \\\\} \\\} macro endp \\\{ match ,skipstream \\\\{ endp \\\\} \\\} \\} macro .stream param \\{ \\} macro .frame param \\{ end if if 0 \\} macro ..frame param,string& \\{ \\} macro .comment \\{ end if if 0 \\} define librarygathering macro library [namelib,filelib] \\{ \\common end if \\forward match ,libraryonce\\#namelib \\\{ \\\} match some,libraryonce\\#namelib \\\{ define libraryonce\\\#namelib match some,librarygathering \\\\{ librarygathering equ librarygathering,namelib,filelib \\\\} match ,librarygathering \\\\{ librarygathering equ namelib,filelib \\\\} \\\} \\common if 0 \\} macro import namelib,[nameimp,apiimp] \\{ \\common end if \\forward match ,importonce\\#nameimp \\\{ \\\} match some,importonce\\#nameimp \\\{ define importonce\\\#nameimp match ,importnamelibonce\\\#namelib \\\\{ importgathering\\\\#namelib equ importgathering\\\\#namelib,nameimp,apiimp \\\\} match some,importnamelibonce\\\#namelib \\\\{ define importnamelibonce\\\\#namelib define importgathering\\\\#namelib namelib,nameimp,apiimp \\\\} \\\} \\common if 0 \\} macro export namelib,[nameexp,apiexp] \\{ \\common end if \\forward match ,exportonce\\#namelib\\#nameexp \\\{ \\\} match some,exportonce\\#namelib\\#nameexp \\\{ define exportonce\\\#namelib\\\#nameexp match ,exportnamelibonce\\\#namelib \\\\{ exportgathering\\\\#namelib equ exportgathering\\\\#namelib,nameexp,apiexp \\\\} match some,exportnamelibonce\\\#namelib \\\\{ define exportnamelibonce\\\\#namelib define exportgathering\\\\#namelib namelib,nameexp,apiexp \\\\} \\\} \\common if 0 \\} ; macro invoke param& \\{ \\} macro proc param& \\{ \\} macro endp \\{ \\} if 1=1 \} } |
|||
10 Aug 2022, 15:54 |
|
Overclick 11 Aug 2022, 10:51
Seems I fixed proc issues but it still buggy on my big project (about 20k lines). Going to rebuild macro again.
|
|||
11 Aug 2022, 10:51 |
|
macomics 11 Aug 2022, 15:22
Overclick wrote: Put .endmultisection in bottom of mainfile. http://flatassembler.net/docs.php?article=manual#2.3.3 wrote: The "postpone" directive can be used to define a special type of macroinstruction that has no name or arguments and will get automatically called when the preprocessor reaches the end of source: |
|||
11 Aug 2022, 15:22 |
|
Overclick 11 Aug 2022, 16:30
Quote:
I tried it from beginning but it doesn't work with macros. |
|||
11 Aug 2022, 16:30 |
|
Overclick 11 Aug 2022, 16:47
Actually you're right, one moment...
|
|||
11 Aug 2022, 16:47 |
|
Overclick 11 Aug 2022, 16:52
Yeah, I did, no more .endmultisection
Code: macro .multisection { match ,skipmultisection \{ end if match any,skipstream ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;for sections \\{ match arg,cuRRentSection \\\{ macro arg ; .code \\\\{ end if define skipstream ;stream on if 1=1 \\\\} macro .\\\#arg string& ; ..code \\\\{ end if match any,skipstream \\\\\{ define skipstream ;stream on if 1=1 string end if define skipstream 'nostream' ;stream off if 0 \\\\\} match ,skipstream \\\\\{ if 1=1 string end if define skipstream ;stream on if 1=1 \\\\\} \\\\} macro arg\\\#once param ; .codeonce \\\\{ match ,arg\\\\#once\\\\#param \\\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\\} match some,arg\\\\#once\\\\#param \\\\\{ end if define skipstream ;stream on define arg\\\\\#once\\\\\#param if 1=1 \\\\\} \\\\} \\\} macro section string ; section \\\{ match arg rest,string \\\\{ arg \\\\} \\\} macro library string& \\\{ match ,skipstream \\\\{ match ,libraryonce \\\\\{ \\\\\} match some,libraryonce \\\\\{ define libraryonce match arg,librarygathering \\\\\\{ library arg \\\\\\} \\\\\} \\\\} \\\} macro import namelib,string& \\\{ match ,skipstream \\\\{ match ,importlibonce\\\\#namelib \\\\\{ \\\\\} match some,importlibonce\\\\#namelib \\\\\{ define importlibonce\\\\\#namelib match arg,importgathering\\\\\#namelib \\\\\\{ import arg \\\\\\} \\\\\} \\\\} \\\} macro export namelib,string& \\\{ match ,skipstream \\\\{ match ,exportlibonce\\\\#namelib \\\\\{ \\\\\} match some,exportlibonce\\\\#namelib \\\\\{ define exportlibonce\\\\\#namelib match arg,exportgathering\\\\\#namelib \\\\\\{ export arg \\\\\\} \\\\\} \\\\} \\\} \\} match ,skipstream ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;for streams \\{ define skipstream 'nostream' ;stream off macro .stream param \\\{ \\\} macro .frame param \\\{ end if if streamcuRRent eq param \\\} macro ..frame param,string& \\\{ end if if streamcuRRent eq param string end if if 0 \\\} macro library string& \\\{ \\\} macro import string& \\\{ \\\} macro export string& \\\{ \\\} macro proc string& \\\{ \\\} macro endp \\\{ \\\} macro section string ; section skip \\\{ end if if 0 \\\} match arg,cuRRentSection \\\{ macro arg ; .code skip \\\\{ end if if 0 \\\\} macro .\\\#arg string& \\\\{ \\\\} ; ..code skip macro arg\\\#once param ; .codeonce skip \\\\{ end if if 0 \\\\} \\\} \\} if 0 \} match any,skipmultisection ; * * * * * first run * * * * * \{ define skipmultisection @__file__@ equ __file__ define cuRRentSection macro section allargs ; section 1 skip \\{ end if define skipstream 'nostream' ;stream off match arg rest,allargs \\\{ macro arg ; .code skip \\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\} macro .\\\#arg string& ; ..code skip \\\\{ match ,cuRRentSection \\\\\{ match firstarg somerest,string \\\\\\{ match =library,firstarg \\\\\\\{ string \\\\\\\} match =import,firstarg \\\\\\\{ string \\\\\\\} match =export,firstarg \\\\\\\{ string \\\\\\\} \\\\\\} \\\\\} \\\\} macro arg\\\#once param ; .codeonce skip \\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\} macro .endmultisection ; extend .endmultisection \\\\{ .endmultisection section \\\\`arg rest cuRRentSection equ arg define skipstream 'nostream' ;stream off if 0 match f, @__file__@ \\\\\{ include f \\\\\} end if purge section purge arg purge .\\\\#arg purge arg\\\\#once purge library purge import purge export purge proc purge endp \\\\} \\\} if 0 \\} macro .endmultisection \\{ end if purge section purge library purge import purge export purge .stream macro .stream frames \\\{ match ,skipstream \\\\{ streamcuRRent equ frames if 0 match f, @__file__@ \\\\\{ include f \\\\\} end if purge section match arg,cuRRentSection \\\\\{ purge arg purge .\\\\\#arg purge arg\\\\\#once \\\\\} purge .stream purge .frame purge ..frame purge library purge import purge export purge proc purge endp define skipstream \\\\} \\\} purge proc purge endp macro proc string& \\\{ match ,skipstream \\\\{ match arg,string \\\\\{ proc arg \\\\\} \\\\} match some,skipstream \\\\{ macro local args& \\\\\{ \\\\\} \\\\} \\\} macro endp \\\{ match ,skipstream \\\\{ endp \\\\} match some,skipstream \\\\{ purge local \\\\} \\\} \\} macro .stream param \\{ \\} macro .frame param \\{ end if define skipstream 'nostream' ;stream off if 0 \\} macro ..frame param,string& \\{ \\} macro .comment \\{ end if define skipstream 'nostream' ;stream off if 0 \\} define librarygathering macro library [namelib,filelib] \\{ \\common end if \\forward match ,libraryonce\\#namelib \\\{ \\\} match some,libraryonce\\#namelib \\\{ define libraryonce\\\#namelib match some,librarygathering \\\\{ librarygathering equ librarygathering,namelib,filelib \\\\} match ,librarygathering \\\\{ librarygathering equ namelib,filelib \\\\} \\\} \\common if 0 \\} macro import namelib,[nameimp,apiimp] \\{ \\common end if \\forward match ,importonce\\#nameimp \\\{ \\\} match some,importonce\\#nameimp \\\{ define importonce\\\#nameimp match ,importnamelibonce\\\#namelib \\\\{ importgathering\\\\#namelib equ importgathering\\\\#namelib,nameimp,apiimp \\\\} match some,importnamelibonce\\\#namelib \\\\{ define importnamelibonce\\\\#namelib define importgathering\\\\#namelib namelib,nameimp,apiimp \\\\} \\\} \\common if 0 \\} macro export namelib,[nameexp,apiexp] \\{ \\common end if \\forward match ,exportonce\\#namelib\\#nameexp \\\{ \\\} match some,exportonce\\#namelib\\#nameexp \\\{ define exportonce\\\#namelib\\\#nameexp match ,exportnamelibonce\\\#namelib \\\\{ exportgathering\\\\#namelib equ exportgathering\\\\#namelib,nameexp,apiexp \\\\} match some,exportnamelibonce\\\#namelib \\\\{ define exportnamelibonce\\\\#namelib define exportgathering\\\\#namelib namelib,nameexp,apiexp \\\\} \\\} \\common if 0 \\} macro proc param& \\{ \\} macro endp \\{ \\} postpone \\{ .endmultisection \\} if 1=1 \} } Issues still exist for big project Last edited by Overclick on 11 Aug 2022, 21:15; edited 1 time in total |
|||
11 Aug 2022, 16:52 |
|
Overclick 11 Aug 2022, 21:14
EVERYTHING SEEMS FIXED, HAVE A LOOK
Code: macro .multisection { match ,skipmultisection \{ end if match any,skipstream ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;for sections \\{ match arg,cuRRentSection \\\{ macro arg ; .code \\\\{ end if define skipstream ;stream on if 1=1 \\\\} macro .\\\#arg string& ; ..code \\\\{ end if match any,skipstream \\\\\{ define skipstream ;stream on if 1=1 string end if define skipstream 'nostream' ;stream off if 0 \\\\\} match ,skipstream \\\\\{ if 1=1 string end if define skipstream ;stream on if 1=1 \\\\\} \\\\} macro arg\\\#once param ; .codeonce \\\\{ match ,arg\\\\#once\\\\#param \\\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\\} match some,arg\\\\#once\\\\#param \\\\\{ end if define skipstream ;stream on define arg\\\\\#once\\\\\#param if 1=1 \\\\\} \\\\} \\\} macro section string ; section \\\{ match arg rest,string \\\\{ arg \\\\} \\\} macro library string& \\\{ match ,skipstream \\\\{ match ,libraryonce \\\\\{ \\\\\} match some,libraryonce \\\\\{ define libraryonce match arg,librarygathering \\\\\\{ library arg \\\\\\} \\\\\} \\\\} \\\} macro import namelib,string& \\\{ match ,skipstream \\\\{ match ,importlibonce\\\\#namelib \\\\\{ \\\\\} match some,importlibonce\\\\#namelib \\\\\{ define importlibonce\\\\\#namelib match arg,importgathering\\\\\#namelib \\\\\\{ import arg \\\\\\} \\\\\} \\\\} \\\} macro export namelib,string& \\\{ match ,skipstream \\\\{ match ,exportlibonce\\\\#namelib \\\\\{ \\\\\} match some,exportlibonce\\\\#namelib \\\\\{ define exportlibonce\\\\\#namelib match arg,exportgathering\\\\\#namelib \\\\\\{ export arg \\\\\\} \\\\\} \\\\} \\\} \\} match ,skipstream ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;for streams \\{ define skipstream 'nostream' ;stream off macro .stream param \\\{ \\\} macro .frame param \\\{ end if if streamcuRRent eq param \\\} macro ..frame param,string& \\\{ end if if streamcuRRent eq param string end if if 0 \\\} macro library string& \\\{ \\\} macro import string& \\\{ \\\} macro export string& \\\{ \\\} macro proc string& \\\{ \\\} macro endp \\\{ \\\} macro section string ; section skip \\\{ end if if 0 \\\} match arg,cuRRentSection \\\{ macro arg ; .code skip \\\\{ end if if 0 \\\\} macro .\\\#arg string& \\\\{ \\\\} ; ..code skip macro arg\\\#once param ; .codeonce skip \\\\{ end if if 0 \\\\} \\\} \\} if 0 \} match any,skipmultisection ; * * * * * first run * * * * * \{ define skipmultisection @__file__@ equ __file__ define cuRRentSection macro section allargs ; section 1 skip \\{ end if define skipstream 'nostream' ;stream off match arg rest,allargs \\\{ macro arg ; .code skip \\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\} macro .\\\#arg string& ; ..code skip \\\\{ match ,cuRRentSection \\\\\{ match firstarg somerest,string \\\\\\{ match =library,firstarg \\\\\\\{ string \\\\\\\} match =import,firstarg \\\\\\\{ string \\\\\\\} match =export,firstarg \\\\\\\{ string \\\\\\\} \\\\\\} \\\\\} \\\\} macro arg\\\#once param ; .codeonce skip \\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\} macro .endmultisection ; extend .endmultisection \\\\{ .endmultisection section \\\\`arg rest cuRRentSection equ arg define skipstream 'nostream' ;stream off if 0 match f, @__file__@ \\\\\{ include f \\\\\} end if purge section purge arg purge .\\\\#arg purge arg\\\\#once purge library purge import purge export \\\\} \\\} if 0 \\} macro .endmultisection \\{ end if purge section purge library purge import purge export purge .stream macro .stream frames \\\{ match ,skipstream \\\\{ streamcuRRent equ frames if 0 match f, @__file__@ \\\\\{ include f \\\\\} end if purge section match arg,cuRRentSection \\\\\{ purge arg purge .\\\\\#arg purge arg\\\\\#once \\\\\} purge .stream purge .frame purge ..frame purge library purge import purge export purge proc purge endp define skipstream \\\\} \\\} purge proc purge endp macro proc string& \\\{ match ,skipstream \\\\{ match arg,string \\\\\{ proc arg \\\\\} \\\\} match some,skipstream \\\\{ macro local args& \\\\\{ \\\\\} \\\\} \\\} macro endp \\\{ match ,skipstream \\\\{ endp \\\\} match some,skipstream \\\\{ purge local \\\\} \\\} \\} macro .stream param \\{ \\} macro .frame param \\{ end if define skipstream 'nostream' ;stream off if 0 \\} macro ..frame param,string& \\{ \\} macro .comment \\{ end if define skipstream 'nostream' ;stream off if 0 \\} define librarygathering macro library [namelib,filelib] \\{ \\common end if \\forward match ,libraryonce\\#namelib \\\{ \\\} match some,libraryonce\\#namelib \\\{ define libraryonce\\\#namelib match some,librarygathering \\\\{ librarygathering equ librarygathering,namelib,filelib \\\\} match ,librarygathering \\\\{ librarygathering equ namelib,filelib \\\\} \\\} \\common if 0 \\} macro import namelib,[nameimp,apiimp] \\{ \\common end if \\forward match ,importonce\\#nameimp \\\{ \\\} match some,importonce\\#nameimp \\\{ define importonce\\\#nameimp match ,importnamelibonce\\\#namelib \\\\{ importgathering\\\\#namelib equ importgathering\\\\#namelib,nameimp,apiimp \\\\} match some,importnamelibonce\\\#namelib \\\\{ define importnamelibonce\\\\#namelib define importgathering\\\\#namelib namelib,nameimp,apiimp \\\\} \\\} \\common if 0 \\} macro export namelib,[nameexp,apiexp] \\{ \\common end if \\forward match ,exportonce\\#namelib\\#nameexp \\\{ \\\} match some,exportonce\\#namelib\\#nameexp \\\{ define exportonce\\\#namelib\\\#nameexp match ,exportnamelibonce\\\#namelib \\\\{ exportgathering\\\\#namelib equ exportgathering\\\\#namelib,nameexp,apiexp \\\\} match some,exportnamelibonce\\\#namelib \\\\{ define exportnamelibonce\\\\#namelib define exportgathering\\\\#namelib namelib,nameexp,apiexp \\\\} \\\} \\common if 0 \\} macro proc param& \\{ \\} macro endp \\{ \\} postpone \\{ .endmultisection \\} if 1=1 \} } |
|||
11 Aug 2022, 21:14 |
|
Overclick 11 Aug 2022, 23:34
Or this
Code: macro .multisection { match ,skipmultisection \{ end if match any,skipstream ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;for sections \\{ match arg,cuRRentSection \\\{ macro arg ; .code \\\\{ end if define skipstream ;stream on if 1=1 \\\\} macro .\\\#arg string& ; ..code \\\\{ end if match any,skipstream \\\\\{ define skipstream ;stream on if 1=1 string end if define skipstream 'nostream' ;stream off if 0 \\\\\} match ,skipstream \\\\\{ if 1=1 string end if define skipstream ;stream on if 1=1 \\\\\} \\\\} macro arg\\\#once param ; .codeonce \\\\{ match ,arg\\\\#once\\\\#param \\\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\\} match some,arg\\\\#once\\\\#param \\\\\{ end if define skipstream ;stream on define arg\\\\\#once\\\\\#param if 1=1 \\\\\} \\\\} \\\} macro section string ; section \\\{ match arg rest,string \\\\{ arg \\\\} \\\} macro library string& \\\{ match ,skipstream \\\\{ match ,libraryonce \\\\\{ \\\\\} match some,libraryonce \\\\\{ define libraryonce match arg,librarygathering \\\\\\{ library arg \\\\\\} \\\\\} \\\\} \\\} macro import namelib,string& \\\{ match ,skipstream \\\\{ match ,importlibonce\\\\#namelib \\\\\{ \\\\\} match some,importlibonce\\\\#namelib \\\\\{ define importlibonce\\\\\#namelib match arg,importgathering\\\\\#namelib \\\\\\{ import arg \\\\\\} \\\\\} \\\\} \\\} macro export namelib,string& \\\{ match ,skipstream \\\\{ match ,exportlibonce\\\\#namelib \\\\\{ \\\\\} match some,exportlibonce\\\\#namelib \\\\\{ define exportlibonce\\\\\#namelib match arg,exportgathering\\\\\#namelib \\\\\\{ export arg \\\\\\} \\\\\} \\\\} \\\} \\} match ,skipstream ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;for streams \\{ define skipstream 'nostream' ;stream off macro .stream param \\\{ \\\} macro .frame param \\\{ end if if streamcuRRent eq param \\\} macro ..frame param,string& \\\{ end if if streamcuRRent eq param string end if if 0 \\\} macro library string& \\\{ \\\} macro import string& \\\{ \\\} macro export string& \\\{ \\\} macro proc string& \\\{ end if ; macro local args& \\\\{ \\\\} if 0 \\\} macro endp \\\{ end if ; purge local if 0 \\\} macro section string ; section skip \\\{ end if if 0 \\\} match arg,cuRRentSection \\\{ macro arg ; .code skip \\\\{ end if if 0 \\\\} macro .\\\#arg string& \\\\{ \\\\} ; ..code skip macro arg\\\#once param ; .codeonce skip \\\\{ end if if 0 \\\\} \\\} \\} if 0 \} match any,skipmultisection ; * * * * * first run * * * * * \{ define skipmultisection @__file__@ equ __file__ define cuRRentSection macro section allargs ; section 1 skip \\{ end if define skipstream 'nostream' ;stream off match arg rest,allargs \\\{ macro arg ; .code skip \\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\} macro .\\\#arg string& ; ..code skip \\\\{ match ,cuRRentSection \\\\\{ match firstarg somerest,string \\\\\\{ match =library,firstarg \\\\\\\{ string \\\\\\\} match =import,firstarg \\\\\\\{ string \\\\\\\} match =export,firstarg \\\\\\\{ string \\\\\\\} \\\\\\} \\\\\} \\\\} macro arg\\\#once param ; .codeonce skip \\\\{ end if define skipstream 'nostream' ;stream off if 0 \\\\} macro .endmultisection ; extend .endmultisection \\\\{ .endmultisection section \\\\`arg rest cuRRentSection equ arg define skipstream 'nostream' ;stream off if 0 match f, @__file__@ \\\\\{ include f \\\\\} end if purge section purge arg purge .\\\\#arg purge arg\\\\#once purge library purge import purge export \\\\} \\\} if 0 \\} macro .endmultisection \\{ end if purge section purge library purge import purge export purge .stream macro .stream frames \\\{ match ,skipstream \\\\{ streamcuRRent equ frames if 0 match f, @__file__@ \\\\\{ include f \\\\\} end if purge section match arg,cuRRentSection \\\\\{ purge arg purge .\\\\\#arg purge arg\\\\\#once \\\\\} purge .stream purge .frame purge ..frame purge library purge import purge export purge proc purge endp define skipstream \\\\} \\\} \\} macro .stream param \\{ \\} macro .frame param \\{ end if define skipstream 'nostream' ;stream off if 0 \\} macro ..frame param,string& \\{ \\} macro .comment \\{ end if define skipstream 'nostream' ;stream off if 0 \\} define librarygathering macro library [namelib,filelib] \\{ \\common end if \\forward match ,libraryonce\\#namelib \\\{ \\\} match some,libraryonce\\#namelib \\\{ define libraryonce\\\#namelib match some,librarygathering \\\\{ librarygathering equ librarygathering,namelib,filelib \\\\} match ,librarygathering \\\\{ librarygathering equ namelib,filelib \\\\} \\\} \\common if 0 \\} macro import namelib,[nameimp,apiimp] \\{ \\common end if \\forward match ,importonce\\#nameimp \\\{ \\\} match some,importonce\\#nameimp \\\{ define importonce\\\#nameimp match ,importnamelibonce\\\#namelib \\\\{ importgathering\\\\#namelib equ importgathering\\\\#namelib,nameimp,apiimp \\\\} match some,importnamelibonce\\\#namelib \\\\{ define importnamelibonce\\\\#namelib define importgathering\\\\#namelib namelib,nameimp,apiimp \\\\} \\\} \\common if 0 \\} macro export namelib,[nameexp,apiexp] \\{ \\common end if \\forward match ,exportonce\\#namelib\\#nameexp \\\{ \\\} match some,exportonce\\#namelib\\#nameexp \\\{ define exportonce\\\#namelib\\\#nameexp match ,exportnamelibonce\\\#namelib \\\\{ exportgathering\\\\#namelib equ exportgathering\\\\#namelib,nameexp,apiexp \\\\} match some,exportnamelibonce\\\#namelib \\\\{ define exportnamelibonce\\\\#namelib define exportgathering\\\\#namelib namelib,nameexp,apiexp \\\\} \\\} \\common if 0 \\} macro proc string& \\{ match ,skipstream \\\{ match arg,string \\\\{ end if proc arg if 1=1 \\\\} \\\} match some,skipstream \\\{ end if ; macro local args& \\\\{ \\\\} if 0 \\\} \\} macro endp \\{ match ,skipstream \\\{ end if endp if 1=1 \\\} match some,skipstream \\\{ end if ; purge local if 0 \\\} \\} postpone \\{ .endmultisection \\} if 1=1 \} } |
|||
11 Aug 2022, 23:34 |
|
Overclick 12 Aug 2022, 00:55
Your header may looks like this:
Code: match any,runonce { define runonce .code fix .text ;if you really want it ..code fix ..text .codeonce fix .textonce ..codeonce fix ..textonce format PE64 GUI 5.0 include 'WIN64a.INC' include 'Macros.inc' section '.rsrc' resource from 'Project.res' data readable } .multisection section .data data readable writeable section .text code readable executable section .idata import data readable writeable ... your project as usual, just don't be shy to switch sections wherever you like. |
|||
12 Aug 2022, 00:55 |
|
Overclick 02 Sep 2022, 04:20
CHANGELOG:
- Speedup improvement. Now it's extremely fast as fasm1 have to be. - No more errors if you mistakenly use ..idataonce for library/import/export. It will be gathered anyway. - Chained streams allowed (not tested yet but seems all is ok). Means the streams inside some other named frames. - Added .frameonce ..frameonce |
|||
02 Sep 2022, 04:20 |
|
Overclick 18 Sep 2022, 09:47
A little trick to manage global labels:
Code: macro .labelspace current { if 0 label current end if } And now force global label any place/subsection you want. Example: Code: .code proc WindowProc ... cmp edx,WM_TIMER je .wm_timer cmp edx,WM_KILLFOCUS je .wm_killfocus cmp edx,WM_SETFOCUS je .wm_setfocus .wm_timer: ... ret .data Somedata dd ? .code Somelabel: ... ret .labelspace WindowProc .wm_killfocus: ... ret .wm_setfocus: ... ret endp ... .data .labelspace Somelabel .someX dd ? .smoeY dd ? As you see you can switch label space with no limits |
|||
18 Sep 2022, 09:47 |
|
DimonSoft 18 Sep 2022, 20:19
Explanation request. What exactly is the role of if 0 here and how does it play together with label? (I gess I just used the latter too little.)
|
|||
18 Sep 2022, 20:19 |
|
macomics 18 Sep 2022, 21:00
Example of defining labels
Code: format binary use16 org 256 macro global name { if 0 label name end if } Label0: ; Global label .A db 0 ; Label Label0.A byte = 0 .B dw 5 ; Label Label0.B word = 5 Label1: ; Global label .C: nop ; Label Label1.C code Label0.D dd ? ; Global label Label0.D dword = ? (0) .E dq 2.0 ; Label0.D.E double = 2.0 global Label1 ; Skipped by assembler because of if 0, but used to form further label names .F dd 1.0 ; Label1.F float = 1.0 global Label0 fild [.B] ; st0 = Label0.B word = 5 fadd [Label1.F] ; st0 += Label1.F float = 5 + 1.0 fdiv [.D.E] ; st0 /= Label0.D.E double = (5 + 1.0) / 2.0 fistp [.D] ; store dword 3 at Label0.D ; fasm -m 1024 a.asm ; flat assembler version 1.73.30 (1024 kilobytes memory) ; 1 passes, 0.1 seconds, 36 bytes. ; 00000000 00 05 00 90 │ 00 00 00 00 │ 00 00 00 00 │ 00 00 00 40 │ 00 00 80 3F │ DF 06 01 01 ...............@...?.... ; 00000018 D8 06 10 01 │ DC 36 08 01 │ DB 1E 04 01 │ .....6...... |
|||
18 Sep 2022, 21:00 |
|
Furs 19 Sep 2022, 13:03
Yeah it's sort of like namespace in C++.
|
|||
19 Sep 2022, 13:03 |
|
DimonSoft 19 Sep 2022, 16:07
Cool. I’ve never paid attention to which part of ASM performs the local label names conversion. Now I’ll know.
|
|||
19 Sep 2022, 16:07 |
|
Overclick 02 Nov 2022, 09:47
New addon added on first post
|
|||
02 Nov 2022, 09:47 |
|
LWW 02 Nov 2023, 17:44
Overclick
You are a real genius! Удивительно, что столь элементарный функционал, отсутствует в FASM ... |
|||
02 Nov 2023, 17:44 |
|
Goto page Previous 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.