flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar 08 Mar 2022, 18:26
Because fasm 1 has a separate preprocessing stage, you need to use a preprocessor-time variable and REPT directive to make a computed token. The variables defined with "=" are assembly-time, so they are of no use here (preprocessor sees lines like "variable = variable + 1" as just a raw text to pass to the assembly stage).
Your macro should therefore look like this: Code: macro strtbl name, [string] { common local variable variable equ 1 forward rept 1 v:variable \{ label name\#v \} db string, 0 variable equ variable + 1 } strtbl lbl, 'abc', 'dfg', 'eaf' Code: ; variable?0 ;variable?0 equ 1 ;rept 1 v:variable?0 ;{ ; label lbl#v ;} label lbl1 db 'abc',0 ;variable?0 equ 1+1 ;rept 1 v:variable?0 ;{ ; label lbl#v ;} label lbl2 db 'dfg',0 ;variable?0 equ 1+1+1 ;rept 1 v:variable?0 ;{ ; label lbl#v ;} label lbl3 db 'eaf',0 ;variable?0 equ 1+1+1+1 BismuthGlass wrote: Also, on an unrelated note, should I be using FASM1 at all, or should I just use FASMG? I am somewhat aware of the differences, but I can't really find a consensus on what people usually use, and the reasons to use FASM1 over the newer FASMG. Code: macro strtbl name, strings& iterate string, strings label name#% db string, 0 end iterate end macro strtbl lbl, 'abc', 'dfg', 'eaf' |
|||
![]() |
|
BismuthGlass 09 Mar 2022, 10:37
Thanks for the suggestions. I must admit that fasmg looks very scary, but reading through the examples and the manual it has a lot of cool features, and I really like the "everything is a macro and nothing is sacred" philosophy. It seems like the kind of thing I've been looking for, so I'll give it a go.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.