mirror of
https://github.com/irmen/prog8.git
synced 2024-12-23 09:32:43 +00:00
added -varsgolden to put BSS into Golden Ram at $0400
This commit is contained in:
parent
0e0fac8c4b
commit
9b113c0cbb
@ -21,6 +21,7 @@ class CompilationOptions(val output: OutputType,
|
||||
var includeSourcelines: Boolean = false,
|
||||
var experimentalCodegen: Boolean = false,
|
||||
var varsHighBank: Int? = null,
|
||||
var varsGolden: Boolean = false,
|
||||
var splitWordArrays: Boolean = false,
|
||||
var breakpointCpuInstruction: Boolean = false,
|
||||
var outputDir: Path = Path(""),
|
||||
|
@ -16,6 +16,8 @@ interface IMachineDefinition {
|
||||
val PROGRAM_LOAD_ADDRESS : UInt
|
||||
val BSSHIGHRAM_START: UInt
|
||||
val BSSHIGHRAM_END: UInt
|
||||
val BSSGOLDENRAM_START: UInt
|
||||
val BSSGOLDENRAM_END: UInt
|
||||
|
||||
val cpu: CpuType
|
||||
var zeropage: Zeropage
|
||||
|
@ -15,6 +15,8 @@ class AtariMachineDefinition: IMachineDefinition {
|
||||
|
||||
override val BSSHIGHRAM_START = 0u // TODO
|
||||
override val BSSHIGHRAM_END = 0u // TODO
|
||||
override val BSSGOLDENRAM_START = 0u // TODO
|
||||
override val BSSGOLDENRAM_END = 0u // TODO
|
||||
|
||||
override lateinit var zeropage: Zeropage
|
||||
override lateinit var golden: GoldenRam
|
||||
|
@ -17,6 +17,8 @@ class C128MachineDefinition: IMachineDefinition {
|
||||
|
||||
override val BSSHIGHRAM_START = 0u // TODO
|
||||
override val BSSHIGHRAM_END = 0u // TODO
|
||||
override val BSSGOLDENRAM_START = 0u // TODO
|
||||
override val BSSGOLDENRAM_END = 0u // TODO
|
||||
|
||||
override lateinit var zeropage: Zeropage
|
||||
override lateinit var golden: GoldenRam
|
||||
|
@ -18,6 +18,8 @@ class C64MachineDefinition: IMachineDefinition {
|
||||
|
||||
override val BSSHIGHRAM_START = 0xc000u
|
||||
override val BSSHIGHRAM_END = 0xcfffu
|
||||
override val BSSGOLDENRAM_START = 0u
|
||||
override val BSSGOLDENRAM_END = 0u
|
||||
|
||||
override lateinit var zeropage: Zeropage
|
||||
override lateinit var golden: GoldenRam
|
||||
|
@ -17,6 +17,8 @@ class CX16MachineDefinition: IMachineDefinition {
|
||||
|
||||
override val BSSHIGHRAM_START = 0xa000u // hiram bank 1, 8Kb, assumed to be active
|
||||
override val BSSHIGHRAM_END = 0xbfffu // Rom starts at $c000
|
||||
override val BSSGOLDENRAM_START = 0x0400u
|
||||
override val BSSGOLDENRAM_END = 0x07ffu
|
||||
|
||||
override lateinit var zeropage: Zeropage
|
||||
override lateinit var golden: GoldenRam
|
||||
|
@ -17,6 +17,8 @@ class PETMachineDefinition: IMachineDefinition {
|
||||
|
||||
override val BSSHIGHRAM_START = 0u
|
||||
override val BSSHIGHRAM_END = 0u
|
||||
override val BSSGOLDENRAM_START = 0u
|
||||
override val BSSGOLDENRAM_END = 0u
|
||||
|
||||
override lateinit var zeropage: Zeropage
|
||||
override lateinit var golden: GoldenRam
|
||||
|
@ -17,6 +17,8 @@ class VirtualMachineDefinition: IMachineDefinition {
|
||||
|
||||
override val BSSHIGHRAM_START = 0u // not actually used
|
||||
override val BSSHIGHRAM_END = 0u // not actually used
|
||||
override val BSSGOLDENRAM_START = 0u // not actually used
|
||||
override val BSSGOLDENRAM_END = 0u // not actually used
|
||||
override lateinit var zeropage: Zeropage // not actually used
|
||||
override lateinit var golden: GoldenRam // not actually used
|
||||
|
||||
|
@ -173,26 +173,46 @@ internal class ProgramAndVarsGen(
|
||||
}
|
||||
|
||||
private fun footer() {
|
||||
asmgen.out("; bss sections")
|
||||
asmgen.out("PROG8_VARSHIGH_RAMBANK = ${options.varsHighBank ?: 1}")
|
||||
if(options.varsHighBank!=null) {
|
||||
var relocateBssVars = false
|
||||
var relocatedBssStart = 0u
|
||||
var relocatedBssEnd = 0u
|
||||
|
||||
if(options.varsGolden) {
|
||||
if(options.compTarget.machine.BSSGOLDENRAM_START == 0u ||
|
||||
options.compTarget.machine.BSSGOLDENRAM_END == 0u ||
|
||||
options.compTarget.machine.BSSGOLDENRAM_END <= options.compTarget.machine.BSSGOLDENRAM_START) {
|
||||
throw AssemblyError("current compilation target hasn't got the golden ram area properly defined or it is simply not available")
|
||||
}
|
||||
relocateBssVars = true
|
||||
relocatedBssStart = options.compTarget.machine.BSSGOLDENRAM_START
|
||||
relocatedBssEnd = options.compTarget.machine.BSSGOLDENRAM_END
|
||||
}
|
||||
else if(options.varsHighBank!=null) {
|
||||
if(options.compTarget.machine.BSSHIGHRAM_START == 0u ||
|
||||
options.compTarget.machine.BSSHIGHRAM_END == 0u ||
|
||||
options.compTarget.machine.BSSHIGHRAM_END <= options.compTarget.machine.BSSHIGHRAM_START) {
|
||||
throw AssemblyError("current compilation target hasn't got the high ram area properly defined or it is simply not available")
|
||||
}
|
||||
// BSS vars in high ram area, memory() slabs just concatenated at the end of the program.
|
||||
relocateBssVars = true
|
||||
relocatedBssStart = options.compTarget.machine.BSSHIGHRAM_START
|
||||
relocatedBssEnd = options.compTarget.machine.BSSHIGHRAM_END
|
||||
}
|
||||
|
||||
asmgen.out("; bss sections")
|
||||
asmgen.out("PROG8_VARSHIGH_RAMBANK = ${options.varsHighBank ?: 1}")
|
||||
if(relocateBssVars) {
|
||||
// BSS vars in another ram area, memory() slabs just concatenated at the end of the program.
|
||||
if(symboltable.allMemorySlabs.isNotEmpty()) {
|
||||
asmgen.out(" .dsection slabs_BSS")
|
||||
}
|
||||
asmgen.out("prog8_program_end\t; end of program label for progend()")
|
||||
asmgen.out(" * = ${options.compTarget.machine.BSSHIGHRAM_START.toHex()}")
|
||||
asmgen.out(" * = ${relocatedBssStart.toHex()}")
|
||||
asmgen.out("prog8_bss_section_start")
|
||||
asmgen.out(" .dsection BSS")
|
||||
asmgen.out(" .cerror * > ${options.compTarget.machine.BSSHIGHRAM_END.toHex()}, \"too many variables for BSS section\"")
|
||||
asmgen.out(" .cerror * > ${relocatedBssEnd.toHex()}, \"too many variables for BSS section\"")
|
||||
asmgen.out("prog8_bss_section_size = * - prog8_bss_section_start")
|
||||
} else {
|
||||
// BSS vars followed by memory() slabs, concatenated at the end of the program.
|
||||
// just append BSS vars followed by memory() slabs, concatenated at the end of the program.
|
||||
asmgen.out("prog8_bss_section_start")
|
||||
asmgen.out(" .dsection BSS")
|
||||
asmgen.out("prog8_bss_section_size = * - prog8_bss_section_start")
|
||||
|
@ -53,6 +53,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
val compilationTarget by cli.option(ArgType.String, fullName = "target", description = "target output of the compiler (one of '${C64Target.NAME}', '${C128Target.NAME}', '${Cx16Target.NAME}', '${AtariTarget.NAME}', '${PETTarget.NAME}', '${VMTarget.NAME}') (required)")
|
||||
val startVm by cli.option(ArgType.Boolean, fullName = "vm", description = "load and run a .p8ir IR source file in the VM")
|
||||
val watchMode by cli.option(ArgType.Boolean, fullName = "watch", description = "continuous compilation mode (watch for file changes)")
|
||||
val varsGolden by cli.option(ArgType.Boolean, fullName = "varsgolden", description = "put uninitialized variables in 'golden ram' memory area instead of at the end of the program. On the cx16 target this is $0400-07ff. This is unavailable on other systems.")
|
||||
val varsHighBank by cli.option(ArgType.Int, fullName = "varshigh", description = "put uninitialized variables in high memory area instead of at the end of the program. On the cx16 target the value specifies the HiRAM bank to use, on other systems this value is ignored.")
|
||||
val moduleFiles by cli.argument(ArgType.String, fullName = "modules", description = "main module file(s) to compile").multiple(999)
|
||||
|
||||
@ -96,6 +97,17 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
if (varsGolden==true) {
|
||||
if (compilationTarget != Cx16Target.NAME) {
|
||||
System.err.println("Golden Ram is only available on the Commander X16 target.")
|
||||
return false
|
||||
}
|
||||
if (varsHighBank!=null) {
|
||||
System.err.println("Either use varsgolden or varshigh, not both.")
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if(startVm==true) {
|
||||
return runVm(moduleFiles.first())
|
||||
}
|
||||
@ -121,6 +133,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
includeSourcelines == true,
|
||||
experimentalCodegen == true,
|
||||
varsHighBank,
|
||||
varsGolden == true,
|
||||
compilationTarget!!,
|
||||
splitWordArrays == true,
|
||||
breakpointCpuInstruction = false,
|
||||
@ -190,6 +203,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
includeSourcelines == true,
|
||||
experimentalCodegen == true,
|
||||
varsHighBank,
|
||||
varsGolden == true,
|
||||
compilationTarget!!,
|
||||
splitWordArrays == true,
|
||||
breakpointCpuInstruction == true,
|
||||
|
@ -36,6 +36,7 @@ class CompilerArguments(val filepath: Path,
|
||||
val includeSourcelines: Boolean,
|
||||
val experimentalCodegen: Boolean,
|
||||
val varsHighBank: Int?,
|
||||
val varsGolden: Boolean,
|
||||
val compilationTarget: String,
|
||||
val splitWordArrays: Boolean,
|
||||
val breakpointCpuInstruction: Boolean,
|
||||
@ -77,6 +78,7 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
||||
experimentalCodegen = args.experimentalCodegen
|
||||
breakpointCpuInstruction = args.breakpointCpuInstruction
|
||||
varsHighBank = args.varsHighBank
|
||||
varsGolden = args.varsGolden
|
||||
splitWordArrays = args.splitWordArrays
|
||||
outputDir = args.outputDir.normalize()
|
||||
symbolDefs = args.symbolDefs
|
||||
|
@ -33,6 +33,7 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat
|
||||
includeSourcelines = false,
|
||||
experimentalCodegen = false,
|
||||
varsHighBank = null,
|
||||
varsGolden = false,
|
||||
compilationTarget = target.name,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
|
@ -31,6 +31,7 @@ class TestCompilerOptionSourcedirs: FunSpec({
|
||||
includeSourcelines = false,
|
||||
experimentalCodegen = false,
|
||||
varsHighBank = null,
|
||||
varsGolden = false,
|
||||
compilationTarget = Cx16Target.NAME,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
|
@ -30,6 +30,7 @@ internal fun compileFile(
|
||||
includeSourcelines = false,
|
||||
experimentalCodegen = false,
|
||||
varsHighBank = null,
|
||||
varsGolden = false,
|
||||
platform.name,
|
||||
symbolDefs = emptyMap(),
|
||||
outputDir = outputDir,
|
||||
|
@ -215,6 +215,11 @@ One or more .p8 module files
|
||||
(it's called 'BSS' section or Gap at the address mentioned above).
|
||||
Assembling the program will fail if there are too many variables to fit in a single high ram bank.
|
||||
|
||||
``-varsgolden``
|
||||
Like ``-varshigh``, but places the variables in the $0400-$07FF "golden ram" area instead.
|
||||
Because this is in normal system memory, there are no bank switching issues.
|
||||
This mode is only available on the Commander X16.
|
||||
|
||||
|
||||
Module source code files
|
||||
------------------------
|
||||
|
@ -2,7 +2,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- add -varsgold to put BSS vars into golden ram at $0400 (cx16 only) rather than in high memory. Make sure the 64tass .cerror check still works to guard against overflow
|
||||
- add -slabshigh and -slabsgold to also put the memory() slabs into these memory areas (they're now still always part of the prg itself)
|
||||
- add -nowarnunused, or %option ignore_unused (module scope), to suppress all warnings about unused symbols. Useful in libraries.
|
||||
put this in all library code, like %option no_symbol_prefixing, and get rid of the "trick" it uses currently to suppress unused symbol warnings for library modules.
|
||||
|
@ -44,6 +44,7 @@ class RequestParser : Take {
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
varsHighBank = null,
|
||||
varsGolden = false
|
||||
)
|
||||
compileProgram(args)
|
||||
return RsJson(Jsonding())
|
||||
|
Loading…
Reference in New Issue
Block a user