flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Detect last macro invocation |
Author |
|
revolution 14 Jun 2010, 04:21
I nice trick. Can you show some example code using this?
|
|||
14 Jun 2010, 04:21 |
|
baldr 14 Jun 2010, 10:06
revolution,
I'm going to use this in data import wrapper macros that will allow to have several import definition blocks throughout source and will actually declare them as a whole at the end of last data import / end data. They're still WIP (imatch, I miss you so much… ). Another possible application for this is auto-inlined function if I'll manage to convince FASM that the following code can be resolved without scope error: Code: display "Pass: ", '0'+%p, 13, 10 macro display_cond cond { irps symbol, cond \{ display \`symbol, ' ' \} match line, __line__ \{ display "@", \`line, 13, 10 \} } usage_counter = 0 ; the following is expanded «inline» macro more = 1 usage_counter = usage_counter+1 if ~defined more?0 ; false display_cond ~defined more?0 usage_count = usage_counter ; this shouldn't take effect; if I comment this line, everything is OK end if if usage_count>1 ; this forward reference should be valid display_cond usage_count>1 if ~defined more?0 display_cond ~defined more?0 push ..over?1 ..func: mov eax, 'Hi!'; func body ret ..over?1: else display_cond defined more?0 call ..func end if else mov eax, 'Hi!'; func body end if ; the following is expanded «inline» macro again more?0 = 1 usage_counter = usage_counter+1 if ~defined more?2 ; true display_cond ~defined more?2 usage_count = usage_counter ; this one should be used end if if usage_count>1 display_cond usage_count>1 if ~defined more?2 display_cond ~defined more?2 push ..over?3 ..func: mov eax, 'Hi!'; func body ret ..over?3: else display_cond defined more?2 call ..func end if else mov eax, 'Hi!'; func body end if |
|||
14 Jun 2010, 10:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.