optimized in-place float var modification, not using translateExpression()

This commit is contained in:
Irmen de Jong 2020-11-24 01:09:24 +01:00
parent a7f56fe0fc
commit ab1232d742
3 changed files with 6 additions and 8 deletions

View File

@ -737,7 +737,10 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
asmgen.out(" jsr floats.set_array_float_from_fac1") asmgen.out(" jsr floats.set_array_float_from_fac1")
} }
TargetStorageKind.MEMORY -> throw AssemblyError("can't assign float to mem byte") TargetStorageKind.MEMORY -> throw AssemblyError("can't assign float to mem byte")
TargetStorageKind.REGISTER -> throw AssemblyError("can't assign Fac1 float to another fac register") TargetStorageKind.REGISTER -> {
if (target.register!! != RegisterOrPair.FAC1)
throw AssemblyError("can't assign Fac1 float to another fac register")
}
TargetStorageKind.STACK -> asmgen.out(" jsr floats.push_fac1") TargetStorageKind.STACK -> asmgen.out(" jsr floats.push_fac1")
} }
} }

View File

@ -1381,12 +1381,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
} }
private fun inplaceModification_float_value_to_variable(name: String, operator: String, value: Expression, scope: Subroutine) { private fun inplaceModification_float_value_to_variable(name: String, operator: String, value: Expression, scope: Subroutine) {
// this should be the last resort for code generation for this, asmgen.assignExpressionToRegister(value, RegisterOrPair.FAC1)
// because the value is evaluated onto the eval stack (=slow).
if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (2): $name $operator= ${value::class.simpleName} at ${value.position}") // TODO
asmgen.translateExpression(value)
asmgen.out(" jsr floats.pop_float_fac1")
asmgen.saveRegister(CpuRegister.X, false, scope) asmgen.saveRegister(CpuRegister.X, false, scope)
when (operator) { when (operator) {
"**" -> { "**" -> {

View File

@ -49,7 +49,7 @@ turtle {
uword xx = xpos as uword uword xx = xpos as uword
c64.SPXY[0] = lsb(xx) + 12 c64.SPXY[0] = lsb(xx) + 12
c64.MSIGX = msb(xx) > 0 c64.MSIGX = msb(xx) > 0
c64.SPXY[1] = ypos as ubyte + 37 c64.SPXY[1] = ypos as ubyte + 40
} }
sub pos(float x, float y) { sub pos(float x, float y) {