flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Prolem using match to define enum macro |
Author |
|
Tomasz Grysztar 29 Jan 2006, 12:28
Read my last post here: http://board.flatassembler.net/topic.php?t=4638 (the macros that use the "status" variable) for some general information.
However in your case it would be enough to do it this way: Code: macro enum name*,[item] { common local count count=0 forward processed = 0 match nam==val,item \{ nam=val count=val+1 processed = 1 \} if ~ processed item=count count=count+1 end if } or even some a bit tricky one: Code: macro enum name*,[item] { common local count count=0 forward if 1 match nam==val,item \{ nam=val count=val+1 else \} item=count count=count+1 end if } |
|||
29 Jan 2006, 12:28 |
|
chris 30 Jan 2006, 05:45
thanks Tomasz, that's great. now I have a better understanding of fasm's preprocessing from your second example. So the preprocessor operates on text, and we can construct proper commands at preprocessing stage and pass them to assembler. Thanks again.
I think following is the pseudo-preprocessing procedure: is it correct? Code: enum week, Sun=7,Mon=1,Tue after preprocessing becomes: Code: count=0 if 1 Sun=7 count=7+1 else Sun=7=count ; although it is invalid expression, but the assembler skips it count=count+1 end if if 1 Mon=1 count=1+1 else Mon=1=count count=count+1 end if if 1 Tue=count count=count+1 end if |
|||
30 Jan 2006, 05:45 |
|
Tomasz Grysztar 30 Jan 2006, 08:49
Yes, exactly.
Please look also into Macroinstruction FAQ, you can find there a thread with a tool to save the result of preprocessing in a text file - which you could use to validate your predictions. |
|||
30 Jan 2006, 08:49 |
|
chris 30 Jan 2006, 12:20
thanks Tomasz, FASMPRE is the ultimate tool to learn fasm macros.
|
|||
30 Jan 2006, 12:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.