From 7cd91610df58846d23da240f74f10b143fa28f66 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 15 Aug 2019 18:26:52 +0300 Subject: [PATCH] compiler: quick and dirty inspection fix for JMP instrs These were interpreted completely wrong, they actually have two next bytes indicating an offset. This patch is a quick fix, actually more work is needed here to properly display various instructions. --- pkg/vm/compiler/compiler.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/vm/compiler/compiler.go b/pkg/vm/compiler/compiler.go index 6b479b07a..828e8983c 100644 --- a/pkg/vm/compiler/compiler.go +++ b/pkg/vm/compiler/compiler.go @@ -122,6 +122,12 @@ func CompileAndInspect(src string) error { } fmt.Fprintf(w, "%d\t0x%x\t%s\t\n", i, b[i], instr) i++ + if instr == vm.JMP || instr == vm.JMPIF || instr == vm.JMPIFNOT || instr == vm.CALL { + for x := 0; x < 2; x++ { + fmt.Fprintf(w, "%d\t0x%x\t%d\t\n", i, b[i + x], b[i + x]) + } + i += 2 + } } w.Flush() return nil