From 02c86567eedb16ebc6680096412983d4d1fb2496 Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 25 Jul 2013 22:40:25 +0200 Subject: [PATCH] new vm: next steps --- compiler/vm.nim | 4 +++- compiler/vmgen.nim | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/vm.nim b/compiler/vm.nim index 97c8700515..5f10c4e2cb 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -79,7 +79,9 @@ template decodeBx(k: expr) {.immediate, dirty.} = let rbx = instr.regBx - wordExcess ensureKind(k) -proc compile(c: PCtx, s: PSym): int = vmgen.genProc(c, s) +proc compile(c: PCtx, s: PSym): int = + result = vmgen.genProc(c, s) + c.echoCode proc myreset(n: PNode) = when defined(system.reset): diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index baa38e05a1..9e276f86c7 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -25,12 +25,17 @@ proc codeListing(c: PCtx, result: var string) = result.addf("\t$#\tr$#, r$#, r$#", ($opc).substr(3), x.regA, x.regB, x.regC) else: - result.addf("\t$#\tr$#, r$#", ($opc).substr(3), x.regA, x.regBx) - result.add(" #") + result.addf("\t$#\tr$#, r$#", ($opc).substr(3), x.regA, x.regBx-wordExcess) + result.add("\t#") result.add(toFileLine(c.debug[i])) result.add("\n") inc i +proc echoCode*(c: PCtx) = + var buf = "" + codeListing(c, buf) + echo buf + proc gABC(ctx: PCtx; n: PNode; opc: TOpcode; a, b, c: TRegister = 0) = assert opc.ord < 255 let ins = (opc.uint32 or (a.uint32 shl 8'u32) or