mirror of
https://github.com/irmen/prog8.git
synced 2025-01-10 20:30:23 +00:00
RAW output now also properly initializes variables
This commit is contained in:
parent
04cb684fd4
commit
3f630ab1b0
@ -89,6 +89,12 @@ internal class ProgramAndVarsGen(
|
||||
OutputType.RAW -> {
|
||||
asmgen.out("; ---- raw assembler program ----")
|
||||
asmgen.out("* = ${options.loadAddress.toHex()}")
|
||||
asmgen.out(" cld")
|
||||
asmgen.out(" tsx ; save stackpointer for sys.exit()")
|
||||
asmgen.out(" stx prog8_lib.orig_stackpointer")
|
||||
if(!options.noSysInit)
|
||||
asmgen.out(" jsr sys.init_system")
|
||||
asmgen.out(" jsr sys.init_system_phase2")
|
||||
}
|
||||
OutputType.PRG -> {
|
||||
when(options.launcher) {
|
||||
@ -111,6 +117,7 @@ internal class ProgramAndVarsGen(
|
||||
asmgen.out(" jsr sys.init_system_phase2")
|
||||
}
|
||||
CbmPrgLauncherType.NONE -> {
|
||||
// this is the same as RAW
|
||||
asmgen.out("; ---- program without basic sys call ----")
|
||||
asmgen.out("* = ${options.loadAddress.toHex()}")
|
||||
asmgen.out(" cld")
|
||||
@ -575,7 +582,7 @@ internal class ProgramAndVarsGen(
|
||||
asmgen.out("")
|
||||
val (varsNoInit, varsWithInit) = variables.partition { it.uninitialized }
|
||||
if(varsNoInit.isNotEmpty()) {
|
||||
asmgen.out("; non-zeropage variables without initialization value")
|
||||
asmgen.out("; non-zeropage variables")
|
||||
asmgen.out(" .section BSS")
|
||||
varsNoInit.sortedWith(compareBy<StStaticVariable> { it.name }.thenBy { it.dt }).forEach {
|
||||
uninitializedVariable2asm(it)
|
||||
@ -584,7 +591,7 @@ internal class ProgramAndVarsGen(
|
||||
}
|
||||
|
||||
if(varsWithInit.isNotEmpty()) {
|
||||
asmgen.out("; non-zeropage variables")
|
||||
asmgen.out("; non-zeropage variables with init value")
|
||||
val (stringvars, othervars) = varsWithInit.sortedBy { it.name }.partition { it.dt == DataType.STR }
|
||||
stringvars.forEach {
|
||||
outputStringvar(
|
||||
|
@ -248,7 +248,7 @@ internal fun determineProgramLoadAddress(program: Program, options: CompilationO
|
||||
}
|
||||
|
||||
if(loadAddress==null) {
|
||||
errors.err("load address must be specified with these output options", program.toplevelModule.position)
|
||||
errors.err("load address must be specified with the specifid output/launcher options", program.toplevelModule.position)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
Shouldn't RAW output target have some initialization logic too? Does it even clear the variables/bss etc?
|
||||
|
||||
Doc improvements: some short overview for people coming from other programming languages like C:
|
||||
tell something about prog8 not having function overloading, max 16 bit (u)word integer as native type (and floats sometimes),
|
||||
static variable allocations, no dynamic memory allocation in the language itself (although possible via user written libraries),
|
||||
|
@ -1,6 +1,9 @@
|
||||
%import textio
|
||||
%zeropage dontuse
|
||||
%option no_sysinit
|
||||
|
||||
%output raw
|
||||
%launcher none
|
||||
%address $2000
|
||||
|
||||
main {
|
||||
uword @shared variable
|
||||
|
Loading…
x
Reference in New Issue
Block a user