RevEng Posted April 28, 2020 Share Posted April 28, 2020 I've added support for Dynamic Labels/Symbols to Dasm, on a testing branch. One common use-case for this is you can create tables programmatically, in a REPEAT loop, and the labels can contain the loop index value. If anybody is interested in putting it through the paces in their assembly code (to make sure I haven't borked something) or even giving the new feature a spin, it would be appreciated. The binaries can be downloaded from the github snapshot builds. The relevant excerpt from the updated dasm.txt follows... Quote Dynamic Symbol/Labels When used in a symbol name, the "," operator indicates one or more arguments that follow should be evaluated, and the resulting values should concatenated to the label, to create a "dynamic" symbol name. symbol,ARG1[,ARG2,...] String literals can be specified with quotes around the string text. Expression operators can also be used, but due to label parsing constraints, they should not contain spacing. The concat-eval "," operator also works on the expression side of EQU/SET pseudo-ops, so dynamic labels can be used with opcodes. A quick and overly trivial example... ; generate multiplication tables with dynamic labels processor 6502 ORG $1000 IDX SET 1 REPEAT 3 Mult_,IDX,"_times" VAL SET 0 REPEAT 5 .byte VAL VAL SET VAL + IDX REPEND IDX SET IDX + 1 REPEND The resulting list is in a spoiler, to avoid making this a monster post... ------- FILE scratch.asm LEVEL 1 PASS 1 1 0000 processor 6502 2 1000 ORG $1000 3 1000 4 1000 IDX SET 1 5 1000 REPEAT 3 6 1000 Mult_1_times 7 1000 VAL SET 0 8 1000 REPEAT 5 9 1000 00 .byte.b VAL 10 1000 VAL SET VAL + IDX 8 1000 REPEND 9 1001 01 .byte.b VAL 10 1001 VAL SET VAL + IDX 8 1001 REPEND 9 1002 02 .byte.b VAL 10 1002 VAL SET VAL + IDX 8 1002 REPEND 9 1003 03 .byte.b VAL 10 1003 VAL SET VAL + IDX 8 1003 REPEND 9 1004 04 .byte.b VAL 10 1004 VAL SET VAL + IDX 11 1005 REPEND 12 1005 IDX SET IDX + 1 5 1005 REPEND 6 1005 Mult_2_times 7 1005 VAL SET 0 8 1005 REPEAT 5 9 1005 00 .byte.b VAL 10 1005 VAL SET VAL + IDX 8 1005 REPEND 9 1006 02 .byte.b VAL 10 1006 VAL SET VAL + IDX 8 1006 REPEND 9 1007 04 .byte.b VAL 10 1007 VAL SET VAL + IDX 8 1007 REPEND 9 1008 06 .byte.b VAL 10 1008 VAL SET VAL + IDX 8 1008 REPEND 9 1009 08 .byte.b VAL 10 1009 VAL SET VAL + IDX 11 100a REPEND 12 100a IDX SET IDX + 1 5 100a REPEND 6 100a Mult_3_times 7 100a VAL SET 0 8 100a REPEAT 5 9 100a 00 .byte.b VAL 10 100a VAL SET VAL + IDX 8 100a REPEND 9 100b 03 .byte.b VAL 10 100b VAL SET VAL + IDX 8 100b REPEND 9 100c 06 .byte.b VAL 10 100c VAL SET VAL + IDX 8 100c REPEND 9 100d 09 .byte.b VAL 10 100d VAL SET VAL + IDX 8 100d REPEND 9 100e 0c .byte.b VAL 10 100e VAL SET VAL + IDX 11 100f REPEND 12 100f IDX SET IDX + 1 13 100f REPEND For small and simple programs, this probably doesn't have much place. But for larger data driven designs, it can take away label kludge and/or repetition of macros. Assuming there isn't widespread revolt over the feature, it will be incorporated into the main dasm branch sooner or later. I just figured it would be good to air it here first, get any feedback, perform any fixes needed. Link to comment Share on other sites More sharing options...
zilog_z80a Posted September 29, 2020 Share Posted September 29, 2020 (edited) hi, thank you so much for your work @RevEng question: this dynamic labels can be used to pass a dynamic argument to a macro? cheers. Edited September 29, 2020 by zilog_z80a Link to comment Share on other sites More sharing options...
RevEng Posted September 29, 2020 Author Share Posted September 29, 2020 Sure, you're welcome. You can't use dynamic labels directly as a macro argument, but nothing stopping you from doing something like... mymacroarg SET ARG,INDEX,"VAL" ; mymacroarg is now whatever ARG#VAL is mymacro mymacroarg 1 Link to comment Share on other sites More sharing options...
zilog_z80a Posted September 29, 2020 Share Posted September 29, 2020 10 minutes ago, RevEng said: Sure, you're welcome. You can't use dynamic labels directly as a macro argument, but nothing stopping you from doing something like... mymacroarg SET ARG,INDEX,"VAL" ; mymacroarg is now whatever ARG#VAL is mymacro mymacroarg ty @RevEng, i will try this in some days. TABLE_WITH_ZEROS MYMACRO_WITH_SEVERAL_TABLES_WITH_GRAPHICS DYNAMIC_ARGUMENT TABLE_WITH_ZEROS 1 Link to comment Share on other sites More sharing options...
Recommended Posts