flat assembler
Message board for the users of flat assembler.
Index
> Programming Language Design > Reinterpretable arguments to macros in fasmg |
Author |
|
MaoKo 14 Dec 2023, 19:51
Seem very promising. This feature would save me from some headache .
|
|||
14 Dec 2023, 19:51 |
|
Tomasz Grysztar 17 Dec 2023, 21:06
Combining it with another relatively recent addition, "??" interceptor, I made what I believe is the simplest and cleanest macro builder yet:
Code: calminstruction ?? &line& match >>line?, line jyes commit match >line?, line jyes collect assemble line exit local stack collect: take stack, line exit commit: take line, stack jyes commit assembly: assemble line take , line take line, line jyes assembly end calminstruction Code: BITS = 64 > struct POINT if BITS = 64 > x dq ? else > x dd ? end if if BITS = 64 > y dq ? else > y dd ? end if >> ends > struct OCTAGON repeat 8 > vertex#% POINT end repeat >> ends Also by adding a couple of commands after the "assemble line" it's possible to view what definition is generated: Code: assemble line
stringify line
display line
display 10 Code: struct POINT x dq ? y dq ? ends struct OCTAGON vertex#1 POINT vertex#2 POINT vertex#3 POINT vertex#4 POINT vertex#5 POINT vertex#6 POINT vertex#7 POINT vertex#8 POINT ends |
|||
17 Dec 2023, 21:06 |
|
fabbel 18 Dec 2023, 09:52
Hi Tomasz. nice indeed !
Wouldn't that be good to include in the standard FASMG distribution package ? What do u think ? |
|||
18 Dec 2023, 09:52 |
|
Tomasz Grysztar 18 Dec 2023, 11:51
Yes, something like this (especially when I get a good feedback) deserves at least inclusion in the utility package, and perhaps it could also go as an example in auxiliary documentation if I decide to write a section about the new tricks.
Another door this new feature opens: it allows to make custom directives to define symbolic variables carrying contextless text. Playing with this, I have another example, this time implementing a fasm-like FIX directive, making a global replacement of a symbol with some other text (in a non-interfering way thanks to the new "&line&" idiom): Code: define fix? fix? calminstruction (name) fix? &value& arrange name, fix.name publish name, value end calminstruction calminstruction ?! &line& local any match any =fix? any?, line jyes skip transform line, fix skip: assemble line end calminstruction |
|||
18 Dec 2023, 11:51 |
|
fabbel 18 Dec 2023, 13:04
thumbs up !
|
|||
18 Dec 2023, 13:04 |
|
Tomasz Grysztar 18 Dec 2023, 21:19
One more thing: this also makes it easier to emulate some of the fasm 1 syntax more closely. This specific snippet used to be quite problematic in fasmg, because context was fixed for the entire line:
Code: foo dd .size .size = $ - foo Code: struc (name) dd? &values& label name: 4 emit 4: values end struc |
|||
18 Dec 2023, 21:19 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.