Jump to content
IGNORED

dasm question


azure

Recommended Posts

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?

Link to comment
Share on other sites

.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.
Link to comment
Share on other sites

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 by azure
  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...