Windless Posted January 11, 2020 Share Posted January 11, 2020 hi, I am generating some code with a macro, and I would like this macro to generated global unique labels. e.g., when called twice, the macro would output : MyMacroLabel1_1 lda #$00 MyMacroLabel2_1 ldx #$00 MyMacroLabel3_1 ldy #$00 MyMacroLabel1_2 lda #$00 MyMacroLabel2_2 ldx #$00 MyMacroLabel3_2 ldy #$00 Is it possible to do so with DASM ? I thought I would use something like : IFNCONST CallIndex CallIndex set 0 ELSE CallIndex set CallIndex + 1 ENDIF ["MyMacroLabel1_" + CallIndex] lda #$00 But after one hour of trying, I didn't manage to have this working. Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted January 12, 2020 Share Posted January 12, 2020 I've tried many ways to do this, too. No luck. My approach was to try passing constructs to macros and hope they were evaulated instead of used verbatim. No luck. There appears to be no way to generate a label based on a "variable" containing the text for that label. I hope to be proven wrong - but this one has me stumped. Quote Link to comment Share on other sites More sharing options...
Windless Posted January 12, 2020 Author Share Posted January 12, 2020 (edited) Thanks. For now, since each call to my macro will generate the same "local global" labels, I did like this : MAC GENCODE .genStart SET . nop nop _label1 SET . - .genStart lda #1 nop _label2 SET . - .genStart lda #2 nop ENDM then I use the relative labels this way : generated1 GENCODE generated2 GENCODE jmp generated1 + _label1 jmp generated1 + _label2 jmp generated2 + _label1 jmp generated2 + _label2 This works because relative labels have the same value each time in my macro. Else I would need to use absolute values and capture each one : GENCODE label1_1 set _label1 label2_1 set _label2 GENCODE label1_2 set _label1 label2_2 set _label2 But that still doesn't allow for a varying number of generated labels. Edited January 12, 2020 by Windless Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.