azure Posted May 20, 2019 Share Posted May 20, 2019 Does anyone know if dasm supports a concatenation operator similar to C preprocessor's ## operator? I'd like to be able to do this: .IDX SET 1 REPEAT 5 .label ## .IDX ; <-------- ; code here .IDX SET .IDX + 1 REPEND I could declare a macro and do the same thing, but sometimes I prefer the code to be inline. MAC INSERT_CODE .label{1} ; code here ENDM ; -------------------- .IDX SET 1 REPEAT 5 INSERT_CODE .IDX .IDX SET .IDX + 1 REPEND Or do you think I should switch to a different assembler or use a C preprocessor? Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 21, 2019 Share Posted May 21, 2019 .label is a temporary label, it goes hand-in-hand with SUBROUTINE: REPEAT 5 SUBROUTINE .label ; code here REPEND With that you'll end up with 5 #.labels, along the lines of: 1.label 2.label etc. Search dasm.txt for SUBROUTINE and you'll find more info like: The other major feature in this assembler is the SUBROUTINE pseudo-op, which logically separates local labels (starting with a dot). This allows you to reuse label names (for example, .1 .fail) rather than think up crazy combinations of the current subroutine to keep it all unique. ... .name -represents a temporary symbol name. Temporary symbols may be reused inside MACROS and between SUBROUTINES, but may not be referenced across macros or across SUBROUTINEs. Quote Link to comment Share on other sites More sharing options...
azure Posted May 21, 2019 Author Share Posted May 21, 2019 (edited) My usage is already inside a subroutine. I was just posting a snippet.I should put the SUBROUTINE keyword inside the REPEAT?I have this structure: Sub SUBROUTINE REPEAT 5 .label ; some code REPEND rts So it should be? Sub SUBROUTINE REPEAT 5 SUBROUTINE .label ; some code REPEND rts Update: It looks like that last one is doing what I wanted. Edited May 21, 2019 by azure 1 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 21, 2019 Share Posted May 21, 2019 I don't know what your goal is, was just pointing out that the <dot><label> format is meant to be used with SUBROUTINE. Without understanding that, you might have tried something like this: jmp .label REPEAT 2 .label nop REPEND which results in this: darrell@darrell-VirtualBox:/media/sf_Atari/kaboom_deluxe$ dasm kaboom_deluxe.asm -f3 -v0 -skaboom_deluxe.sym -lkaboom_deluxe.lst -okaboom_deluxe.bin kaboom_deluxe.asm (2005): error: Label mismatch... --> 10.label fa44 Unrecoverable error(s) in pass, aborting assembly! or something like this: jmp .label REPEAT 2 SUBROUTINE .label nop REPEND which results in this: darrell@darrell-VirtualBox:/media/sf_Atari/kaboom_deluxe$ dasm kaboom_deluxe.asm -f3 -v0 -skaboom_deluxe.sym -lkaboom_deluxe.lst -okaboom_deluxe.bin --- Unresolved Symbol List 10.label 0000 ???? (R ) --- 1 Unresolved Symbol Fatal assembly error: Source is not resolvable. and would get confused as why it didn't work. I put those at the end of Kaboom! Deluxe! to show the errors. By looking at the symbol list kaboom_deluxe.sym, requested via the -s option, we can see dasm converted those instances of .label in the second test to: 10.label 0000 ???? (R ) 11.label fa44 12.label fa45 10.label = before the REPEND 11.label = first REPEND 12.label = second REPEND 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.