Add conditional call instructions

This commit is contained in:
Ian Gulliver
2021-11-19 16:24:04 -10:00
parent 6e36152b6a
commit 7a24eee583
4 changed files with 89 additions and 25 deletions

View File

@@ -5,8 +5,6 @@ import "github.com/firestuff/subcoding/vm"
var opCodeByName = map[string]vm.OpCodeType{
"noop": vm.OpNoOp,
"nop": vm.OpNop,
"call": vm.OpCall,
"cal": vm.OpCal,
"return": vm.OpReturn,
"ret": vm.OpRet,
@@ -48,6 +46,13 @@ var opCodeByName = map[string]vm.OpCodeType{
"jmpt": vm.OpJmpT,
"jumpiffalse": vm.OpJumpIfFalse,
"jmpf": vm.OpJmpF,
"call": vm.OpCall,
"cal": vm.OpCal,
"calliftrue": vm.OpCallIfTrue,
"calt": vm.OpCalT,
"calliffalse": vm.OpCallIfFalse,
"calf": vm.OpCalF,
}
type operandType int
@@ -61,7 +66,6 @@ const (
var operandsByOpCode = map[vm.OpCodeType][]operandType{
vm.OpNop: []operandType{},
vm.OpCal: []operandType{s},
vm.OpRet: []operandType{},
vm.OpMov: []operandType{r, us},
@@ -84,4 +88,8 @@ var operandsByOpCode = map[vm.OpCodeType][]operandType{
vm.OpJmp: []operandType{s},
vm.OpJmpT: []operandType{s},
vm.OpJmpF: []operandType{s},
vm.OpCal: []operandType{s},
vm.OpCalT: []operandType{s},
vm.OpCalF: []operandType{s},
}