nurpax / c64jasm

C64 6502 assembler in TypeScript
51 stars 14 forks source link

Forward references to variables #88

Open micheldebree opened 1 year ago

micheldebree commented 1 year ago

A nice-to-have really. I use self-modifying code a lot, like in this contrived example:

!let color = loop + 1

lda #0
sta color

loop:
  lda #0
  sta $d020
  inc color
  jmp loop

I would prefer to write it like this:

lda #0
sta color

loop:
!let color = * + 1
  lda #0
  sta $d020
  inc color
  jmp loop

But that doesn't work because I am referencing color before it is defined.

But only if it doesn't cost much, the above is also workable.