reducing the label's int for return

placing the raw address in the register to jump to
puts the extra instruction at the risc level (not arm), thus changing a
lot of (brittle?) tests
This commit is contained in:
Torsten Ruger
2018-05-30 12:54:40 +03:00
parent 01a2911483
commit 53107d3ef8
28 changed files with 202 additions and 176 deletions

View File

@ -25,10 +25,11 @@ module Risc
Transfer, LoadData, OperatorInstruction, LoadData, OperatorInstruction,
OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
Branch, RegToSlot, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, FunctionReturn, Transfer, Syscall, NilClass]
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer,
Syscall, NilClass]
assert_equal Parfait::Integer , get_return.class
assert_equal 2 , get_return.value
end
@ -38,14 +39,14 @@ module Risc
assert_equal LoadConstant , load_ins.class
assert_equal 25 , @interpreter.get_register(load_ins.register).value
end
def test_return
ret = main_ticks(74)
def test_return_class
ret = main_ticks(75)
assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register )
assert_equal Parfait::Integer , link.class
assert_equal Fixnum , link.class
end
def test_sys
sys = main_ticks(89)
sys = main_ticks(91)
assert_equal Syscall , sys.class
assert_equal :exit , sys.name
end

View File

@ -19,10 +19,10 @@ module Risc
SlotToReg, SlotToReg, SlotToReg, ByteToReg, LoadConstant,
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, Branch, RegToSlot, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, FunctionReturn, Transfer,
Syscall, NilClass]
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
Branch, FunctionReturn, Transfer, Syscall, NilClass]
assert_equal Parfait::Integer , get_return.class
assert_equal "H".ord , get_return.value
end
@ -32,7 +32,7 @@ module Risc
assert_equal "H".ord , @interpreter.get_register(done.register)
end
def test_exit
done = main_ticks(61)
done = main_ticks(64)
assert_equal Syscall , done.class
end
end

View File

@ -20,10 +20,11 @@ module Risc
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, FunctionReturn,
Transfer, Syscall, NilClass]
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, Transfer, Syscall,
NilClass]
assert_equal Parfait::Integer , get_return.class
assert_equal 1 , get_return.value
end
@ -41,8 +42,14 @@ module Risc
assert_equal 5 , @interpreter.get_register(:r2)
assert_equal 1 , @interpreter.get_register(:r1)
end
def test_return
ret = main_ticks(63)
assert_equal FunctionReturn , ret.class
assert_equal :r1 , ret.register.symbol
assert_equal 18628 , @interpreter.get_register(ret.register)
end
def test_sys
sys = main_ticks(62)
sys = main_ticks(65)
assert_equal Syscall , sys.class
assert_equal :exit , sys.name
end

View File

@ -19,10 +19,10 @@ module Risc
SlotToReg, LoadData, OperatorInstruction, LoadConstant, SlotToReg,
SlotToReg, RegToSlot, RegToSlot, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg,
FunctionReturn, SlotToReg, SlotToReg, RegToSlot, Branch,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, FunctionReturn, Transfer,
Syscall, NilClass]
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
FunctionReturn, Transfer, Syscall, NilClass]
assert_equal Parfait::Integer , get_return.class
assert_equal 2 , get_return.value
end
@ -42,7 +42,7 @@ module Risc
end
def test_sys
sys = main_ticks(56)
sys = main_ticks(58)
assert_equal Syscall , sys.class
assert_equal :exit , sys.name
end

View File

@ -20,13 +20,18 @@ module Risc
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, FunctionReturn,
Transfer, Syscall, NilClass]
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, Transfer, Syscall,
NilClass]
assert_equal Parfait::Integer , get_return.class
assert_equal 0 , get_return.value
end
def test_zero
ticks( 12 )
assert @interpreter.flags[:zero]
end
def test_op
op = main_ticks(35)
assert_equal OperatorInstruction , op.class
@ -39,9 +44,5 @@ module Risc
main_ticks( 37 )
assert @interpreter.flags[:overflow]
end
def test_zero
ticks( 12 )
assert @interpreter.flags[:zero]
end
end
end

View File

@ -20,10 +20,11 @@ module Risc
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, FunctionReturn,
Transfer, Syscall, NilClass]
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, Branch, FunctionReturn, Transfer, Syscall,
NilClass]
assert_equal Parfait::Integer , get_return.class
assert_equal 10 , get_return.value
end
@ -102,7 +103,7 @@ module Risc
assert_equal :r4 , sl.register.symbol
end
def test_sys
sys = main_ticks(62)
sys = main_ticks(65)
assert_equal Syscall , sys.class
assert_equal :exit , sys.name
end

View File

@ -19,10 +19,11 @@ module Risc
SlotToReg, Transfer, Syscall, Transfer, Transfer,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
FunctionReturn, Transfer, Syscall, NilClass]
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, FunctionReturn, Transfer, Syscall,
NilClass]
assert_equal "Hello again" , @interpreter.stdout
assert_equal Parfait::Integer , get_return.class
assert_equal 11 , get_return.value #bytes written
@ -63,7 +64,7 @@ module Risc
assert_equal 2 , sl.index
end
def test_return
done = main_ticks(43)
done = main_ticks(44)
assert_equal FunctionReturn , done.class
end

View File

@ -20,10 +20,11 @@ module Risc
RegToSlot, SlotToReg, FunctionCall, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
RegToByte, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, Branch, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, Branch, RegToSlot, SlotToReg,
SlotToReg, FunctionReturn, Transfer, Syscall, NilClass]
SlotToReg, Branch, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, Branch, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer,
Syscall, NilClass]
assert_equal Parfait::Word , get_return.class
assert_equal "Kello" , get_return.to_string
end
@ -33,7 +34,7 @@ module Risc
assert_equal "K".ord , @interpreter.get_register(done.register)
end
def test_exit
done = main_ticks(64)
done = main_ticks(66)
assert_equal Syscall , done.class
end