flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Macroinstructions > How to limit scope of a macro to the given procedure body. | 
| Author | 
 | 
| Tomasz Grysztar 10 Aug 2019, 17:39 I assume this is about fasm 1, since fasmg has proper namespaces that work for macros, too.
 You can make macros temporary by restoring them to their previous definition (or undefined state) with PURGE directive. To make this automatic, you can have some framework that would keep track of the macros that need to be PURGEd at the end of procedure. For example something like: Code: macro macroscope { define list@macroscope } macro .macro definition& { local buffer define buffer definition match name tail, buffer: \{ match any, list@macroscope \\{ restore list@macroscope define list@macroscope any,name \\} match , list@macroscope \\{ restore list@macroscope define list@macroscope name \\} \} macro definition } macro endmacroscope { match list, list@macroscope \{ irp name, list \\{ purge name \\} \} restore list@macroscope } Code: macroscope .macro test { display 'macro in scope' } test endmacroscope test ax,bx ; back to normal x86 instruction | |||
|  10 Aug 2019, 17:39 | 
 | 
| MHajduk 10 Aug 2019, 17:49 Tomasz Grysztar wrote: I assume this is about fasm 1, since fasmg has proper namespaces that work for macros, too. Thanks for the reply, this is exactly a solution I wanted.  | |||
|  10 Aug 2019, 17:49 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.