fix the exit sequence

was returning wrong register (1, not 0)
also saving the message for test, which changes order as the return value destroys the message
This commit is contained in:
Torsten Ruger
2018-06-19 19:52:06 +03:00
parent 5f7683efcf
commit ce79617875
26 changed files with 57 additions and 65 deletions

View File

@ -28,8 +28,8 @@ module Risc
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, Branch, Transfer, Syscall, NilClass]
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer,
SlotToReg, Branch, SlotToReg, Syscall, NilClass]
assert_equal 2 , get_return
end

View File

@ -22,8 +22,8 @@ module Risc
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
Branch, FunctionReturn, SlotToReg, SlotToReg, Branch,
Transfer, Syscall, NilClass]
Branch, FunctionReturn, Transfer, SlotToReg, Branch,
SlotToReg, Syscall, NilClass]
assert_equal "H".ord , get_return
end
def test_byte_to_reg

View File

@ -23,8 +23,8 @@ module Risc
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, SlotToReg, SlotToReg,
Branch, Transfer, Syscall, NilClass]
SlotToReg, Branch, FunctionReturn, Transfer, SlotToReg,
Branch, SlotToReg, Syscall, NilClass]
assert_equal 1 , get_return
end
def test_load_5

View File

@ -22,7 +22,7 @@ module Risc
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
FunctionReturn, SlotToReg, SlotToReg, Branch, Transfer,
FunctionReturn, Transfer, SlotToReg, Branch, SlotToReg,
Syscall, NilClass]
assert_equal 2 , get_return
end

View File

@ -23,8 +23,8 @@ module Risc
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, SlotToReg, SlotToReg,
Branch, Transfer, Syscall, NilClass]
SlotToReg, Branch, FunctionReturn, Transfer, SlotToReg,
Branch, SlotToReg, Syscall, NilClass]
assert_equal 0 , get_return
end
def test_zero

View File

@ -23,8 +23,8 @@ module Risc
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, SlotToReg, SlotToReg,
Branch, Transfer, Syscall, NilClass]
SlotToReg, Branch, FunctionReturn, Transfer, SlotToReg,
Branch, SlotToReg, Syscall, NilClass]
assert_equal 10 , get_return
end
def test_load_5

View File

@ -22,10 +22,9 @@ module Risc
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
Branch, Transfer, Syscall, NilClass]
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
Branch, SlotToReg, Syscall, NilClass]
assert_equal "Hello again" , @interpreter.stdout
assert_equal Fixnum , get_return.class
assert_equal 11 , get_return #bytes written
end
def test_call

View File

@ -24,9 +24,8 @@ module Risc
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
Branch, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
FunctionReturn, SlotToReg, SlotToReg, Branch, Transfer,
FunctionReturn, Transfer, SlotToReg, Branch, SlotToReg,
Syscall, NilClass]
assert_equal Fixnum , get_return.class
assert_equal "K".ord , get_return
end
def test_reg_to_byte