dasm-assembler / dasm

Macro assembler with support for several 8-bit microprocessors
https://dasm-assembler.github.io/
GNU General Public License v2.0
215 stars 40 forks source link

Dynamic labels are not working in an expression #134

Closed Settis closed 1 year ago

Settis commented 1 year ago

I can construct dynamic label when I define it:

    processor 6502
    org $200

BAR SET 1
FOO_,BAR
    JMP FOO_1

But I can't construct it for using in jump:

    processor 6502
    org $200

BAR SET 1
FOO_1
    JMP FOO_,BAR

It fails with error:

--- Unresolved Symbol List
FOO_                     0000 ????         (R )
--- 1 Unresolved Symbol 
Settis commented 1 year ago

I see that the comma is already used as an argument separator. So I can't do it because of the dasm syntaxis. Is it still possible to add dynamic label assembling for arguments? The label parts could be separated by the other separator.

neilsf commented 1 year ago

The documentation reads:

The concat-eval “,” operator also works on the expression side of EQU/SET directives, so dynamic labels can be used with opcodes.

However, the following code returns a weird result for me, or I'm misunderstanding something.

  PROCESSOR 6502

  ORG $1000
lab_1
  nop

num   SET 1
addr  SET "lab_",num

  jmp addr

I'm expecting addr to be assigned $1000, but in fact it takes a seemingly random value:

  1  0000                         PROCESSOR 6502
  2  0000 ????
  3  1000                         ORG   $1000
  4  1000                  lab_1
  5  1000              ea             nop
  6  1001
  7  1001                  num        SET   1
  8  1001                  addr       SET   "lab_",num
  9  1001
 10  1001              4c 5f 62           jmp   addr
Settis commented 1 year ago

It seems that you can use:

addr  SET lab_,num

Good for me.