mirror of
https://github.com/irmen/prog8.git
synced 2026-04-19 04:17:08 +00:00
fix address check issue when using custom launcher
This commit is contained in:
@@ -34,7 +34,7 @@ interface ICompilationTarget: IStringEncoding, IMemSizer {
|
||||
var zeropage: Zeropage
|
||||
var golden: GoldenRam
|
||||
val libraryPath: Path?
|
||||
val customLauncher: List<String>?
|
||||
val customLauncher: List<String>
|
||||
|
||||
fun initializeMemoryAreas(compilerOptions: CompilationOptions)
|
||||
fun getFloatAsmBytes(num: Number): String
|
||||
|
||||
@@ -11,7 +11,7 @@ class AtariTarget: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by
|
||||
override val name = NAME
|
||||
override val defaultEncoding = Encoding.ATASCII
|
||||
override val libraryPath = null
|
||||
override val customLauncher = null
|
||||
override val customLauncher: List<String> = emptyList()
|
||||
|
||||
companion object {
|
||||
const val NAME = "atari"
|
||||
|
||||
@@ -18,7 +18,7 @@ class C128Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by N
|
||||
override val name = NAME
|
||||
override val defaultEncoding = Encoding.PETSCII
|
||||
override val libraryPath = null
|
||||
override val customLauncher = null
|
||||
override val customLauncher: List<String> = emptyList()
|
||||
|
||||
companion object {
|
||||
const val NAME = "c128"
|
||||
|
||||
@@ -11,7 +11,7 @@ class C64Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by No
|
||||
override val name = NAME
|
||||
override val defaultEncoding = Encoding.PETSCII
|
||||
override val libraryPath = null
|
||||
override val customLauncher = null
|
||||
override val customLauncher: List<String> = emptyList()
|
||||
|
||||
companion object {
|
||||
const val NAME = "c64"
|
||||
|
||||
@@ -26,7 +26,7 @@ class ConfigFileTarget(
|
||||
override val BSSGOLDENRAM_START: UInt,
|
||||
override val BSSGOLDENRAM_END: UInt,
|
||||
override val libraryPath: Path,
|
||||
override val customLauncher: List<String>?,
|
||||
override val customLauncher: List<String>,
|
||||
val ioAddresses: List<UIntRange>,
|
||||
val zpScratchB1: UInt,
|
||||
val zpScratchReg: UInt,
|
||||
@@ -106,7 +106,7 @@ class ConfigFileTarget(
|
||||
val customLauncher =
|
||||
if(customLauncherStr?.isNotBlank()==true)
|
||||
(customLauncherStr+"\n").lines().map { it.trimEnd() }
|
||||
else null
|
||||
else emptyList()
|
||||
|
||||
return ConfigFileTarget(
|
||||
configfile.nameWithoutExtension,
|
||||
|
||||
@@ -18,7 +18,7 @@ class Cx16Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by N
|
||||
override val name = NAME
|
||||
override val defaultEncoding = Encoding.PETSCII
|
||||
override val libraryPath = null
|
||||
override val customLauncher = null
|
||||
override val customLauncher: List<String> = emptyList()
|
||||
|
||||
companion object {
|
||||
const val NAME = "cx16"
|
||||
|
||||
@@ -10,7 +10,7 @@ class Neo6502Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer b
|
||||
override val name = NAME
|
||||
override val defaultEncoding = Encoding.ISO
|
||||
override val libraryPath = null
|
||||
override val customLauncher = null
|
||||
override val customLauncher: List<String> = emptyList()
|
||||
|
||||
companion object {
|
||||
const val NAME = "neo"
|
||||
|
||||
@@ -18,7 +18,7 @@ class PETTarget: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by No
|
||||
override val name = NAME
|
||||
override val defaultEncoding = Encoding.PETSCII
|
||||
override val libraryPath = null
|
||||
override val customLauncher = null
|
||||
override val customLauncher: List<String> = emptyList()
|
||||
|
||||
companion object {
|
||||
const val NAME = "pet32"
|
||||
|
||||
@@ -11,7 +11,7 @@ class VMTarget: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by Nor
|
||||
override val name = NAME
|
||||
override val defaultEncoding = Encoding.ISO
|
||||
override val libraryPath = null
|
||||
override val customLauncher = null
|
||||
override val customLauncher: List<String> = emptyList()
|
||||
|
||||
companion object {
|
||||
const val NAME = "virtual"
|
||||
|
||||
@@ -87,7 +87,7 @@ internal class ProgramAndVarsGen(
|
||||
}
|
||||
}
|
||||
|
||||
if(options.compTarget.customLauncher?.isNotEmpty()==true) {
|
||||
if(options.compTarget.customLauncher.isNotEmpty()) {
|
||||
asmgen.out("; ---- custom launcher assembler program ----")
|
||||
asmgen.out("* = ${options.loadAddress.toHex()}")
|
||||
asmgen.out("prog8_program_start\t; start of program label")
|
||||
|
||||
@@ -265,7 +265,7 @@ internal fun determineProgramLoadAddress(program: Program, options: CompilationO
|
||||
}
|
||||
}
|
||||
|
||||
if(options.output==OutputType.PRG && options.launcher==CbmPrgLauncherType.BASIC) {
|
||||
if(options.output==OutputType.PRG && options.launcher==CbmPrgLauncherType.BASIC && options.compTarget.customLauncher.isEmpty()) {
|
||||
val expected = options.compTarget.PROGRAM_LOAD_ADDRESS
|
||||
if(loadAddress!=expected) {
|
||||
errors.err("BASIC output must have load address ${expected.toHex()}", specifiedAddress?.second ?: program.toplevelModule.position)
|
||||
|
||||
@@ -45,14 +45,19 @@ programs for new machines or existing ones it doesn't yet know about.
|
||||
The configuration file should be a "properties" file (Java's ubiquitous configuration file format), which is basically a text file containing "key=value" lines.
|
||||
The contents of the file is pretty extensive and it's easier to just look at some examples that are already included:
|
||||
`target configuration examples <https://github.com/irmen/prog8/tree/master/examples/customtarget/>`_ .
|
||||
The filename base part (the part before any suffix) of the target configuration file will be taken as the name of the compilation target.
|
||||
If it matches one of the existing built-in compilation targets, the internal library files for that target will also be searched,
|
||||
if the user supplied library location doesn't contain a replacement library file for anything that might get imported.
|
||||
The path you need to provide for the ``library`` variable can be relative (to the current working directory where you launch the compiler from)
|
||||
and you can use a tilde ``~`` in it like in a shell path, to refer to a user's home directory.
|
||||
Note that library modules not unique to a specific compilation target (for example, `buffers`, `sorting` or `strings`) will
|
||||
be picked up from the internal library files just fine as was always the case. You can still provide custom versions of them
|
||||
in your own library folder ofcourse, like you already could with using the ``-srcdirs`` compiler flag.
|
||||
|
||||
Most of the things discussed in the :ref:`portingguide` can and must be configured properly in the target configuration file.
|
||||
You also need to create some essential ``syslib`` library module for the configured target if its name does not match
|
||||
one of the built in targets. This is because the compiler won't have a built in library that can be used this time.
|
||||
The customtarget examples also show how to build the essentials.
|
||||
The filename base part (the part before any suffix) of the target configuration file will be taken as the name of the compilation target.
|
||||
If it matches one of the existing built-in compilation targets, the internal library files for that target will still be used,
|
||||
if the user supplied library location doesn't contain a replacement library file for anything that might get imported.
|
||||
|
||||
The target configuration file also allows you to override the entire launcher assembly fragment that the compiler
|
||||
usually puts at the start of the program (immediately after the setting of the program counter/load address and
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- Make some of the target machine config externally configurable (for 1 new target, the existing ones should stay as they are for the time being)
|
||||
- Make neo
|
||||
|
||||
- add paypal donation button as well?
|
||||
- announce prog8 on the 6502.org site?
|
||||
|
||||
@@ -5,7 +5,7 @@ program = CBMPRG
|
||||
encoding = petscii
|
||||
load_address = $0801
|
||||
memtop = $9f00
|
||||
bss_highram_start = $a00
|
||||
bss_highram_start = $a000
|
||||
bss_highram_end = $bfff
|
||||
bss_goldenram_start = $0400
|
||||
bss_goldenram_end = $07ff
|
||||
|
||||
Reference in New Issue
Block a user