diff --git a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt index 43a984718..c724644ca 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt @@ -217,8 +217,9 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, if(!childIDt.isKnown) throw AssemblyError("unknown dt") val childDt = childIDt.typeOrElse(DataType.STRUCT) - if (value.type.equalsSize(childDt) || value.type.largerThan(childDt)) { + if (value.type!=DataType.FLOAT && (value.type.equalsSize(childDt) || value.type.largerThan(childDt))) { // this typecast is redundant here; the rest of the code knows how to deal with the uncasted value. + // (works for integer types, not for float.) inplaceModification(target, operator, value.expression) return true } diff --git a/examples/test.p8 b/examples/test.p8 index 3ef92e80d..7ddc104b4 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -6,16 +6,37 @@ main { sub start() { - float t = 0.0 - repeat 10 { - float cosa = cos(t) - float sina = sin(t) - float cosb = cos(t*0.33) - float sinb = sin(t*0.33) - float cosc = cos(t*0.78) - float sinc = sin(t*0.78) - } +; byte bb = 4 +; bb += sgn(bb+bb) +; txt.print_b(bb) +; txt.chrout('\n') +; +; word ww = 4 +; ww += sgn(ww+ww) +; txt.print_w(ww) +; txt.chrout('\n') + + float x = 4 + x += abs(x+x) + floats.print_f(x) + txt.chrout('\n') + + x = 4 + x += sgn(x+x) ; TODO missing byte->float cast in assembly??? Also fucks up stack + x += sgn(x+x) ; TODO missing byte->float cast in assembly??? Also fucks up stack + x += sgn(x+x) ; TODO missing byte->float cast in assembly??? Also fucks up stack + floats.print_f(x) + txt.chrout('\n') + +; repeat 10 { +; float cosa = cos(t) +; float sina = sin(t) +; float cosb = cos(t*0.33) +; float sinb = sin(t*0.33) +; float cosc = cos(t*0.78) +; float sinc = sin(t*0.78) +; } testX() }