Skip to content

Commit

Permalink
minor tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
larme committed Aug 7, 2019
1 parent a6d4c76 commit ba284f6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 1 addition & 3 deletions examples/test_nga.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions muri.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 11 additions & 4 deletions nga.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ba284f6

Please sign in to comment.