Jump to content

Open Club  ·  61 members

DASM
IGNORED

Auto-increment label values?


Karl G

Recommended Posts

I couldn't find anything in the documentation that matched, but is there a way to have label values auto increment? E.g. you set the value of the first label, then just supply the names of the subsequent labels, and these will be given incrementing values in order. I get how I could do it via dynamic labels, but is there a way with arbitrary label names?

Link to comment
Share on other sites

There's no auto-incrementing label names or values. I think the only way you can manage this with names is dynamic labels, and for values by using SET with whatever incrementing you need. I'm not sure exactly what you mean by arbitrary, since you can name dynamic labels as you like.

 

Here's a example of creating a series of incrementing dynamic labels, which take on different values. I took this from the 7800basic zonememory.asm file and simplified a bit. (for the sake of having a clear example not cluttered up by various 7800basic memory allocation options)

 

DLINDEX SET 0
  REPEAT WZONECOUNT
TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART)
; create symbols in the form "ZONE#ADDRESS" that point to the memory for each zone
ZONE,DLINDEX,"ADDRESS" = TMPMEMADDRESS
DLINDEX SET DLINDEX + 1
  REPEND

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Have you tried doing what is done for RAM? 

 

    ; .U means uninitialized, does not end up in ROM
        SEG.U
        
    ; value for first label
        ORG 1000

Label1:    ds 1
Label2:    ds 1
Label3:    ds 1
Label4:    ds 1
...

 

The labels would be assigned 1000, 1001, 1002, 1003, etc

 

  • Like 2
Link to comment
Share on other sites

  • Recently Browsing   0 members

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