redo restore after syscall with builder

This commit is contained in:
Torsten Ruger 2018-08-13 18:48:54 +03:00
parent 55bc9c5273
commit fb54d68020
2 changed files with 11 additions and 14 deletions

View File

@ -111,21 +111,18 @@ module Risc
# #
def save_message(builder) def save_message(builder)
r8 = RegisterValue.new( :r8 , :Message) r8 = RegisterValue.new( :r8 , :Message)
builder.add_code Risc.transfer("save_message", Risc.message_reg , r8 ) builder.add_transfer("save_message", Risc.message_reg , r8 )
end end
def restore_message(builder) def restore_message(builder)
r8 = RegisterValue.new( :r8 , :Message) r8 = RegisterValue.new( :r8 , :Message)
return_tmp = builder.compiler.use_reg :fixnum
source = "_restore_message"
# get the sys return out of the way
builder.add_code Risc.transfer(source, Risc.message_reg , return_tmp )
# load the stored message into the base register
builder.add_code Risc.transfer(source, r8 , Risc.message_reg )
int = builder.compiler.use_reg(:Integer) int = builder.compiler.use_reg(:Integer)
builder.add_new_int(source , return_tmp , int ) builder.build do
# save the return value into the message integer_reg << message
builder.add_code Risc.reg_to_slot( source , int , Risc.message_reg , :return_value ) message << r8
add_new_int( "_restore_message", integer_reg , int )
message[:return_value] << int
end
end end
end end

View File

@ -45,8 +45,8 @@ module Risc
sl = main_ticks(22) sl = main_ticks(22)
assert_equal Transfer , sl.class assert_equal Transfer , sl.class
assert_equal :r0 , sl.from.symbol assert_equal :r0 , sl.from.symbol
assert_equal :r2 , sl.to.symbol assert_equal :r3 , sl.to.symbol
assert_equal 11 , @interpreter.get_register(:r2) assert_equal 11 , @interpreter.get_register(:r3)
end end
def test_restore_message def test_restore_message
sl = main_ticks(23) sl = main_ticks(23)
@ -58,8 +58,8 @@ module Risc
def test_save_sys_return def test_save_sys_return
sl = main_ticks(28) sl = main_ticks(28)
assert_equal RegToSlot , sl.class assert_equal RegToSlot , sl.class
assert_equal :r2 , sl.register.symbol #return assert_equal :r3 , sl.register.symbol #return
assert_equal :r3 , sl.array.symbol #parfait integer assert_equal :r2 , sl.array.symbol #parfait integer
assert_equal 2 , sl.index assert_equal 2 , sl.index
end end
def test_return def test_return