mike.2000 Posted March 1, 2020 Share Posted March 1, 2020 Used Assember: MAC/65 Topic: Usage of multiple macro instances creates multiple labels. This causes wrong branching. Example: This macro gets a random number and branches depending on the value .MACRO RNDMOVE LDA $D20A ; get RDN() CLC ROR A CMP #16 BNE ?STAY ; don't move LDA #1 STA MOVEON JMP ?ZEXIT ?STAY LDA #0 STA MOVEON ?ZEXIT .ENDM The two instances used here : RNDMOVE ; Instance a) . . NOP . RNDMOVE ; instance b) What I couldnt' resolve is this: the assember generates code in a way that it creates a branch that jumps from macro instance a) to macro instance b). The branch BNE ?STAY gets the address of the ?STAY label from macro instance b) instread of a) Looked into the MAC/65 reference manual on this. Tried declaring labels as local with '?'. Also tried the .local directive that led to more assemby Errors: 606F D08F M BNE ?STAY ; don't move }ERROR - 3,BR RANGE 5,UNDEF Workaround: Use just ONE instance and use JSR + at the end of macro an RTS General question I'm asking : Doesn't the concept of macro asselblers support multiple instances. I could imagine that in times where memory was precious wasting of memory by usage of multiple macro instances was no use case. Quote Link to comment Share on other sites More sharing options...
+Ryan Witmer Posted March 1, 2020 Share Posted March 1, 2020 That does seem very strange. I use DASM and don't have any trouble at all with labels inside macros. ; This macro defines subroutines that play sounds in the ; various channels. The sound should have its address ; placed in $fe-$ff. ; Arguments are: ; {1} the AUDC register. ; {2} the AUDF register. ; {3} the sound pointer. ; {4} the timer location. ; {5} the control location. mac start_sound ldy #0 ; 0 index. lda ($fe),y ; Load the AUDC value. sta {1} ; Fill AUDC. sta {5} ; Save AUDC for rests. iny ; Step forward. lda ($fe),y ; Load the AUDF value. sta {2} ; Fill AUDF. iny ; Step forward. lda ($fe),y ; Get the frame count. sta {4} ; Save it. inc $fe ; Move the pointer to the first record. bne .no_carry inc $ff .no_carry lda $fe ; Store the record address. sta {3} lda $ff sta {3} + 1 rts endm This macro in particular is repeated four times in immediate succession without issues. This is a basic function of macro assemblers and I'd be shocked if yours didn't support it. Perhaps there's some special syntax for a "macro-local" label in that assembler. 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.