From d5ae22115d19a87f61163479b972fb13e5d42caf Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 9 Sep 2012 15:22:54 +0100 Subject: [PATCH] Preserve stack pointer after VirtualMachine::Call() --- src/virtualmachine/VirtualMachine.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/virtualmachine/VirtualMachine.cpp b/src/virtualmachine/VirtualMachine.cpp index ce12b8774..c97ba7234 100644 --- a/src/virtualmachine/VirtualMachine.cpp +++ b/src/virtualmachine/VirtualMachine.cpp @@ -198,11 +198,11 @@ namespace vm int VirtualMachine::Call(int address) { word w; - int i, argCount = 13; + int i, argCount = 0; /* Set up call. */ - opPUSH(w); - crumb("Starting with PC=%d, DP=%d, RP=%d to %d\n", PC, DP, RP, address); + //crumb("Starting with PC=%d, DP=%d, RP=%d to %d\n", PC, DP, RP, address); + opPUSH(w); //wtf is the point of this... w.int4 = (argCount + 2) * sizeof(word); opENTER(w); i = 8; @@ -222,11 +222,14 @@ namespace vm w.int4 = address; Push(w); opCALL(w); - printf("Upon running PC=%d, DP=%d, RP=%d\n", PC, DP, RP); + //printf("Upon running PC=%d, DP=%d, RP=%d\n", PC, DP, RP); Run(); - printf("At finish PC=%d, DP=%d, RP=%d\n", PC, DP, RP); + //printf("At finish PC=%d, DP=%d, RP=%d\n", PC, DP, RP); w.int4 = (argCount + 2) * sizeof(word); opLEAVE(w); + opPOP(w); //To counter that stupid opPUSH at the start + PC = romSize + 1; + //crumb("Ending with PC=%d, DP=%d, RP=%d\n", PC, DP, RP); return 0; }