diff --git a/compiler/res/version.txt b/compiler/res/version.txt index 912643200..7d904708c 100644 --- a/compiler/res/version.txt +++ b/compiler/res/version.txt @@ -1 +1 @@ -6.5-SNAPSHOT +6.5-BETA diff --git a/compiler/src/prog8/compiler/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt b/compiler/src/prog8/compiler/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt index d487190ae..7033f5b0e 100644 --- a/compiler/src/prog8/compiler/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt +++ b/compiler/src/prog8/compiler/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt @@ -431,8 +431,8 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen } // give up, do it via eval stack - // TODO optimize typecasts for more special cases? // note: cannot use assignTypeCastedValue because that is ourselves :P + // TODO optimize typecasts for more special cases? if(this.asmgen.options.slowCodegenWarnings) println("warning: slow stack evaluation used for typecast: $value into $targetDt (target=${target.kind} at ${value.position}") asmgen.translateExpression(origTypeCastExpression) // this performs the actual type cast in translateExpression(Typecast) @@ -1236,11 +1236,20 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen """) } TargetStorageKind.ARRAY -> { - // TODO optimize slow stack evaluation for this case, see assignVariableUByteIntoWord - if(this.asmgen.options.slowCodegenWarnings) - println("warning: slow stack evaluation used for sign-extend byte typecast at ${bytevar.position}") - asmgen.translateExpression(wordtarget.origAssign.source.expression!!) - assignStackValue(wordtarget) + if (wordtarget.constArrayIndexValue!=null) { + val scaledIdx = wordtarget.constArrayIndexValue!! * 2 + asmgen.out(" lda $sourceName") + asmgen.signExtendAYlsb(DataType.BYTE) + asmgen.out(" sta ${wordtarget.asmVarname}+$scaledIdx | sty ${wordtarget.asmVarname}+$scaledIdx+1") + } + else { + asmgen.saveRegisterLocal(CpuRegister.X, wordtarget.scope!!) + asmgen.loadScaledArrayIndexIntoRegister(wordtarget.array!!, wordtarget.datatype, CpuRegister.X) + asmgen.out(" lda $sourceName") + asmgen.signExtendAYlsb(DataType.BYTE) + asmgen.out(" sta ${wordtarget.asmVarname},x | inx | tya | sta ${wordtarget.asmVarname},x") + asmgen.restoreRegisterLocal(CpuRegister.X) + } } TargetStorageKind.REGISTER -> { when(wordtarget.register!!) { diff --git a/compiler/src/prog8/compiler/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt b/compiler/src/prog8/compiler/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt index f4b06e965..dac370cf2 100644 --- a/compiler/src/prog8/compiler/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt +++ b/compiler/src/prog8/compiler/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt @@ -688,8 +688,8 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, sec sbc P8ZP_SCRATCH_B1 sta $name""") - // TODO: tuned code for more operators } + // TODO: tuned code for more operators else -> { inplaceModification_byte_value_to_variable(name, dt, operator, memread) } @@ -719,8 +719,8 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, bcc + dec $name+1 +""") - // TODO: tuned code for more operators } + // TODO: tuned code for more operators else -> { inplaceModification_word_value_to_variable(name, dt, operator, memread) } diff --git a/examples/test.p8 b/examples/test.p8 index 84bd9f798..ee68b8823 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,34 +1,30 @@ %import textio -%import floats -%zeropage floatsafe +%zeropage basicsafe main { sub start() { - float f1 = 9.9999 - float f2 = 8.8888 - float f3 = 0.1111 + uword[] uw_arr = [1111,2222,3333] + word[] w_arr = [1111,2222,3333] - uword fs + ubyte ub = 42 + byte bb = -42 + ubyte ix = 2 - %asm {{ - phx - lda #f1 - jsr floats.MOVFM - jsr floats.NEGOP - jsr floats.FOUT - sta fs - sty fs+1 - plx - }} + uw_arr[1] = ub + w_arr[1] = bb - txt.print_uwhex(fs,1) + txt.print_uw(uw_arr[1]) txt.nl() - txt.print(fs) + txt.print_w(w_arr[1]) txt.nl() - txt.print("ok!\n") - sys.wait(2*60) + uw_arr[ix] = ub + w_arr[ix] = bb + + txt.print_uw(uw_arr[1]) + txt.nl() + txt.print_w(w_arr[1]) + } }