mirror of
https://github.com/fadden/6502bench.git
synced 2025-02-07 14:31:00 +00:00
Fix ACME code gen "overflow"
ACME has a "real" PC and a "pseudo" PC. The "real" PC determines the initial position in a 64KB buffer used to hold assembler output. If the amount of code generated runs off the end, the assembler fails with "produced too much code". The source code generator in SourceGen was outputting a "real" PC for the first address range and "psuedo" PCs for any address ranges that followed. This produced nice results for code with a single range, but caused problems for multi-range sources if the initial range was high in memory and a later range was lower in memory. While the assembler isn't actually generating more than 64KB of code, ACME's buffer management was detecting an overflow. Now, if a source file has multiple address ranges, we set the "real" PC to $0000 and use a "pseudo" PC for all ranges. Output for projects with a single address range is unmodified.
This commit is contained in:
parent
100d2ffc13
commit
4981c3cdbb
@ -523,19 +523,28 @@ namespace SourceGen.AsmGen {
|
||||
|
||||
// IGenerator
|
||||
public void OutputOrgDirective(int offset, int address) {
|
||||
// For the first one, set the "real" PC. For all subsequent directives, set the
|
||||
// "pseudo" PC.
|
||||
// If there's only one address range, just set the "real" PC. If there's more
|
||||
// than one we can run out of space if the source file has a chunk in high memory
|
||||
// followed by a chunk in low memory, because the "real" PC determines when the
|
||||
// 64KB bank is overrun.
|
||||
if (offset == 0) {
|
||||
OutputLine("*", "=", SourceFormatter.FormatHexValue(address, 4), string.Empty);
|
||||
} else {
|
||||
if (mInPseudoPcBlock) {
|
||||
// close previous block
|
||||
OutputLine(string.Empty, CLOSE_PSEUDOPC, string.Empty, string.Empty);
|
||||
// first one
|
||||
if (Project.AddrMap.Count == 1) {
|
||||
OutputLine("*", "=", SourceFormatter.FormatHexValue(address, 4), string.Empty);
|
||||
return;
|
||||
} else {
|
||||
// set the real PC to address zero to ensure we get a full 64KB
|
||||
OutputLine("*", "=", SourceFormatter.FormatHexValue(0, 4), string.Empty);
|
||||
}
|
||||
OutputLine(string.Empty, sDataOpNames.OrgDirective,
|
||||
SourceFormatter.FormatHexValue(address, 4) + " {", string.Empty);
|
||||
mInPseudoPcBlock = true;
|
||||
}
|
||||
|
||||
if (mInPseudoPcBlock) {
|
||||
// close previous block
|
||||
OutputLine(string.Empty, CLOSE_PSEUDOPC, string.Empty, string.Empty);
|
||||
}
|
||||
OutputLine(string.Empty, sDataOpNames.OrgDirective,
|
||||
SourceFormatter.FormatHexValue(address, 4) + " {", string.Empty);
|
||||
mInPseudoPcBlock = true;
|
||||
}
|
||||
|
||||
// IGenerator
|
||||
|
@ -1,7 +1,8 @@
|
||||
;Project file was edited to get all big-endian data types, and to have an
|
||||
;incorrect .junk alignment directive.
|
||||
!cpu 6502
|
||||
* = $1000
|
||||
* = $0000
|
||||
!pseudopc $1000 {
|
||||
bit L1448
|
||||
jsr L14A8
|
||||
nop
|
||||
@ -60,6 +61,7 @@ LABEL !hex 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff
|
||||
!fill 2,$dd ;incorrect alignment
|
||||
!align 255,0,$00
|
||||
!fill 8,$82
|
||||
} ;!pseudopc
|
||||
!pseudopc $1408 {
|
||||
!fill 8,$82 ;note no-op .ORG
|
||||
!fill 8,$83
|
||||
|
@ -1,5 +1,6 @@
|
||||
;ACME can't handle 65816 code that lives outside bank zero
|
||||
* = $012345
|
||||
* = $0000
|
||||
!pseudopc $012345 {
|
||||
!hex 18fbe230a9cda9dda90da9eda9fea92da9ffa929a910a9e9a90fa945a923a901
|
||||
!hex f4edfef44523f40100f45634f41200f4edfef44523f40100f45634f41200a5ce
|
||||
!hex adce00afce0000adecfeafecfe00adeefeafeefe00ad4623af462301ad4423af
|
||||
@ -22,3 +23,4 @@
|
||||
!hex 656172206f6e20746865206669727374206c696e652e20205468652071756963
|
||||
!hex 6b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920
|
||||
!hex 646f67732ea97aa959a934c230a97b56a95a34a9341260
|
||||
} ;!pseudopc
|
||||
|
@ -1,5 +1,6 @@
|
||||
!cpu 65816
|
||||
* = $1000
|
||||
* = $0000
|
||||
!pseudopc $1000 {
|
||||
!as
|
||||
!rs
|
||||
clc
|
||||
@ -9,6 +10,7 @@
|
||||
jsr L1107
|
||||
jmp L2000
|
||||
|
||||
} ;!pseudopc
|
||||
!pseudopc $1100 {
|
||||
L1100 bit L1100
|
||||
L1103 lda #$11
|
||||
|
@ -1,6 +1,8 @@
|
||||
;ACME can't handle 65816 code that lives outside bank zero
|
||||
* = $1000
|
||||
* = $0000
|
||||
!pseudopc $1000 {
|
||||
!hex 18fbe2304c00002c0000a500a503d0ba30b862b5ff7006826d00000102a51482
|
||||
!hex a5ff2c80005c0000442cc0ff823d00cf000044af000044ad0000a50030f562b2
|
||||
!hex ffd0b082a9ff1700170044cfc0ff44f005303c8239005c0020002c0020f41700
|
||||
!hex f44400d003dc1300ea201220201520200f202256341260
|
||||
} ;!pseudopc
|
||||
|
@ -1,5 +1,6 @@
|
||||
!cpu 65816
|
||||
* = $1000
|
||||
* = $0000
|
||||
!pseudopc $1000 {
|
||||
!as
|
||||
!rs
|
||||
load11 lda #$11
|
||||
@ -48,6 +49,7 @@ load11 lda #$11
|
||||
|
||||
!byte $80
|
||||
@dat81 !byte $81
|
||||
} ;!pseudopc
|
||||
!pseudopc $2000 {
|
||||
@L2000 !byte $82
|
||||
!byte $83
|
||||
|
@ -1,6 +1,7 @@
|
||||
;6502bench SourceGen v1.1.0-dev1
|
||||
!cpu 65816
|
||||
* = $1000
|
||||
* = $0000
|
||||
!pseudopc $1000 {
|
||||
!as
|
||||
!rs
|
||||
sec
|
||||
@ -286,6 +287,7 @@ L11FC cmp+2 L0086,x
|
||||
sbc+2 L0086,x
|
||||
inc+2 L0086,x
|
||||
sbc+3 L0089,x
|
||||
} ;!pseudopc
|
||||
!pseudopc $0080 {
|
||||
L0080 bit+1 @L0082
|
||||
@L0082 bit+1 @L0082
|
||||
|
@ -5,7 +5,8 @@ CONST_ZERO = $f0 ;project const
|
||||
PROJ_ZERO = $00 ;project addr
|
||||
PROJ_ONE = $01 ;project addr
|
||||
|
||||
* = $1000
|
||||
* = $0000
|
||||
!pseudopc $1000 {
|
||||
!as
|
||||
!rs
|
||||
ldy PROJ_ZERO
|
||||
@ -187,6 +188,7 @@ L103C lda #$fe
|
||||
jsr DPCODE
|
||||
rts
|
||||
|
||||
} ;!pseudopc
|
||||
!pseudopc $0080 {
|
||||
DPCODE nop
|
||||
lda+1 DPCODE
|
||||
|
@ -3,7 +3,8 @@ PrintInlineL1String = $011000
|
||||
PrintInlineL2String = $012000
|
||||
PrintInlineDciString = $013000
|
||||
|
||||
* = $1000
|
||||
* = $0000
|
||||
!pseudopc $1000 {
|
||||
!as
|
||||
!rs
|
||||
clc
|
||||
@ -92,6 +93,7 @@ Next1 jsr L10BA
|
||||
|
||||
!fill 300,$00
|
||||
|
||||
} ;!pseudopc
|
||||
!pseudopc $1800 {
|
||||
L1800 jsr PrintInlineNullString
|
||||
per $8778
|
||||
|
@ -1,8 +1,10 @@
|
||||
!cpu 6502
|
||||
* = $2000
|
||||
* = $0000
|
||||
!pseudopc $2000 {
|
||||
jmp L2100
|
||||
|
||||
!text "hello, " ;string should be split by no-op addr change
|
||||
} ;!pseudopc
|
||||
!pseudopc $200a {
|
||||
!text "world"
|
||||
!byte $80
|
||||
|
Loading…
x
Reference in New Issue
Block a user