diff --git a/compiler/res/prog8lib/c64floats.asm b/compiler/res/prog8lib/c64floats.asm index b427aec9c..59485ea8f 100644 --- a/compiler/res/prog8lib/c64floats.asm +++ b/compiler/res/prog8lib/c64floats.asm @@ -215,23 +215,13 @@ pop_float_to_indexed_var .proc copy_float .proc ; -- copies the 5 bytes of the mflt value pointed to by SCRATCH_ZPWORD1, ; into the 5 bytes pointed to by A/Y. Clobbers A,Y. - sta c64.SCRATCH_ZPWORD2 - sty c64.SCRATCH_ZPWORD2+1 - ldy #0 - lda (c64.SCRATCH_ZPWORD1),y - sta (c64.SCRATCH_ZPWORD2),y - iny - lda (c64.SCRATCH_ZPWORD1),y - sta (c64.SCRATCH_ZPWORD2),y - iny - lda (c64.SCRATCH_ZPWORD1),y - sta (c64.SCRATCH_ZPWORD2),y - iny - lda (c64.SCRATCH_ZPWORD1),y - sta (c64.SCRATCH_ZPWORD2),y - iny - lda (c64.SCRATCH_ZPWORD1),y - sta (c64.SCRATCH_ZPWORD2),y + sta _target+1 + sty _target+2 + ldy #4 +_loop lda (c64.SCRATCH_ZPWORD1),y +_target sta $ffff,y ; modified + dey + bpl _loop rts .pend @@ -772,7 +762,6 @@ set_array_float .proc asl a clc adc c64.ESTACK_LO,x - clc adc c64.SCRATCH_ZPWORD2 ldy c64.SCRATCH_ZPWORD2+1 bcc + diff --git a/compiler/src/prog8/compiler/target/c64/codegen/AssignmentAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/AssignmentAsmGen.kt index 730f1834a..6db8206f0 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/AssignmentAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/AssignmentAsmGen.kt @@ -573,8 +573,7 @@ internal class AssignmentAsmGen(private val program: Program, private val errors sta $arrayVarName+$indexValue+4 """) } else { - // TODO the index in A below seems to be clobbered? - asmgen.translateArrayIndexIntoA(targetArrayIdx) + asmgen.translateExpression(index) asmgen.out(""" lda #<${constFloat} sta ${C64Zeropage.SCRATCH_W1} diff --git a/examples/test.p8 b/examples/test.p8 index d4336583f..f40365c30 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -7,43 +7,30 @@ main { + float[] fa = [1,2,3,4] + sub start() { + float x = 9.9 - ubyte wv - ubyte wv2 + fa[2] = 8.8 - wv *= wv2 + p() - wv += 10 - wv += 20 - wv += 30 + ubyte b = 2 + fa[b] = 9.8 + p() + fa[b] = 9.9 + p() - wv += 1 + wv2 - wv += 2 + wv2 - wv += 3 + wv2 + } - wv += wv2 + 1 - wv += wv2 + 2 - wv += wv2 + 3 - - wv = wv + 1 + wv2 - wv = wv + 2 + wv2 - wv = wv + 3 + wv2 - - wv = 1 + wv2 + wv - wv = 2 + wv2 + wv - wv = 3 + wv2 + wv - - wv = wv + wv2 + 1 - wv = wv + wv2 + 2 - wv = wv + wv2 + 3 - - wv = wv2 + 1 + wv - wv = wv2 + 2 + wv - wv = wv2 + 3 + wv - - wv = wv2 + wv + 1 - wv = wv2 + wv + 2 - wv = wv2 + wv + 3 + sub p() { + byte i + for i in 0 to len(fa)-1 { + c64flt.print_f(fa[i]) + c64.CHROUT(',') + c64.CHROUT(' ') + } + c64.CHROUT('\n') } }