1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-07-06 00:28:58 +00:00
6502bench/SourceGen/SGTestData/Expected/20052-branches-and-banks_cc65.S
Andy McFadden fdd2bcf847 Fix some 65816 code generation issues
Two basic problems:

(1) cc65, being a one-pass assembler, can't tell if a forward-referenced
label is 16-bit or 24-bit.  If the operand is potentially ambiguous,
such as "LDA label", we need to add an operand width disambiguator.
(The existing tests managed to only do backward references.)

(2) 64tass wants the labels on JMP/JSR absolute operands to have 24-bit
values that match the current program bank.  This is the opposite of
cc65, which requires 16-bit values.  We need to distinguish PBR vs.
DBR instructions (i.e. "LDA abs" vs. "JMP abs") and handle them
differently when formatting for "Common".

Merlin32 doesn't care, and ACME doesn't work at all, so neither of
those needed updating.

The 20052-branches-and-banks test was expanded to cover the problematic
cases.
2020-07-01 17:59:12 -07:00

115 lines
2.3 KiB
ArmAsm

.setcpu "65816"
zero = $00
longsym = $123456
; .segment "SEG000"
.org $1000
.a8
.i8
clc
xce
sep #$30
jml L440000
lodat: .byte $00
.byte $01
.byte $02
; .segment "SEG001"
.org $440000
L440000: cmp L440000
L440004: lda L440000
lda a:L440000 & $ffff
lda zero
bmi L440004
.byte $62,$b2,$ff
.byte $d0,$b0
.byte $82,$a9,$ff
dat44: .word dat44 & $ffff
.faraddr dat44
; .segment "SEG002"
.org $44ffc0
L44FFC0: cmp L44FFC0
high44: beq @L44FFCB
.byte $30,$3c
.byte $82,$39,$00
@L44FFCB: jml @L2000
; .segment "SEG003"
.org $2000
@L2000: bit @L2000
pea dat44 & $ffff
pea dat44 >> 16
bne skip
jml [lodat]
skip: nop
jsr j2
j2: jsr j2+3
jsr j2-3
jsl longsym
jml bank54
; .segment "SEG004"
.org $543210
bank54: cmp bank54
bra L54321C
backchk: nop
nop
L543218: rts
backval: .faraddr backchk
L54321C: lda backchk
lda f:fwdchk
lda $543216
lda $54327d
lda backchk & $ffff +1
lda backchk & $ffff -1
lda fwdchk & $ffff +1
lda fwdval & $ffff +2
nop
jsr backchk & $ffff
jsr backchk & $ffff +1
jsr L543218 & $ffff
jsr fwdchk & $ffff
jsr fwdchk & $ffff +1
jsr L54327F & $ffff
nop
ldx #$00
jsr (backval & $ffff,x)
jsr (fwdval & $ffff,x)
jsr @L54326E & $ffff
jsr @L543271 & $ffff
jsr @L543268 & $ffff
jsr @L54326B & $ffff
jsr @L543274 & $ffff
jsr @L543277 & $ffff
bra L543280
@L543268: jmp (backval & $ffff,x)
@L54326B: jmp (fwdval & $ffff,x)
@L54326E: jmp ($1008)
@L543271: jmp ($1008)
@L543274: jml [$1008]
@L543277: jml [$1008]
fwdval: .faraddr fwdchk
fwdchk: nop
nop
L54327F: rts
L543280: jsr skip
rtl