fix putstring registers
This commit is contained in:
parent
3a3a9277b3
commit
17a1121408
@ -43,11 +43,11 @@ module SlotMachine
|
|||||||
# This instance is filled with os return value
|
# This instance is filled with os return value
|
||||||
def self.restore_message(builder)
|
def self.restore_message(builder)
|
||||||
r8 = Risc::RegisterValue.new( :saved_message , :Message).set_compiler(builder.compiler)
|
r8 = Risc::RegisterValue.new( :saved_message , :Message).set_compiler(builder.compiler)
|
||||||
|
tmp = Risc::RegisterValue.new( :integer_tmp , :Integer).set_compiler(builder.compiler)
|
||||||
builder.build do
|
builder.build do
|
||||||
integer_reg! << message
|
tmp << message
|
||||||
message << r8
|
message << r8
|
||||||
integer_2! << message[:return_value]
|
message[:return_value][Parfait::Integer.integer_index] << tmp
|
||||||
integer_2[Parfait::Integer.integer_index] << integer_reg
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,10 +2,10 @@ module SlotMachine
|
|||||||
class Putstring < Macro
|
class Putstring < Macro
|
||||||
def to_risc(compiler)
|
def to_risc(compiler)
|
||||||
builder = compiler.builder(compiler.source)
|
builder = compiler.builder(compiler.source)
|
||||||
builder.prepare_int_return # makes integer_tmp variable as return
|
integer = builder.prepare_int_return # makes integer_tmp variable as return
|
||||||
builder.build do
|
builder.build do
|
||||||
word! << message[:receiver]
|
word = message[:receiver].to_reg.known_type(:Word)
|
||||||
integer! << word[Parfait::Word.get_length_index]
|
integer << word[:char_length]
|
||||||
end
|
end
|
||||||
SlotMachine::Macro.emit_syscall( builder , :putstring )
|
SlotMachine::Macro.emit_syscall( builder , :putstring )
|
||||||
compiler
|
compiler
|
||||||
|
@ -14,28 +14,29 @@ module SlotMachine
|
|||||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||||
end
|
end
|
||||||
def test_risc_length
|
def test_risc_length
|
||||||
assert_equal 44 , @method.to_risc.risc_instructions.length
|
assert_equal 42 , @method.to_risc.risc_instructions.length
|
||||||
end
|
end
|
||||||
def test_allocate
|
def test_allocate
|
||||||
assert_allocate
|
assert_allocate
|
||||||
end
|
end
|
||||||
def test_all
|
def test_all
|
||||||
assert_reg_to_slot risc(23) , :r1 , :r0 , 5
|
s = Risc.allocate_length
|
||||||
assert_slot_to_reg risc(24),:r0 , 2 , :r1
|
assert_reg_to_slot s + 1 , "id_factory_.next_object" , :message , 5
|
||||||
assert_slot_to_reg risc(25),:r1 , 1 , :r2
|
assert_slot_to_reg s + 2 ,:message , 2 , "message.receiver"
|
||||||
assert_transfer risc(26) , :r0 , :r8
|
assert_slot_to_reg s + 3 ,"message.receiver" , 1 , "id_factory_.next_object"
|
||||||
assert_equal Risc::Syscall, risc(27).class
|
assert_transfer s + 4 , :message , :saved_message
|
||||||
assert_transfer risc(28) , :r0 , :r3
|
assert_syscall s + 5 , :putstring
|
||||||
assert_transfer risc(29) , :r8 , :r0
|
assert_transfer s + 6 , :message , :integer_tmp
|
||||||
assert_slot_to_reg risc(30),:r0 , 5 , :r4
|
assert_transfer s + 7 , :saved_message , :message
|
||||||
assert_reg_to_slot risc(31) , :r3 , :r4 , 2
|
assert_slot_to_reg s + 8 ,:message , 5 , "message.return_value"
|
||||||
assert_slot_to_reg risc(32),:r0 , 5 , :r2
|
assert_reg_to_slot s + 9 , :integer_tmp , "message.return_value" , 2
|
||||||
assert_reg_to_slot risc(33) , :r2 , :r0 , 5
|
assert_slot_to_reg s + 10 ,:message , 5 , "message.return_value"
|
||||||
assert_branch risc(34) , "return_label"
|
assert_reg_to_slot s + 11 , "message.return_value" , :message , 5
|
||||||
assert_label risc(35) , "return_label"
|
assert_branch s + 12 , "return_label"
|
||||||
|
assert_label s + 13 , "return_label"
|
||||||
end
|
end
|
||||||
def test_return
|
def test_return
|
||||||
assert_return(35)
|
assert_return(34)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user