1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-03 05:49:48 +00:00
6502bench/SourceGen/SGTestData/Expected/20042-address-changes_64tass.S
Andy McFadden 99cd0d3ac1 Improve handling of C64 PRG header
C64 PRG files are pretty common.  Their salient feature is that they
start with a 16-bit value that is used as the load address.  The
value is commonly generated by the assembler itself, rather than
explicitly added to the source file.

Not all assemblers know what a PRG file is, and some of them handle
it in ways that are difficult to guarantee in SourceGen.  ACME adds
the 16-bit header when the output file name ends in ".prg", cc65
uses a modified config file, 64tass uses a different command-line
option, and Merlin 32 has no idea what they are.

This change adds PRG file detection and handling to the 64tass code
generator.  Doing so required making a few changes to the gen/asm
interfaces, because we now need to have the generator pass additional
flags to the assembler, and sometimes we need code generation to
start somewhere other than offset zero.  Overall the changes were
pretty minor.

The 20042-address-changes test needed a 6502-only variant.  A new test
(20040-address-changes) has been added and given a PRG header.  As
part of this change the 65816 variant was changed to use addresses
in bank 2, which uncovered a code generation bug that this change
also fixes.

The 64tass --long-address flag doesn't appear to be necessary for
files <= 65536 bytes long, so we no longer emit it for those.

(issue #90)
2020-10-17 16:45:13 -07:00

124 lines
2.4 KiB
ArmAsm

.cpu "65816"
* = $021000
.as
.xs
clc
xce
sep #$ff
jsr L21100
jsr L21107
jmp L22000
.logical $021100
L21100 bit L21100 & $ffff
L21103 lda #$11
ldx #$11
L21107 ldy #$11
per L21103
bra L21103
.here
.logical $021100
_L21100_0 bit _L21100_0 & $ffff
lda #$22
_L21105 ldx #$22
ldy #$22
per _L21105
jmp _L21105
.here
.logical $021100
_L21100_1 bit _L21100_1 & $ffff
lda #$33
ldx #$33
_L21107_0 ldy #$33
per _L21107_0
bra _L21107_0
.here
.logical $022000
L22000 bit L22000 & $ffff
beq $022018
bra _L22020
.here
.logical $022020
_L22020 bit _L22020 & $ffff
beq $022029
brl _L22080
_offend nop
.here
.logical $022080
_L22080 bit _L22080 & $ffff
lda _offend & $ffff
jsr _offend
lda $2029
jsr $022029
lda 0+(_L22080 & $ffff)-1
jsr _L22080-1
lda _L22080 & $ffff
jsr _L22080
lda $00
beq _L22100
.byte $ad
.here
.logical $022100
_L22100 nop
nop
jmp _L23000
.here
.logical $022800
.byte $00
.byte $28
.fill 14,$00
.here
.logical $022820
.fill 18,$00
.here
.logical $023000
_L23000 bit _L23000 & $ffff
lda #$44
ldx #$44
ldy #$44
brl _fwd
_ulabel .byte $00
.byte $01
.here
.logical $023100
.byte $02
_fwd bit _fwd & $ffff
lda _ulabel & $ffff
lda 0+(_ulabel & $ffff)+1
lda $300e
lda $300f
lda 0+(_fwd & $ffff)-1
beq _L23182
.byte $ea
.byte $ea
.here
.logical $023180
.byte $00
.byte $01
_L23182 bit _L23182 & $ffff
lda _label1 & $ffff
lda 0+(_label1 & $ffff)+1
lda 0+(_label1 & $ffff)+112
bra _L23200
_label1 .byte $ea
.byte $ea
.here
.logical $023200
_L23200 bit _L23200 & $ffff
.byte $00
.byte $01
.here