mirror of
https://github.com/irmen/prog8.git
synced 2024-11-20 03:32:05 +00:00
vm: fix mul and div instructions
This commit is contained in:
parent
0f9e87d7bb
commit
3f9cdd9b56
@ -388,6 +388,7 @@ class CodeGen(internal val program: PtProgram,
|
||||
code += VmCodeInstruction(Opcode.LOAD, VmDataType.FLOAT, fpReg1 = fpReg, fpValue = 0f)
|
||||
} else {
|
||||
val factorReg = vmRegisters.nextFreeFloat()
|
||||
code += VmCodeInstruction(Opcode.LOAD, VmDataType.FLOAT, fpReg1=factorReg, fpValue = factor)
|
||||
code += VmCodeInstruction(Opcode.MUL, VmDataType.FLOAT, fpReg1 = fpReg, fpReg2 = fpReg, fpReg3 = factorReg)
|
||||
}
|
||||
return code
|
||||
@ -430,6 +431,7 @@ class CodeGen(internal val program: PtProgram,
|
||||
code += VmCodeInstruction(Opcode.LOAD, VmDataType.FLOAT, fpReg1 = fpReg, fpValue = Float.MAX_VALUE)
|
||||
} else {
|
||||
val factorReg = vmRegisters.nextFreeFloat()
|
||||
code += VmCodeInstruction(Opcode.LOAD, VmDataType.FLOAT, fpReg1=factorReg, fpValue = factor)
|
||||
code += VmCodeInstruction(Opcode.DIV, VmDataType.FLOAT, fpReg1 = fpReg, fpReg2 = fpReg, fpReg3 = factorReg)
|
||||
}
|
||||
return code
|
||||
|
@ -4,7 +4,6 @@ TODO
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- vm: implement float any, all, reverse, sort
|
||||
- vm: fix test fp calc result being 0
|
||||
- vm: get rid of intermediate floats.xxx() functions somehow, instead generate the float instructions directly?
|
||||
- pipe operator: allow non-unary function calls in the pipe that specify the other argument(s) in the calls.
|
||||
- allow "xxx" * constexpr (where constexpr is not a number literal), now gives expression error not same type
|
||||
|
@ -10,29 +10,14 @@ main {
|
||||
sub start() {
|
||||
float fl = 42.123
|
||||
float fl2 = fl / 1.0
|
||||
txt.print_ub(fl2 as ubyte)
|
||||
txt.nl()
|
||||
txt.print_uw(fl2 as uword)
|
||||
txt.nl()
|
||||
byte bb = fl2 as byte
|
||||
txt.print_b(bb)
|
||||
txt.nl()
|
||||
txt.print_b(fl2 as byte)
|
||||
txt.nl()
|
||||
txt.print_w(fl2 as word)
|
||||
txt.nl()
|
||||
word ww = fl2 as word
|
||||
txt.print_w(ww)
|
||||
txt.nl()
|
||||
|
||||
; txt.print("rad 180 = ")
|
||||
; floats.print_f(floats.rad(180.0))
|
||||
; txt.print("rad 360 = ")
|
||||
; floats.print_f(floats.rad(360.0))
|
||||
; txt.print("deg 2 = ")
|
||||
; floats.print_f(floats.deg(2.0))
|
||||
; txt.print("deg pi = ")
|
||||
; floats.print_f(floats.deg(floats.PI))
|
||||
txt.print("rad 180 = ")
|
||||
floats.print_f(floats.rad(180.0))
|
||||
txt.print("\nrad 360 = ")
|
||||
floats.print_f(floats.rad(360.0))
|
||||
txt.print("\ndeg 2 = ")
|
||||
floats.print_f(floats.deg(2.0))
|
||||
txt.print("\ndeg pi = ")
|
||||
floats.print_f(floats.deg(floats.PI))
|
||||
sys.exit(42)
|
||||
; floats.print_f(-42.42)
|
||||
; float f1 = 1.2345
|
||||
|
Loading…
Reference in New Issue
Block a user