fix value return and test

slot load was wrong way around
This commit is contained in:
Torsten Ruger 2018-03-23 20:02:17 +02:00
parent 6721153456
commit 0f183b3a74
4 changed files with 23 additions and 32 deletions

View File

@ -20,7 +20,7 @@ module Mom
#
class ReturnSequence < Instruction
def to_risc(compiler)
return_move = SlotLoad.new( [:message ,:return_value] , [:message , :caller, :return_value],self)
return_move = SlotLoad.new( [:message , :caller,:return_value] , [:message , :return_value],self)
moves = return_move.to_risc(compiler)
return_address = compiler.use_reg(:int)
compiler.reset_regs

View File

@ -17,7 +17,7 @@ module Risc
# fire events for changed pc and register contents
include Eventable
include Logging
log_level :debug
log_level :info
attr_reader :instruction # current instruction or pc
attr_reader :clock # current instruction or pc

View File

@ -11,46 +11,37 @@ module Risc
def test_chain
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
Transfer]
check_chain [Branch, Label, LoadConstant, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label,
LoadConstant, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, FunctionReturn, Transfer, Syscall,
NilClass]
assert_equal 5 , get_return.value
end
def test_call_main
call_ins = ticks(8)
call_ins = ticks(9)
assert_equal FunctionCall , call_ins.class
assert :main , call_ins.method.name
end
def test_load_5
load_ins = ticks 10
load_ins = ticks 11
assert_equal LoadConstant , load_ins.class
assert_equal 5 , @interpreter.get_register(load_ins.register).value
assert_equal 5 , @interpreter.get_register(load_ins.register).value
end
def pest_call
def test_transfer
transfer = ticks(19)
assert_equal Transfer , transfer.class
end
def test_sys
sys = ticks(20)
assert_equal Syscall , sys.class
end
def test_return
ret = ticks(18)
assert_equal FunctionReturn , ret.class
object = @interpreter.get_register( ret.register )
link = object.get_internal_word( ret.index )
link = @interpreter.get_register( ret.register )
assert_equal Label , link.class
end
def pest_adding
done_op = ticks(12)
assert_equal OperatorInstruction , done_op.class
left = @interpreter.get_register(done_op.left)
rr = done_op.right
right = @interpreter.get_register(rr)
assert_equal Fixnum , left.class
assert_equal Fixnum , right.class
assert_equal 7 , right
assert_equal 12 , left
done_tr = ticks(1)
assert_equal RegToSlot , done_tr.class
result = @interpreter.get_register(done_op.left)
assert_equal result , 12
end
end
end

View File

@ -9,9 +9,9 @@ module Risc
end
end
def check_return( val )
def get_return
assert_equal Parfait::Message , @interpreter.get_register(:r0).class
assert_equal val , @interpreter.get_register(:r0).return_value
@interpreter.get_register(:r0).return_value
end
def ticks( num )