mirror of
https://github.com/irmen/prog8.git
synced 2026-04-22 08:16:49 +00:00
swap longs now uses R14+R15 as temporary storage instead of R0+R1
This commit is contained in:
@@ -1338,7 +1338,7 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram,
|
||||
tya
|
||||
adc $ptrName+1
|
||||
sta P8ZP_SCRATCH_W2+1""")
|
||||
asmgen.assignExpressionToRegister(fcall.args[1], RegisterOrPair.A) // TODO *could* overwerite SCRATCH_W2 if it's a compliated expression...
|
||||
asmgen.assignExpressionToRegister(fcall.args[1], RegisterOrPair.A) // TODO *could* overwrite SCRATCH_W2 if it's a compliated expression...
|
||||
asmgen.storeIndirectByteReg(CpuRegister.A, "P8ZP_SCRATCH_W2", 0u, false, false)
|
||||
return
|
||||
}
|
||||
@@ -1419,7 +1419,7 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram,
|
||||
tya
|
||||
adc $ptrName+1
|
||||
sta P8ZP_SCRATCH_W2+1""")
|
||||
asmgen.assignExpressionToRegister(fcall.args[1], RegisterOrPair.AY) // TODO *could* overwerite SCRATCH_W2 if it's a compliated expression...
|
||||
asmgen.assignExpressionToRegister(fcall.args[1], RegisterOrPair.AY) // TODO *could* overwrite SCRATCH_W2 if it's a compliated expression...
|
||||
asmgen.out(" jsr prog8_lib.func_pokew_scratchW2")
|
||||
//asmgen.storeIndirectWordReg(RegisterOrPair.AY, "P8ZP_SCRATCH_W2", 0u)
|
||||
return
|
||||
|
||||
@@ -464,7 +464,6 @@ internal class BuiltinFuncGen(private val codeGen: IRCodeGen, private val exprGe
|
||||
}
|
||||
|
||||
private fun funcSwap(call: PtBuiltinFunctionCall): ExpressionCodeResult {
|
||||
// TODO implement swap of two variables
|
||||
require(call.args[0].type == call.args[1].type)
|
||||
val result = mutableListOf<IRCodeChunkBase>()
|
||||
|
||||
|
||||
@@ -948,7 +948,7 @@ internal class ExpressionGen(private val codeGen: IRCodeGen) {
|
||||
addInstr(result, IRInstruction(Opcode.CALL, labelSymbol = fcall.name,
|
||||
fcallArgs = FunctionCallArgs(argRegisters, returnRegSpecs)), null)
|
||||
return if(fcall.void)
|
||||
ExpressionCodeResult(result, IRDataType.BYTE, -1, -1) // TODO datatype void?
|
||||
ExpressionCodeResult(result, IRDataType.BYTE, -1, -1)
|
||||
else if(returnRegSpecs.size==1) {
|
||||
val returnRegSpec = returnRegSpecs.single()
|
||||
if (fcall.type.isFloat)
|
||||
|
||||
@@ -777,19 +777,19 @@ swap_words .proc
|
||||
.pend
|
||||
|
||||
swap_longs .proc
|
||||
; -- swap long values pointed to by P8ZP_SCRATCH_W1 and AY. Clobbers R0 and R1 (temporary swap var)
|
||||
; -- swap long values pointed to by P8ZP_SCRATCH_W1 and AY. Clobbers R14 and R15 (temporary swap var)
|
||||
|
||||
sta P8ZP_SCRATCH_W2
|
||||
sty P8ZP_SCRATCH_W2+1
|
||||
ldy #3
|
||||
- lda (P8ZP_SCRATCH_W1),y
|
||||
sta cx16.r0r1sl,y
|
||||
sta cx16.r14r15sl,y
|
||||
lda (P8ZP_SCRATCH_W2),y
|
||||
sta (P8ZP_SCRATCH_W1),y
|
||||
dey
|
||||
bpl -
|
||||
ldy #3
|
||||
- lda cx16.r0r1sl,y
|
||||
- lda cx16.r14r15sl,y
|
||||
sta (P8ZP_SCRATCH_W2),y
|
||||
dey
|
||||
bpl -
|
||||
|
||||
@@ -13,6 +13,7 @@ Future Things and Ideas
|
||||
- make builtin functions capable of returning multiple values, then make divmod() return the 2 results rather than accepting 2 extra variables as arguments
|
||||
- then also introduce lmh(longvalue) -or whatever sensible name- builtin function that returns the low, mid, hi (bank) bytes of a long.
|
||||
- add a -profile option (for now X16 only) that instruments the start (and returns?) -of every prog8 subroutine with code that dumps to the X16 emulator debug console: name of sub, stack pointer (for call depth!), emudbg cycle count. Save/restore all used registers! Start of program must set cycle count to zero.
|
||||
- add @private to variables and subroutines declared in a scope to make them invisible from outside that scope?
|
||||
- when implementing unsigned longs: remove the (multiple) "TODO "hack" to allow unsigned long constants to be used as values for signed longs, without needing a cast"
|
||||
- structs: properly fix the symbol name prefix hack in StStruct.sameas(), see github issue 198
|
||||
- struct/ptr: support const pointers (simple and struct types) (make sure to change codegen properly in all cases, change remark about this limitation in docs too)
|
||||
@@ -119,7 +120,6 @@ Optimizations
|
||||
- Compilation speed regression: test/comparisons/test_word_lte.p8 compilation takes almost twice as long as with prog8 11.4 and 10.5 is even faster. Largest slowdown in "ast optimizing" pass.
|
||||
- Compilation speed: try to join multiple modifications in 1 result in the AST processors instead of returning it straight away every time
|
||||
- Optimize the IfExpression code generation to be more like regular if-else code. (both 6502 and IR) search for "TODO don't store condition as expression" ... but maybe postpone until codegen from IR, where it seems solved?
|
||||
- optimize floats.cast_from_long and floats.cast_as_long by directly accessing FAC bits?
|
||||
- VariableAllocator: can we think of a smarter strategy for allocating variables into zeropage, rather than first-come-first-served?
|
||||
for instance, vars used inside loops first, then loopvars, then uwords used as pointers (or these first??), then the rest
|
||||
This will probably need the register categorization from the IR explained there, for the old 6502 codegen there is not enough information to act on
|
||||
|
||||
Reference in New Issue
Block a user