flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Nested macros |
Author |
|
revolution 16 Dec 2007, 06:23
I don't see where in your description you need nesting of macros.
But anyway, have a look at the file 'win32ax.inc' in the fasm windows package. It shows one way to do macro nesting. Also, I posted this code some time back, it also uses nesting: Code: macro nest_includeonce{ macro includeonce path,[instr]\{\common file@include equ path match head path tail,files@included\\{file@include equ\\} match head path,files@included\\{file@include equ\\} match file,file@include\\{ files@included equ files@included path nest_includeonce include file purge includeonce irp i,instr\\\{i\\\} \\} \} }nest_includeonce files@included equ x 'macros.inc' |
|||
16 Dec 2007, 06:23 |
|
mwh 16 Dec 2007, 10:01
revolution wrote: I don't see where in your description you need nesting of macros. Ok, how would you do it without nesting then? |
|||
16 Dec 2007, 10:01 |
|
revolution 16 Dec 2007, 10:10
mwh wrote: Ok, how would you do it without nesting then? Code: START_INLINE macro mac_name { macro mac_name \{ ;beginning code goes here } END_INLINE macro { ;ending code goes here \} } INLINE equ START_INLINE foo ...assembly code specific to foo... END_INLINE INLINE foo |
|||
16 Dec 2007, 10:10 |
|
mwh 16 Dec 2007, 10:50
I'm not sure I understand, this doesn't seem like it produces the two results I'm looking for.
Also isn't this nesting the macro mac_name inside the macro START_INLINE? |
|||
16 Dec 2007, 10:50 |
|
revolution 16 Dec 2007, 11:35
mwh wrote: I'm not sure I understand, this doesn't seem like it produces the two results I'm looking for. mwh wrote: Also isn't this nesting the macro mac_name inside the macro START_INLINE? |
|||
16 Dec 2007, 11:35 |
|
mwh 16 Dec 2007, 11:51
Thanks for persevering with me:
The first result I'm looking for is that when the following appears in my source: -------------------------------------- START_INLINE foo ...assembly code specific to foo... END_INLINE -------------------------------------- it would be substituted with: -------------------------------------------------- ...some assemby code produced by START_INLINE... ...assembly code specific to foo... ...some assembly code produced by END_INLINE... ------------------------------------------------- The second result is when the following appears in my source: -------------- INLINE foo -------------- it would be substituted with only: -------------------------------------- ...assembly code specific to foo... -------------------------------------- |
|||
16 Dec 2007, 11:51 |
|
revolution 16 Dec 2007, 12:06
Try this code
Code: START_INLINE macro mac_name { ;beginning code goes here START_INLINE@name equ mac_name macro mac_name \{ } END_INLINE macro { \}START_INLINE@name restore START_INLINE@name ;ending code goes here } INLINE equ |
|||
16 Dec 2007, 12:06 |
|
mwh 16 Dec 2007, 12:18
START_INLINE macro mac_name {
;beginning code goes here START_INLINE@name equ mac_name macro mac_name \{ } <== doesn't compile, gives me an error here |
|||
16 Dec 2007, 12:18 |
|
revolution 16 Dec 2007, 12:42
Okay, since you want it to be given directly
Code: macro START_INLINE mac_name { ;beginning code goes here START_INLINE@name equ mac_name macro mac_name \{ } macro END_INLINE { match x,START_INLINE@name\{x\} restore START_INLINE@name ;ending code goes here } END_INLINE fix }END_INLINE INLINE fix |
|||
16 Dec 2007, 12:42 |
|
vid 16 Dec 2007, 16:17
but note that using macrofeatures inside START_INLINE - END_INLINE block is tricky, you must escape symbols just like in nested macro.
|
|||
16 Dec 2007, 16:17 |
|
mwh 17 Dec 2007, 13:05
revolution wrote: Okay, since you want it to be given directly Huh? Thanks for the code, I'll try it out. |
|||
17 Dec 2007, 13:05 |
|
mwh 17 Dec 2007, 13:09
vid wrote: but note that using macrofeatures inside START_INLINE - END_INLINE block is tricky, you must escape symbols just like in nested macro. Perhaps it might be cleaner for me to use an external preprocessor rather than FASM's built-in macroinstructions for this. |
|||
17 Dec 2007, 13:09 |
|
vid 17 Dec 2007, 22:51
Quote: Perhaps it might be cleaner for me to use an external preprocessor rather than FASM's built-in macroinstructions for this. Perhaps yes. If what you want can't be done with FASM macros using some sane way, using external tool is best option. Do you know some scripting language? |
|||
17 Dec 2007, 22:51 |
|
mwh 18 Dec 2007, 02:00
vid wrote:
I usually use AWK for simple filters. Should work fine for this I think. Cheers |
|||
18 Dec 2007, 02:00 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.