1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-07-14 05:28:55 +00:00
6502bench/SourceGen/SGTestData/Expected/2023-non-unique-labels_cc65.S
Andy McFadden d3670c48e8 Label rework, part 6
Correct handling of local variables.  We now correctly uniquify them
with regard to non-unique labels.  Because local vars can effectively
have global scope we mostly want to treat them as global, but they're
uniquified relative to other globals very late in the process, so we
can't just throw them in the symbol table and be done.  Fortunately
local variables exist in a separate namespace, so we just need to
uniquify the variables relative to the post-localization symbol table.
In other words, we take the symbol table, apply the label map, and
rename any variable that clashes.

This also fixes an older problem where we weren't masking the
leading '_' on variable labels when generating 64tass output.

The code list now makes non-unique labels obvious, but you can't tell
the difference between unique global and unique local.  What's more,
the default type value in Edit Label is now adjusted to Global for
unique locals that were auto-generated.  To make it a bit easier to
figure out what's what, the Info panel now has a "label type" line
that reports the type.

The 2023-non-unique-labels test had some additional tests added to
exercise conflicts with local variables.  The 2019-local-variables
test output changed slightly because the de-duplicated variable
naming convention was simplified.
2019-11-18 13:36:53 -08:00

113 lines
2.1 KiB
ArmAsm

.setcpu "6502"
; .segment "SEG000"
.org $1000
L1000: lda #$00
@L1000: lda #$01
ldx L1000
ldy @L1000
ldx #$02
loop1: dex
bne loop1
ldx #$03
@loop1: dex
bne @loop1
global1: nop
ldx #$04
@loop: ldy #$05
@loop1: dey
bne @loop1
dex
bne @loop
jmp loop
global2: .byte $ea
loop: nop
global3: nop
ldx #$06
ldy #$07
dex
beq @fwd1
dey
beq @fwd2
@fwd1: nop
@fwd2: nop
global4: nop
ldx #$08
loop2: dex
global5: nop
bne loop2
nop
global6: nop
@spin1: jsr @spin2
@spin2: jsr @spin1
nop
@spin11: lda @spin1+7
beq @spin11
lda #<@spin1
ldx #<@spin2
lda #>@spin1
ldx #>@spin2
bne @skip
.word @spin1
.word @spin2
.word @spin11
.byte <@spin1
.byte <@spin2
.byte >@spin1
.byte >@spin2
@skip: nop
global_: nop
_global: ldx #$40
__: dex
bne __
beq ___
___: ldx #$41
@__: dex
bne @__
nop
anno: lda #$42
T106B: lda anno
clc
bcc @skip
.word T106B
@skip: nop
JMP1: lda JMP1
JMP0: lda JMP0
JMP11: lda JMP11
@JMP: lda @JMP
@JMP0: lda @JMP0
@JMP1: lda @JMP1
@JMP2: lda @JMP2
jmp1: lda jmp1
Jmp1: lda Jmp1
BRA: lda BRA
brl: lda brl
LDAL: .byte $af
.byte $95
.byte $10
.byte $00
nop
plain_1 .set $11
_under1 .set $12
__dub1 .set $13
lda plain_1
lda _under1
lda __dub1
@plain: lda @plain
plain: lda plain
global8: dex
bne plain
X_under1: lda X_under1
@X__dub1: lda @X__dub1
_under1 .set $22
lda plain_1
lda _under1
rts