From ba284f6cc7a23820f1736b1b366c35cc2e728303 Mon Sep 17 00:00:00 2001 From: Zhao Shenyang Date: Wed, 7 Aug 2019 22:50:11 +0800 Subject: [PATCH] minor tweak --- examples/test_nga.lua | 4 +--- muri.lua | 3 +-- nga.lua | 15 +++++++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/test_nga.lua b/examples/test_nga.lua index 870ae49..32396ae 100644 --- a/examples/test_nga.lua +++ b/examples/test_nga.lua @@ -101,9 +101,7 @@ function run() interpreter = vm.state.memory[interpreter_addr] while not done do - for i=vm.conf.addr_start, vm.state.sp do - io.stdout:write(tostring(vm.state.data[i]) .. ' ') - end + vm:print_stacks() io.stdout:write("\nOK> ") local line = io.stdin:read() if line == 'bye' then diff --git a/muri.lua b/muri.lua index 67b8300..24b646c 100644 --- a/muri.lua +++ b/muri.lua @@ -57,8 +57,7 @@ function Muri:reset(init_target) end function Muri:fatal_error(msg) - print("Fatal error: " .. msg) - os.exit(0) + error("Fatal error: " .. msg) end function Muri:add_label(name, slice) diff --git a/nga.lua b/nga.lua index 8d6703a..522380c 100644 --- a/nga.lua +++ b/nga.lua @@ -128,13 +128,20 @@ function NgaVM:init_mem() end end -function NgaVM:print_stack() - io.stdout:write("stack:\t") +function NgaVM:print_stacks() + io.stdout:write("data stack: ( ") for i=self.conf.addr_start,self.state.sp do io.stdout:write(tostring(self.state.data[i])) - io.stdout:write("\t") + io.stdout:write(" ") end - io.stdout:write("\n") + io.stdout:write(")\n") + + io.stdout:write("address stack: ( ") + for i=self.conf.addr_start,self.state.rp do + io.stdout:write(tostring(self.state.address[i])) + io.stdout:write(" ") + end + io.stdout:write(")\n") end function NgaVM:load_image(path)