From 78d3d9d27d2db953efeac97c4d114e6cf282b8f9 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 13 Aug 2022 20:00:13 +0200 Subject: [PATCH] vm: get rid of jumpi traces, fix IR value issue with STOREIX --- compiler/src/prog8/compiler/astprocessing/AstChecker.kt | 5 +---- compiler/src/prog8/compiler/astprocessing/AstExtensions.kt | 2 +- virtualmachine/src/prog8/vm/Instructions.kt | 4 +++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index f5a89092e..e0334bfdf 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -259,10 +259,7 @@ internal class AstChecker(private val program: Program, ) count++ } else { - if(" return" in assembly || "\treturn" in assembly - || " jump" in assembly || "\tjump" in assembly - || " jumpi" in assembly || "\tjumpi" in assembly - ) + if(" return" in assembly || "\treturn" in assembly || " jump" in assembly || "\tjump" in assembly) count++ } } diff --git a/compiler/src/prog8/compiler/astprocessing/AstExtensions.kt b/compiler/src/prog8/compiler/astprocessing/AstExtensions.kt index ff44f0f87..cc2920cdf 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstExtensions.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstExtensions.kt @@ -172,7 +172,7 @@ internal fun IdentifierReference.isSubroutineParameter(program: Program): Boolea internal fun Subroutine.hasRtsInAsm(compTarget: ICompilationTarget): Boolean { val instructions = if(compTarget.name == VMTarget.NAME) - listOf(" return", "\treturn", " jump", "\tjump", " jumpi", "\tjumpi") + listOf(" return", "\treturn", " jump", "\tjump") else listOf(" rti", "\trti", " rts", "\trts", " jmp", "\tjmp", " bra", "\tbra") return statements diff --git a/virtualmachine/src/prog8/vm/Instructions.kt b/virtualmachine/src/prog8/vm/Instructions.kt index c90d96e99..c8ff6a050 100644 --- a/virtualmachine/src/prog8/vm/Instructions.kt +++ b/virtualmachine/src/prog8/vm/Instructions.kt @@ -44,7 +44,6 @@ But you can decide whatever you want because here we just care about jumping and Saving/restoring registers is possible with PUSH and POP instructions. jump location - continue running at instruction number given by location -jumpi reg1 - continue running at instruction number in reg1 call location - save current instruction location+1, continue execution at instruction nr given by location calli reg1 - save current instruction location+1, continue execution at instruction number in reg1 syscall value - do a systemcall identified by call number @@ -345,8 +344,11 @@ val OpcodesWithAddress = setOf( Opcode.LOADIX, Opcode.STOREM, Opcode.STOREX, + Opcode.STOREIX, Opcode.STOREZM, Opcode.STOREZX, + Opcode.JUMP, + Opcode.CALL, Opcode.INCM, Opcode.DECM, Opcode.NEGM,