1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-09-16 07:55:00 +00:00
6502bench/SourceGen/SGTestData/Source/2023-non-unique-labels.S
Andy McFadden 68c324bbe8 Label rework, part 4
Update the symbol lookup in EditInstructionOperand, EditDataOperand,
and GotoBox to correctly deal with non-unique labels.

This is a little awkward because we're doing lookups by name on
a non-unique symbol, and must resolve the ambiguity.  In the case of
an instruction operand that refers to an address this is pretty
straightforward.  For partial bytes (LDA #>:foo) or data directives
(.DD1 :foo) we have to take a guess.  We can probably make a more
informed guess than we currently are, e.g. the LDA case could find
the label that minimizes the adjustment, but I don't want to sink a
lot of time into this until I'm sure it'll be useful.

Data operands with multiple regions are something of a challenge,
but I'm not sure specifying a single symbol for multiple locations
is important.

The "goto" box just finds the match that's closest to the selection.
Unlike "find", it always grabs the closest, not the next one forward.
(Not sure if this is useful or confusing.)
2019-11-16 16:44:08 -08:00

107 lines
2.8 KiB
ArmAsm

; Copyright 2019 faddenSoft. All Rights Reserved.
; See the LICENSE.txt file for distribution terms (Apache 2.0).
;
; Assembler: Merlin 32
org $1000
; Test conflict with auto-label.
start lda #$00 ;do not label
:L1000 lda #$01 ;EDIT: set label to :L1000 (dup of auto)
ldx start
ldy :L1000
; Test local/global having same name.
ldx #$02
loop1 dex ;EDIT
bne loop1
ldx #$03
:loop1 dex ;EDIT
bne :loop1
; Test nested loops, and ref to a non-unique local on the other side
; of a global.
global1 nop ;EDIT
ldx #$04
:loop1 ldy #$05 ;EDIT: local, name "loop"
:loop2 dey ;EDIT: local, name "loop"
bne :loop2
dex
bne :loop1
jmp btarg
global2 nop ;EDIT
btarg nop ;EDIT: local, name "loop"
; Test hand-over-hand locals branching forward.
global3 nop ;EDIT
ldx #$06
ldy #$07
dex
beq :fwd1
dey
beq :fwd2
:fwd1 nop ;EDIT
:fwd2 nop ;EDIT
; Test loop with a global in the middle.
global4 nop ;EDIT
ldx #$08
gloop dex ;EDIT: local, name "loop"
global5 nop
bne gloop
nop
; Test symbolic references.
global6 nop
:spin1 jsr :spin2 ;EDIT: local, name "spin1", operand ref to ":spin2"
:spin2 jsr :spin1 ;EDIT: local, name "spin2", operand ref to ":spin1"
nop
:spin3 lda :spin3 ;EDIT: local, name "spin1", operand ref to ":spin1"
beq :spin3 ;EDIT: operand ref to ":spin1"
lda #<:spin1
ldx #<:spin2
lda #>:spin1
ldx #>:spin2
bne :skip
dw :spin1 ;EDIT: local, name "spin1"
dw :spin2 ;EDIT: local, name "spin1" (will be offset)
dw :spin3 ;EDIT: local, name "spin1"
dfb <:spin1 ;EDIT: local, name "spin1" (may need to do as
dfb <:spin2 ;EDIT: local, name "spin1" unique names and then
dfb >:spin1 ;EDIT: local, name "spin1" rename afterward)
dfb >:spin2 ;EDIT: local, name "spin1"
:skip nop ;EDIT: local
; Semi-related: test labels that are nothing but underscores.
global_ nop
ldx #$40
__ dex
bne __
beq ___
___ ldx #$41
:__ dex
bne :__
nop
; Semi-related: test annotations (mostly to confirm that the suffix chars
; aren't appearing in the assembly output)
anno lda #$42 ;EDIT: add '?'
anno1 lda anno
rts
dw anno1 ;EDIT: use table generator