flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > coalesce - a data migration scheme for fasmg |
Author |
|
bitRAKE 16 Mar 2021, 03:04
Of course, we extend with other macros for convenient data defining:
Code: struc(name) const_utf8_array quoted& CONST8 equ label name:8 iterate S,quoted CONST1 equ name#% db S,0 CONST8 equ dq name#% end iterate CONST8 equ dq 0 end struc _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
16 Mar 2021, 03:04 |
|
bitRAKE 16 Mar 2021, 10:04
There are a lot of tricks to force the scheme to work:
Code: macro FatalAppExit quoted& repeat 1,x:`quoted CONST2. equ ?x du quoted,0 xor ecx,ecx lea edx,[?x.] call [FatalAppExitW] end repeat end macro _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
16 Mar 2021, 10:04 |
|
Tomasz Grysztar 16 Mar 2021, 10:56
When making symbolic links, DEFINE might be safer choice than EQU. But perhaps it does not matter here, since your framework seems to require a strict ordering - IRPV cannot forward-reference, so it needs to have everything defined before the place where it is put into.
bitRAKE wrote: There are a lot of tricks to force the scheme to work: Code: macro FatalAppExit quoted& local x CONST2. equ x du quoted,0 xor ecx,ecx lea edx,[x] call [FatalAppExitW] end macro |
|||
16 Mar 2021, 10:56 |
|
bitRAKE 16 Mar 2021, 13:10
Quote: IRPV cannot forward-reference, so it needs to have everything defined before the place where it is put into. Tried the local namespace but didn't realize my "CONST2" naming was the problem at that point, and didn't back-track once I did solve that. Thought I was taking the difficult route. Thank you. Should be able to refactor most things to a couple namespaces. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
16 Mar 2021, 13:10 |
|
bitRAKE 16 Mar 2021, 14:15
IRPV also works with DEFINE - I don't know why I thought it didn't.
Now if it worked with macros I'd be shocked. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
16 Mar 2021, 14:15 |
|
Tomasz Grysztar 16 Mar 2021, 14:38
bitRAKE wrote:
To make one, you could use the same pattern that works for fasm 1 (and I actually used the same method in the Mach-O formatter for fasmg, search for "macroBuilder" there). However, CALM allows to do the trick in a less resource-hungry fashion. This instruction assembles all lines collected in variable named MacroBuilder: Code: define MacroBuilder calminstruction MacroBuilder.instantiate local stack, line reverse: take stack, MacroBuilder jyes reverse process: take line, stack jno done assemble line jump process done: end calminstruction restore MacroBuilder Code: postpone define MacroBuilder macro DATA define MacroBuilder align __MAX_DATA_ALIGNMENT__ irpv DN,__DATA irpv D,DN define MacroBuilder D end irpv end irpv define MacroBuilder end macro MacroBuilder.instantiate define MacroBuilder macro CONST define MacroBuilder align __MAX_DATA_ALIGNMENT__ irpv CN,__CONST irpv C,CN define MacroBuilder C end irpv end irpv define MacroBuilder end macro MacroBuilder.instantiate define MacroBuilder macro BSS define MacroBuilder align __MAX_DATA_ALIGNMENT__ irpv BN,__BSS irpv B,BN define MacroBuilder B end irpv end irpv define MacroBuilder end macro MacroBuilder.instantiate end postpone Code: ; DATA, CONST, BSS are put in place with the following code, respectively: DATA CONST BSS |
|||
16 Mar 2021, 14:38 |
|
bitRAKE 16 Mar 2021, 15:29
When I use EQU the IRPV only evaluates for non-empty items - no matter how many alignment groups I have. The dummy no-op macro was created to force each alignment group being examined, and it doesn't work like I thought fasmg skips over them. Whereas because DEFINE is symbolic it loops over empty symbols - even if they are blank. I'm not sure how it works, but EQU seems optimal unless I need delayed evaluation.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
16 Mar 2021, 15:29 |
|
Tomasz Grysztar 16 Mar 2021, 18:13
I only meant specific places where you use EQU to form symbolic links, like:
Code: __DATA equ DATA#k __CONST equ CONST#k __BSS equ BSS#k EDIT: In fact, this is what may be causing the behavior that you describe. When you have DATA1 defined only once (with default "___" value), it becomes forward-referable and then: Code: __DATA equ DATA#1 Code: __DATA equ ___ Code: define __DATA ___ |
|||
16 Mar 2021, 18:13 |
|
bitRAKE 17 Mar 2021, 01:28
Any alignment groups I don't use are factored out early. Even for the case of empty macro results - which is a wonderfully scalable thing. fasmg is amazing.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
17 Mar 2021, 01:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.