Conditional return instructions

This commit is contained in:
Ian Gulliver
2021-11-19 16:30:11 -10:00
parent 7a24eee583
commit 50f986fb13
4 changed files with 94 additions and 30 deletions

View File

@@ -3,10 +3,8 @@ package asm
import "github.com/firestuff/subcoding/vm"
var opCodeByName = map[string]vm.OpCodeType{
"noop": vm.OpNoOp,
"nop": vm.OpNop,
"return": vm.OpReturn,
"ret": vm.OpRet,
"noop": vm.OpNoOp,
"nop": vm.OpNop,
"move": vm.OpMove,
"mov": vm.OpMov,
@@ -53,6 +51,13 @@ var opCodeByName = map[string]vm.OpCodeType{
"calt": vm.OpCalT,
"calliffalse": vm.OpCallIfFalse,
"calf": vm.OpCalF,
"return": vm.OpReturn,
"ret": vm.OpRet,
"returniftrue": vm.OpReturnIfTrue,
"rett": vm.OpRetT,
"returniffalse": vm.OpReturnIfFalse,
"retf": vm.OpRetF,
}
type operandType int
@@ -66,7 +71,6 @@ const (
var operandsByOpCode = map[vm.OpCodeType][]operandType{
vm.OpNop: []operandType{},
vm.OpRet: []operandType{},
vm.OpMov: []operandType{r, us},
vm.OpAdd: []operandType{r, us},
@@ -92,4 +96,8 @@ var operandsByOpCode = map[vm.OpCodeType][]operandType{
vm.OpCal: []operandType{s},
vm.OpCalT: []operandType{s},
vm.OpCalF: []operandType{s},
vm.OpRet: []operandType{},
vm.OpRetT: []operandType{},
vm.OpRetF: []operandType{},
}