flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 06 Aug 2017, 20:34
If you define the macro twice you can call it up to twice before you get back to the native definition of push.
But you can also define the macro within itself so that you can do infinite recursion (if wanted/needed). |
|||
![]() |
|
shutdownall 06 Aug 2017, 20:59
revolution wrote:
Can you please help how to do that ? |
|||
![]() |
|
revolution 06 Aug 2017, 21:06
Look for the win32ax.inc file in the windows download, and inside there look at the allow_nesting macro for pushd/invoke. It allows infinite nesting of invoke.
|
|||
![]() |
|
Tomasz Grysztar 07 Aug 2017, 13:47
If you tried to use such trick to make this macro recursive, you would end up with infinite recursion (not a good thing, obviously), because you use assembly-time conditionals while macro expansion is done entirely in the preprocessing stage. You'd need to change your IF blocks into MATCHes and then the recursion could be viable (but still would require a trick with macro redefinition).
I really would recommend switching to fasmg for this kind of macros. |
|||
![]() |
|
revolution 07 Aug 2017, 15:42
There is also the trick in fasm1 of using uppercase letters to access the native implementation directly.
Code: macro push ... { Push ... ;invoke the native push directly with an uppercase P } |
|||
![]() |
|
shutdownall 07 Aug 2017, 22:47
Tomasz Grysztar wrote:
Thanks for your info about it. I thought that macros could be called recursively in general but did not thought quite deep about it - it was more or less a question. I could also live with two macros or with double code in one macro, in general try to avoid double code if possible. Code: macro push [char] { if char in <all> push AF BC DE HL IX IY EXX push BC DE HL EXX else if char in <exx> EXX push BC DE HL EXX else push char end if } Switching to fasmg is not an alternative for me right now for this small feature. I can live with double code and bigger macros, not that big problem. And there is not more than 2 stages ("push all" calls "push exx"). Anyway thanks for all comments. ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.