mirror of
https://github.com/irmen/prog8.git
synced 2025-03-02 22:32:34 +00:00
optimized register save/restore on Cx16 cpu target
This commit is contained in:
parent
96c700ee46
commit
684e081399
@ -3,11 +3,8 @@
|
||||
|
||||
; Note: this code is compatible with C64 and CX16.
|
||||
|
||||
; TODO directory() BROKEN ON C64, SEEMS TO WORK ON CX16
|
||||
|
||||
diskio {
|
||||
|
||||
|
||||
sub directory(ubyte drivenumber) -> ubyte {
|
||||
; -- Prints the directory contents of disk drive 8-11 to the screen. Returns success.
|
||||
|
||||
@ -34,7 +31,7 @@ diskio {
|
||||
ubyte @zp char
|
||||
repeat {
|
||||
char = c64.CHRIN()
|
||||
if char==0 ; TODO doesn't work???
|
||||
if char==0
|
||||
break
|
||||
txt.chrout(char)
|
||||
}
|
||||
|
@ -548,10 +548,18 @@ internal class AsmGen(private val program: Program,
|
||||
private fun fixNameSymbols(name: String) = name.replace("<", "prog8_").replace(">", "") // take care of the autogenerated invalid (anon) label names
|
||||
|
||||
internal fun saveRegisterLocal(register: CpuRegister, scope: Subroutine) {
|
||||
if (CompilationTarget.instance.machine.cpu == CpuType.CPU65c02) {
|
||||
// just use the cpu's stack for all registers, shorter code
|
||||
when (register) {
|
||||
CpuRegister.A -> out(" pha")
|
||||
CpuRegister.X -> out(" phx")
|
||||
CpuRegister.Y -> out(" phy")
|
||||
}
|
||||
} else {
|
||||
when (register) {
|
||||
CpuRegister.A -> {
|
||||
out(" sta _prog8_regsaveA")
|
||||
scope.asmGenInfo.usedRegsaveA = true
|
||||
// just use the stack, only for A
|
||||
out(" pha")
|
||||
}
|
||||
CpuRegister.X -> {
|
||||
out(" stx _prog8_regsaveX")
|
||||
@ -563,6 +571,7 @@ internal class AsmGen(private val program: Program,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun saveRegisterStack(register: CpuRegister, keepA: Boolean) {
|
||||
when (register) {
|
||||
@ -589,12 +598,22 @@ internal class AsmGen(private val program: Program,
|
||||
}
|
||||
|
||||
internal fun restoreRegisterLocal(register: CpuRegister) {
|
||||
if (CompilationTarget.instance.machine.cpu == CpuType.CPU65c02) {
|
||||
when (register) {
|
||||
CpuRegister.A -> out(" lda _prog8_regsaveA")
|
||||
// this just used the stack, for all registers. Shorter code.
|
||||
CpuRegister.A -> out(" pla")
|
||||
CpuRegister.X -> out(" plx")
|
||||
CpuRegister.Y -> out(" ply")
|
||||
}
|
||||
|
||||
} else {
|
||||
when (register) {
|
||||
CpuRegister.A -> out(" pla") // this just used the stack but only for A
|
||||
CpuRegister.X -> out(" ldx _prog8_regsaveX")
|
||||
CpuRegister.Y -> out(" ldy _prog8_regsaveY")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun restoreRegisterStack(register: CpuRegister, keepA: Boolean) {
|
||||
when (register) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
%import bmp_module
|
||||
;; %import ci_module
|
||||
|
||||
; TODO WHY is this 400 bytes larger than a few hours ago?
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user