mirror of
https://github.com/irmen/prog8.git
synced 2024-12-26 14:29:35 +00:00
added -slabshigh N and -slabsgolden for memory() slabs
This commit is contained in:
parent
9b113c0cbb
commit
8ae435549d
@ -22,6 +22,8 @@ class CompilationOptions(val output: OutputType,
|
||||
var experimentalCodegen: Boolean = false,
|
||||
var varsHighBank: Int? = null,
|
||||
var varsGolden: Boolean = false,
|
||||
var slabsHighBank: Int? = null,
|
||||
var slabsGolden: Boolean = false,
|
||||
var splitWordArrays: Boolean = false,
|
||||
var breakpointCpuInstruction: Boolean = false,
|
||||
var outputDir: Path = Path(""),
|
||||
|
@ -174,6 +174,7 @@ internal class ProgramAndVarsGen(
|
||||
|
||||
private fun footer() {
|
||||
var relocateBssVars = false
|
||||
var relocateBssSlabs = false
|
||||
var relocatedBssStart = 0u
|
||||
var relocatedBssEnd = 0u
|
||||
|
||||
@ -193,33 +194,61 @@ internal class ProgramAndVarsGen(
|
||||
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")
|
||||
}
|
||||
if(options.slabsHighBank!=null && options.varsHighBank!=options.slabsHighBank)
|
||||
throw AssemblyError("slabs and vars high bank must be the same")
|
||||
relocateBssVars = true
|
||||
relocatedBssStart = options.compTarget.machine.BSSHIGHRAM_START
|
||||
relocatedBssEnd = options.compTarget.machine.BSSHIGHRAM_END
|
||||
}
|
||||
|
||||
if(options.slabsGolden) {
|
||||
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")
|
||||
}
|
||||
relocateBssSlabs = true
|
||||
relocatedBssStart = options.compTarget.machine.BSSGOLDENRAM_START
|
||||
relocatedBssEnd = options.compTarget.machine.BSSGOLDENRAM_END
|
||||
}
|
||||
else if(options.slabsHighBank!=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")
|
||||
}
|
||||
if(options.varsHighBank!=null && options.varsHighBank!=options.slabsHighBank)
|
||||
throw AssemblyError("slabs and vars high bank must be the same")
|
||||
relocateBssSlabs = 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()) {
|
||||
if(!relocateBssSlabs)
|
||||
asmgen.out(" .dsection slabs_BSS")
|
||||
}
|
||||
asmgen.out("prog8_program_end\t; end of program label for progend()")
|
||||
asmgen.out(" * = ${relocatedBssStart.toHex()}")
|
||||
asmgen.out("prog8_bss_section_start")
|
||||
asmgen.out(" .dsection BSS")
|
||||
asmgen.out(" .cerror * > ${relocatedBssEnd.toHex()}, \"too many variables for BSS section\"")
|
||||
if(relocateBssSlabs)
|
||||
asmgen.out(" .dsection slabs_BSS")
|
||||
asmgen.out(" .cerror * > ${relocatedBssEnd.toHex()}, \"too many variables/data for BSS section\"")
|
||||
asmgen.out("prog8_bss_section_size = * - prog8_bss_section_start")
|
||||
} else {
|
||||
// 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")
|
||||
if(symboltable.allMemorySlabs.isNotEmpty()) {
|
||||
if(!relocateBssSlabs)
|
||||
asmgen.out(" .dsection slabs_BSS")
|
||||
}
|
||||
asmgen.out("prog8_program_end\t; end of program label for progend()")
|
||||
if(relocateBssSlabs) {
|
||||
asmgen.out(" * = ${relocatedBssStart.toHex()}")
|
||||
asmgen.out(" .dsection slabs_BSS")
|
||||
asmgen.out(" .cerror * > ${relocatedBssEnd.toHex()}, \"too many data for slabs_BSS section\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,8 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
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 slabsGolden by cli.option(ArgType.Boolean, fullName = "slabsgolden", description = "put memory() slabs 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 slabsHighBank by cli.option(ArgType.Int, fullName = "slabshigh", description = "put memory() slabs 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)
|
||||
|
||||
try {
|
||||
@ -102,11 +104,26 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
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.")
|
||||
if (varsHighBank!=null || slabsHighBank!=null) {
|
||||
System.err.println("Either use varsgolden or varshigh (and slabsgolden or slabshigh), not both or mixed.")
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (slabsGolden==true) {
|
||||
if (compilationTarget != Cx16Target.NAME) {
|
||||
System.err.println("Golden Ram is only available on the Commander X16 target.")
|
||||
return false
|
||||
}
|
||||
if (varsHighBank!=null || slabsHighBank!=null) {
|
||||
System.err.println("Either use golden or high ram, not both.")
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if(varsHighBank!=null && slabsHighBank!=null && varsHighBank!=slabsHighBank) {
|
||||
System.err.println("Vars and slabs high memory bank must be the same.")
|
||||
return false
|
||||
}
|
||||
|
||||
if(startVm==true) {
|
||||
return runVm(moduleFiles.first())
|
||||
@ -134,6 +151,8 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
experimentalCodegen == true,
|
||||
varsHighBank,
|
||||
varsGolden == true,
|
||||
slabsHighBank,
|
||||
slabsGolden == true,
|
||||
compilationTarget!!,
|
||||
splitWordArrays == true,
|
||||
breakpointCpuInstruction = false,
|
||||
@ -204,6 +223,8 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
experimentalCodegen == true,
|
||||
varsHighBank,
|
||||
varsGolden == true,
|
||||
slabsHighBank,
|
||||
slabsGolden == true,
|
||||
compilationTarget!!,
|
||||
splitWordArrays == true,
|
||||
breakpointCpuInstruction == true,
|
||||
|
@ -37,6 +37,8 @@ class CompilerArguments(val filepath: Path,
|
||||
val experimentalCodegen: Boolean,
|
||||
val varsHighBank: Int?,
|
||||
val varsGolden: Boolean,
|
||||
val slabsHighBank: Int?,
|
||||
val slabsGolden: Boolean,
|
||||
val compilationTarget: String,
|
||||
val splitWordArrays: Boolean,
|
||||
val breakpointCpuInstruction: Boolean,
|
||||
@ -79,6 +81,8 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
||||
breakpointCpuInstruction = args.breakpointCpuInstruction
|
||||
varsHighBank = args.varsHighBank
|
||||
varsGolden = args.varsGolden
|
||||
slabsHighBank = args.slabsHighBank
|
||||
slabsGolden = args.slabsGolden
|
||||
splitWordArrays = args.splitWordArrays
|
||||
outputDir = args.outputDir.normalize()
|
||||
symbolDefs = args.symbolDefs
|
||||
|
@ -34,6 +34,8 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat
|
||||
experimentalCodegen = false,
|
||||
varsHighBank = null,
|
||||
varsGolden = false,
|
||||
slabsHighBank = null,
|
||||
slabsGolden = false,
|
||||
compilationTarget = target.name,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
|
@ -32,6 +32,8 @@ class TestCompilerOptionSourcedirs: FunSpec({
|
||||
experimentalCodegen = false,
|
||||
varsHighBank = null,
|
||||
varsGolden = false,
|
||||
slabsHighBank = null,
|
||||
slabsGolden = false,
|
||||
compilationTarget = Cx16Target.NAME,
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
|
@ -31,6 +31,8 @@ internal fun compileFile(
|
||||
experimentalCodegen = false,
|
||||
varsHighBank = null,
|
||||
varsGolden = false,
|
||||
slabsHighBank = null,
|
||||
slabsGolden = false,
|
||||
platform.name,
|
||||
symbolDefs = emptyMap(),
|
||||
outputDir = outputDir,
|
||||
|
@ -2,7 +2,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- 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.
|
||||
|
||||
|
@ -1,24 +1,14 @@
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
%zeropage dontuse
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
ubyte[] barr = [1,2,3,4,5,6,7,8,9]
|
||||
uword[] warr = [111,222,333,444,555,666,777,888,999]
|
||||
uword pointer = &barr
|
||||
byte index = 2
|
||||
uword empty
|
||||
uword block = memory("block", 500, 0)
|
||||
|
||||
txt.print_ub(barr[7])
|
||||
txt.print_uwhex(&empty, true)
|
||||
txt.nl()
|
||||
txt.print_ub(barr[-2])
|
||||
txt.nl()
|
||||
txt.print_ub(pointer[7])
|
||||
txt.nl()
|
||||
txt.print_ub(pointer[index])
|
||||
txt.nl()
|
||||
txt.print_uw(warr[7])
|
||||
txt.nl()
|
||||
txt.print_uw(warr[-2])
|
||||
txt.print_uwhex(block, true)
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,9 @@ class RequestParser : Take {
|
||||
splitWordArrays = false,
|
||||
breakpointCpuInstruction = false,
|
||||
varsHighBank = null,
|
||||
varsGolden = false
|
||||
varsGolden = false,
|
||||
slabsHighBank = null,
|
||||
slabsGolden = false
|
||||
)
|
||||
compileProgram(args)
|
||||
return RsJson(Jsonding())
|
||||
|
Loading…
Reference in New Issue
Block a user