mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
fix float expression crash: fl = abs/sqrt (fl)+0.5
This commit is contained in:
parent
ba25b7fee6
commit
ea6926e57d
@ -292,10 +292,10 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram,
|
||||
}
|
||||
}
|
||||
DataType.FLOAT -> {
|
||||
asmgen.out(" jsr floats.func_sqrt_into_FAC1")
|
||||
if(resultToStack)
|
||||
throw AssemblyError("no support for sqrt float onto stack")
|
||||
assignAsmGen.assignFAC1float(AsmAssignTarget(TargetStorageKind.STACK, asmgen, DataType.FLOAT, scope, fcall.position))
|
||||
else {
|
||||
asmgen.out(" jsr floats.func_sqrt_into_FAC1")
|
||||
assignAsmGen.assignFAC1float(AsmAssignTarget.fromRegisters(resultRegister ?: RegisterOrPair.FAC1, true, fcall.position, scope, asmgen))
|
||||
}
|
||||
}
|
||||
@ -688,7 +688,10 @@ internal class BuiltinFunctionsAsmGen(private val program: PtProgram,
|
||||
when (dt) {
|
||||
DataType.BYTE -> asmgen.out(" jsr prog8_lib.abs_b_stack")
|
||||
DataType.WORD -> asmgen.out(" jsr prog8_lib.abs_w_stack")
|
||||
else -> throw AssemblyError("no support for abs onto stack for this dt")
|
||||
else -> {
|
||||
asmgen.out(" jsr floats.func_abs_f_into_FAC1")
|
||||
assignAsmGen.assignFAC1float(AsmAssignTarget(TargetStorageKind.STACK, asmgen, DataType.FLOAT, scope, fcall.position))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
when (dt) {
|
||||
|
@ -165,4 +165,17 @@ main {
|
||||
compileText(C64Target(), true, text, writeAssembly = true, useNewExprCode = true) shouldNotBe null
|
||||
// no newexpr for IR targets: compileText(VMTarget(), true, text, writeAssembly = true, useNewExprCode = true) shouldNotBe null
|
||||
}
|
||||
|
||||
test("builtin func in float expression") {
|
||||
val src="""
|
||||
%import floats
|
||||
main {
|
||||
sub start() {
|
||||
float @shared fl =25.1
|
||||
fl = abs(fl)+0.5
|
||||
fl = sqrt(fl)+0.5
|
||||
}
|
||||
}"""
|
||||
compileText(C64Target(), false, src, writeAssembly = true) shouldNotBe null
|
||||
}
|
||||
})
|
@ -1,8 +1,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- c64 fix diskio.diskname
|
||||
|
||||
- fix undefined symbol error for sub curdir() -> str { return "todo" }
|
||||
- fix placeholder error for
|
||||
str result = "todo" , sub curdir() -> str { return result }
|
||||
|
Loading…
Reference in New Issue
Block a user