mirror of
https://github.com/irmen/prog8.git
synced 2024-10-19 07:23:56 +00:00
even better machinetarget independence
This commit is contained in:
parent
78bdbde3ae
commit
3ce692bb10
@ -231,4 +231,36 @@ romsub $FFF3 = IOBASE() -> uword @ XY ; read base addr
|
|||||||
|
|
||||||
; ---- end of C64 kernal routines ----
|
; ---- end of C64 kernal routines ----
|
||||||
|
|
||||||
|
asmsub init_system() {
|
||||||
|
; Initializes the machine to a sane starting state.
|
||||||
|
; Called automatically by the loader program logic.
|
||||||
|
; This means that the BASIC, KERNAL and CHARGEN ROMs are banked in,
|
||||||
|
; the VIC, SID and CIA chips are reset, screen is cleared, and the default IRQ is set.
|
||||||
|
; Also a different color scheme is chosen to identify ourselves a little.
|
||||||
|
; Uppercase charset is activated, and all three registers set to 0, status flags cleared.
|
||||||
|
%asm {{
|
||||||
|
sei
|
||||||
|
cld
|
||||||
|
lda #%00101111
|
||||||
|
sta $00
|
||||||
|
lda #%00100111
|
||||||
|
sta $01
|
||||||
|
jsr c64.IOINIT
|
||||||
|
jsr c64.RESTOR
|
||||||
|
jsr c64.CINT
|
||||||
|
lda #6
|
||||||
|
sta c64.EXTCOL
|
||||||
|
lda #7
|
||||||
|
sta c64.COLOR
|
||||||
|
lda #0
|
||||||
|
sta c64.BGCOL0
|
||||||
|
tax
|
||||||
|
tay
|
||||||
|
clc
|
||||||
|
clv
|
||||||
|
cli
|
||||||
|
rts
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,38 +6,6 @@
|
|||||||
; indent format: TABS, size=8
|
; indent format: TABS, size=8
|
||||||
|
|
||||||
|
|
||||||
; TODO move this one to c64lib:
|
|
||||||
init_system .proc
|
|
||||||
; -- initializes the machine to a sane starting state
|
|
||||||
; Called automatically by the loader program logic.
|
|
||||||
; This means that the BASIC, KERNAL and CHARGEN ROMs are banked in,
|
|
||||||
; the VIC, SID and CIA chips are reset, screen is cleared, and the default IRQ is set.
|
|
||||||
; Also a different color scheme is chosen to identify ourselves a little.
|
|
||||||
; Uppercase charset is activated, and all three registers set to 0, status flags cleared.
|
|
||||||
sei
|
|
||||||
cld
|
|
||||||
lda #%00101111
|
|
||||||
sta $00
|
|
||||||
lda #%00100111
|
|
||||||
sta $01
|
|
||||||
jsr c64.IOINIT
|
|
||||||
jsr c64.RESTOR
|
|
||||||
jsr c64.CINT
|
|
||||||
lda #6
|
|
||||||
sta c64.EXTCOL
|
|
||||||
lda #7
|
|
||||||
sta c64.COLOR
|
|
||||||
lda #0
|
|
||||||
sta c64.BGCOL0
|
|
||||||
tax
|
|
||||||
tay
|
|
||||||
clc
|
|
||||||
clv
|
|
||||||
cli
|
|
||||||
rts
|
|
||||||
.pend
|
|
||||||
|
|
||||||
|
|
||||||
read_byte_from_address_on_stack .proc
|
read_byte_from_address_on_stack .proc
|
||||||
; -- read the byte from the memory address on the top of the stack, return in A (stack remains unchanged)
|
; -- read the byte from the memory address on the top of the stack, return in A (stack remains unchanged)
|
||||||
lda P8ESTACK_LO+1,x
|
lda P8ESTACK_LO+1,x
|
||||||
|
@ -21,6 +21,7 @@ interface IMachineDefinition {
|
|||||||
|
|
||||||
val opcodeNames: Set<String>
|
val opcodeNames: Set<String>
|
||||||
var zeropage: Zeropage
|
var zeropage: Zeropage
|
||||||
|
val initSystemProcname: String
|
||||||
|
|
||||||
fun initializeZeropage(compilerOptions: CompilationOptions)
|
fun initializeZeropage(compilerOptions: CompilationOptions)
|
||||||
fun getFloat(num: Number): IMachineFloat
|
fun getFloat(num: Number): IMachineFloat
|
||||||
|
@ -26,6 +26,8 @@ internal object C64MachineDefinition: IMachineDefinition {
|
|||||||
override val ESTACK_HI = 0xcf00 // $ce00-$ceff inclusive
|
override val ESTACK_HI = 0xcf00 // $ce00-$ceff inclusive
|
||||||
|
|
||||||
override lateinit var zeropage: Zeropage
|
override lateinit var zeropage: Zeropage
|
||||||
|
override val initSystemProcname = "c64.init_system"
|
||||||
|
|
||||||
override fun getFloat(num: Number) = Mflpt5.fromNumber(num)
|
override fun getFloat(num: Number) = Mflpt5.fromNumber(num)
|
||||||
|
|
||||||
override fun getFloatRomConst(number: Double): String? {
|
override fun getFloatRomConst(number: Double): String? {
|
||||||
|
@ -12,7 +12,6 @@ import prog8.compiler.target.CompilationTarget
|
|||||||
import prog8.compiler.target.IAssemblyGenerator
|
import prog8.compiler.target.IAssemblyGenerator
|
||||||
import prog8.compiler.target.IAssemblyProgram
|
import prog8.compiler.target.IAssemblyProgram
|
||||||
import prog8.compiler.target.c64.AssemblyProgram
|
import prog8.compiler.target.c64.AssemblyProgram
|
||||||
import prog8.compiler.target.c64.C64MachineDefinition
|
|
||||||
import prog8.compiler.target.c64.Petscii
|
import prog8.compiler.target.c64.Petscii
|
||||||
import prog8.compiler.target.c64.codegen.assignment.AsmAssignSource
|
import prog8.compiler.target.c64.codegen.assignment.AsmAssignSource
|
||||||
import prog8.compiler.target.c64.codegen.assignment.AsmAssignTarget
|
import prog8.compiler.target.c64.codegen.assignment.AsmAssignTarget
|
||||||
@ -22,7 +21,6 @@ import prog8.compiler.target.c64.codegen.assignment.TargetStorageKind
|
|||||||
import prog8.compiler.target.generatedLabelPrefix
|
import prog8.compiler.target.generatedLabelPrefix
|
||||||
import prog8.functions.BuiltinFunctions
|
import prog8.functions.BuiltinFunctions
|
||||||
import prog8.functions.FSignature
|
import prog8.functions.FSignature
|
||||||
import java.math.RoundingMode
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
@ -93,6 +91,7 @@ internal class AsmGen(private val program: Program,
|
|||||||
|
|
||||||
// the global prog8 variables needed
|
// the global prog8 variables needed
|
||||||
val zp = CompilationTarget.machine.zeropage
|
val zp = CompilationTarget.machine.zeropage
|
||||||
|
val initproc = CompilationTarget.machine.initSystemProcname
|
||||||
out("P8ZP_SCRATCH_B1 = ${zp.SCRATCH_B1}")
|
out("P8ZP_SCRATCH_B1 = ${zp.SCRATCH_B1}")
|
||||||
out("P8ZP_SCRATCH_REG = ${zp.SCRATCH_REG}")
|
out("P8ZP_SCRATCH_REG = ${zp.SCRATCH_REG}")
|
||||||
out("P8ZP_SCRATCH_REG_X = ${zp.SCRATCH_REG_X}")
|
out("P8ZP_SCRATCH_REG_X = ${zp.SCRATCH_REG_X}")
|
||||||
@ -114,14 +113,16 @@ internal class AsmGen(private val program: Program,
|
|||||||
out("_prog8_entrypoint\t; assembly code starts here\n")
|
out("_prog8_entrypoint\t; assembly code starts here\n")
|
||||||
out(" tsx")
|
out(" tsx")
|
||||||
out(" stx prog8_lib.orig_stackpointer")
|
out(" stx prog8_lib.orig_stackpointer")
|
||||||
out(" jsr prog8_lib.init_system")
|
if(!initproc.isNullOrEmpty())
|
||||||
|
out(" jsr $initproc")
|
||||||
}
|
}
|
||||||
options.output == OutputType.PRG -> {
|
options.output == OutputType.PRG -> {
|
||||||
out("; ---- program without basic sys call ----")
|
out("; ---- program without basic sys call ----")
|
||||||
out("* = ${program.actualLoadAddress.toHex()}\n")
|
out("* = ${program.actualLoadAddress.toHex()}\n")
|
||||||
out(" tsx")
|
out(" tsx")
|
||||||
out(" stx prog8_lib.orig_stackpointer")
|
out(" stx prog8_lib.orig_stackpointer")
|
||||||
out(" jsr prog8_lib.init_system")
|
if(!initproc.isNullOrEmpty())
|
||||||
|
out(" jsr $initproc")
|
||||||
}
|
}
|
||||||
options.output == OutputType.RAW -> {
|
options.output == OutputType.RAW -> {
|
||||||
out("; ---- raw assembler program ----")
|
out("; ---- raw assembler program ----")
|
||||||
|
@ -14,8 +14,7 @@ import prog8.compiler.loadAsmIncludeFile
|
|||||||
|
|
||||||
private val alwaysKeepSubroutines = setOf(
|
private val alwaysKeepSubroutines = setOf(
|
||||||
Pair("main", "start"),
|
Pair("main", "start"),
|
||||||
Pair("irq", "irq"),
|
Pair("irq", "irq")
|
||||||
Pair("prog8_lib", "init_system")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private val asmJumpRx = Regex("""[\-+a-zA-Z0-9_ \t]+(jmp|jsr)[ \t]+(\S+).*""", RegexOption.IGNORE_CASE)
|
private val asmJumpRx = Regex("""[\-+a-zA-Z0-9_ \t]+(jmp|jsr)[ \t]+(\S+).*""", RegexOption.IGNORE_CASE)
|
||||||
|
Loading…
Reference in New Issue
Block a user