diff --git a/go/asm/asm.go b/go/asm/asm.go index 1069411..fdec70a 100644 --- a/go/asm/asm.go +++ b/go/asm/asm.go @@ -7,8 +7,11 @@ import ( "github.com/alecthomas/participle/v2" "github.com/alecthomas/participle/v2/lexer" + + "git.defalsify.org/festive/vm" ) + type Asm struct { Instructions []*Instruction `@@*` } @@ -112,7 +115,8 @@ func Parse(s string, w io.Writer) (int, error) { rd := strings.NewReader(s) ast, err := asmParser.Parse("file", rd) for i, v := range ast.Instructions { - fmt.Printf("%v %v\n", i, v) + op := vm.OpcodeIndex[v.OpCode] + fmt.Printf("%v (%v) %v\n", i, op, v) } return 0, err } diff --git a/go/vm/opcodes.go b/go/vm/opcodes.go index 60f05b2..77855b8 100644 --- a/go/vm/opcodes.go +++ b/go/vm/opcodes.go @@ -38,4 +38,21 @@ var ( MNEXT: "MNEXT", MPREV: "MPREV", } + + OpcodeIndex = map[string]Opcode { + "NOOP": NOOP, + "CATCH": CATCH, + "CROAK": CROAK, + "LOAD": LOAD, + "RELOAD": RELOAD, + "MAP": MAP, + "MOVE": MOVE, + "HALT": HALT, + "INCMP": INCMP, + "MSIZE": MSIZE, + "MOUT": MOUT, + "MNEXT": MNEXT, + "MPREV": MPREV, + } + )