vm: fix storezm/storezx instructions

This commit is contained in:
Irmen de Jong 2022-05-23 21:01:02 +02:00
parent e09f054058
commit e659b91c4d
4 changed files with 17 additions and 23 deletions

View File

@ -163,11 +163,11 @@ internal class AssignmentGen(private val codeGen: CodeGen, private val expressio
if(zero) {
if(fixedIndex!=null) {
variableAddr += fixedIndex*itemsize
code += VmCodeInstruction(Opcode.STOREZM, VmDataType.FLOAT, value=variableAddr)
code += VmCodeInstruction(Opcode.STOREZM, vmDt, value=variableAddr)
} else {
val indexReg = codeGen.vmRegisters.nextFree()
code += loadIndexReg(array, itemsize, indexReg)
code += VmCodeInstruction(Opcode.STOREZX, VmDataType.FLOAT, reg1=indexReg, value=variableAddr)
code += VmCodeInstruction(Opcode.STOREZX, vmDt, reg1=indexReg, value=variableAddr)
}
} else {
if(vmDt== VmDataType.FLOAT) {

View File

@ -3,6 +3,7 @@ TODO
For next release
^^^^^^^^^^^^^^^^
- vm: fix primes.p8 calculating wrong primes
...

View File

@ -1,8 +1,5 @@
%import textio
%import math
%import string
%import floats
%zeropage dontuse
%zeropage basicsafe
; NOTE: meant to test to virtual machine output target (use -target vitual)
@ -34,22 +31,17 @@ main {
sub start() {
; mcCarthy()
ubyte @shared bb = %10110001
byte @shared sb = -99
bb *= 2
bb /= 2
bb *= 8
bb /= 8
txt.print_ub(bb) ; 17
ubyte[256] sieve
ubyte xx
for xx in 0 to 255 {
sieve[xx] = false
}
for xx in 0 to 255 {
txt.print_ub(sieve[xx])
txt.spc()
}
txt.nl()
sb *= 2
sb /= 2
sb *= 8
sb /= 8
txt.print_b(sb) ; -3
txt.nl()
; ; a "pixelshader":
; sys.gfx_enable(0) ; enable lo res screen

View File

@ -630,10 +630,11 @@ class VirtualMachine(val memory: Memory, program: List<Instruction>) {
}
private fun InsINCM(i: Instruction) {
val address = i.value!!
when(i.type!!) {
VmDataType.BYTE -> memory.setUB(i.value!!, (memory.getUB(i.value)+1u).toUByte())
VmDataType.WORD -> memory.setUW(i.value!!, (memory.getUW(i.value)+1u).toUShort())
VmDataType.FLOAT -> memory.setFloat(i.value!!, memory.getFloat(i.value)+1f)
VmDataType.BYTE -> memory.setUB(address, (memory.getUB(address)+1u).toUByte())
VmDataType.WORD -> memory.setUW(address, (memory.getUW(address)+1u).toUShort())
VmDataType.FLOAT -> memory.setFloat(address, memory.getFloat(address)+1f)
}
pc++
}