mirror of
https://github.com/irmen/prog8.git
synced 2025-01-25 12:30:09 +00:00
cx16: set rom bank to 0 at startup (for faster kernal API calls)
cx16: callfar() with constant address generates shorter asm
This commit is contained in:
parent
1541ad2160
commit
cd49c5f88d
@ -284,6 +284,15 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram,
|
|||||||
if(asmgen.options.compTarget.name != "cx16")
|
if(asmgen.options.compTarget.name != "cx16")
|
||||||
throw AssemblyError("callfar only works on cx16 target at this time")
|
throw AssemblyError("callfar only works on cx16 target at this time")
|
||||||
|
|
||||||
|
val constBank = fcall.args[0].asConstInteger()
|
||||||
|
val constAddress = fcall.args[1].asConstInteger()
|
||||||
|
if(constBank!=null && constAddress!=null) {
|
||||||
|
asmgen.assignExpressionToRegister(fcall.args[2], RegisterOrPair.AY) // uword argument
|
||||||
|
asmgen.out("""
|
||||||
|
jsr cx16.JSRFAR
|
||||||
|
.word ${constAddress.toHex()}
|
||||||
|
.byte $constBank""")
|
||||||
|
} else {
|
||||||
asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.A) // bank
|
asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.A) // bank
|
||||||
asmgen.out(" sta (++)+0")
|
asmgen.out(" sta (++)+0")
|
||||||
asmgen.assignExpressionToRegister(fcall.args[1], RegisterOrPair.AY) // jump address
|
asmgen.assignExpressionToRegister(fcall.args[1], RegisterOrPair.AY) // jump address
|
||||||
@ -293,6 +302,8 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram,
|
|||||||
jsr cx16.JSRFAR
|
jsr cx16.JSRFAR
|
||||||
+ .word 0
|
+ .word 0
|
||||||
+ .byte 0""")
|
+ .byte 0""")
|
||||||
|
}
|
||||||
|
|
||||||
// note that by convention the values in A+Y registers are now the return value of the call.
|
// note that by convention the values in A+Y registers are now the return value of the call.
|
||||||
if(resultRegister!=null) {
|
if(resultRegister!=null) {
|
||||||
assignAsmGen.assignRegisterpairWord(AsmAssignTarget.fromRegisters(resultRegister, false, fcall.position, null, asmgen), RegisterOrPair.AY)
|
assignAsmGen.assignRegisterpairWord(AsmAssignTarget.fromRegisters(resultRegister, false, fcall.position, null, asmgen), RegisterOrPair.AY)
|
||||||
|
@ -483,7 +483,7 @@ romsub $C006 = x16edit_loadfile_options(ubyte firstbank @X, ubyte lastbank @Y, s
|
|||||||
uword filenameLengthAndOptions @R1, uword tabstopAndWordwrap @R2,
|
uword filenameLengthAndOptions @R1, uword tabstopAndWordwrap @R2,
|
||||||
uword disknumberAndColors @R3, uword headerAndStatusColors @R4) clobbers(A,X,Y)
|
uword disknumberAndColors @R3, uword headerAndStatusColors @R4) clobbers(A,X,Y)
|
||||||
|
|
||||||
; Audio (rom bank 10 - you have to activate this bank manually first! Or use callfar/JSRFAR.)
|
; Audio (rom bank 10 - you have to activate this bank manually first! Or use the stubs in the audio module. Or use callfar/JSRFAR manually.)
|
||||||
romsub $C09F = audio_init() clobbers(A,X,Y) -> bool @Pc ; (re)initialize both vera PSG and YM audio chips
|
romsub $C09F = audio_init() clobbers(A,X,Y) -> bool @Pc ; (re)initialize both vera PSG and YM audio chips
|
||||||
romsub $C000 = bas_fmfreq(ubyte channel @A, uword freq @XY, bool noretrigger @Pc) clobbers(A,X,Y) -> bool @Pc
|
romsub $C000 = bas_fmfreq(ubyte channel @A, uword freq @XY, bool noretrigger @Pc) clobbers(A,X,Y) -> bool @Pc
|
||||||
romsub $C003 = bas_fmnote(ubyte channel @A, ubyte note @X, ubyte fracsemitone @Y, bool noretrigger @Pc) clobbers(A,X,Y) -> bool @Pc
|
romsub $C003 = bas_fmnote(ubyte channel @A, ubyte note @X, ubyte fracsemitone @Y, bool noretrigger @Pc) clobbers(A,X,Y) -> bool @Pc
|
||||||
@ -1397,6 +1397,7 @@ asmsub init_system() {
|
|||||||
lda #PROG8_VARSHIGH_RAMBANK
|
lda #PROG8_VARSHIGH_RAMBANK
|
||||||
sta $00 ; select ram bank
|
sta $00 ; select ram bank
|
||||||
lda #0
|
lda #0
|
||||||
|
sta $01 ; set ROM bank to kernal bank to speed up kernal calls
|
||||||
tax
|
tax
|
||||||
tay
|
tay
|
||||||
cli
|
cli
|
||||||
@ -1413,6 +1414,7 @@ asmsub init_system_phase2() {
|
|||||||
sta restore_irq._orig_irqvec+1
|
sta restore_irq._orig_irqvec+1
|
||||||
lda #PROG8_VARSHIGH_RAMBANK
|
lda #PROG8_VARSHIGH_RAMBANK
|
||||||
sta $00 ; select ram bank
|
sta $00 ; select ram bank
|
||||||
|
stz $01 ; set ROM bank to kernal bank to speed up kernal calls
|
||||||
cli
|
cli
|
||||||
cld
|
cld
|
||||||
clc
|
clc
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
Commit "tweak program start initialization and fix cleanup at exit for atari and pet compiler targets #04cb684f" causing programs to crash (assem, rockrunner)
|
|
||||||
|
|
||||||
|
|
||||||
Improve register load order in subroutine call args assignments:
|
Improve register load order in subroutine call args assignments:
|
||||||
in certain situations, the "wrong" order of evaluation of function call arguments is done which results
|
in certain situations, the "wrong" order of evaluation of function call arguments is done which results
|
||||||
in overwriting registers that already got their value, which requires a lot of stack juggling (especially on plain 6502 cpu!)
|
in overwriting registers that already got their value, which requires a lot of stack juggling (especially on plain 6502 cpu!)
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
|
|
||||||
main {
|
main {
|
||||||
ubyte @shared @nozp value1 = 99
|
|
||||||
ubyte @shared @requirezp value2 = 42
|
|
||||||
sub start() {
|
sub start() {
|
||||||
txt.print_ub(value1)
|
uword @shared address = $C09F
|
||||||
txt.nl()
|
ubyte @shared bank = 10
|
||||||
txt.print_ub(value2)
|
uword @shared argument = $1234
|
||||||
txt.nl()
|
|
||||||
|
void callfar(bank, address, argument)
|
||||||
|
void callfar(10, $C09F, argument)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user