change to_risc and builtin code according to last commit

Wherever space was loaded to get to the next_message
we now load the Message factory.
Otherwise much the same, only the attribute is next_object, not next_message
The binary is growing with 1k objects per factory, so i had to fix (hack) arm to handle bigger constants
close #14
This commit is contained in:
Torsten Ruger
2018-09-01 11:28:53 +03:00
parent d964e9ea9d
commit f798173a09
13 changed files with 39 additions and 37 deletions

View File

@ -45,7 +45,7 @@ module Risc
ret = main_ticks(64)
assert_equal FunctionReturn , ret.class
assert_equal :r1 , ret.register.symbol
assert_equal 50632 , @interpreter.get_register(ret.register)
assert_equal 175276 , @interpreter.get_register(ret.register)
end
end
end

View File

@ -19,7 +19,7 @@ module Risc
@instruction_events << was
end
def length
38
39
end
def test_state_change
@interpreter.register_event :state_changed , self
@ -40,13 +40,13 @@ module Risc
def test_chain
#show_ticks # get output of what is
check_chain [Branch, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, SlotToReg, Branch,
RegToSlot, LoadConstant, RegToSlot, FunctionCall, LoadConstant,
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, Branch, FunctionReturn, Transfer,
SlotToReg, SlotToReg, Syscall, NilClass]
LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, # 10
RegToSlot, RegToSlot, RegToSlot, SlotToReg, Branch,
LoadConstant, RegToSlot, LoadConstant, RegToSlot, FunctionCall, # 20
LoadConstant, RegToSlot, Branch, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, # 30
SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn,
Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ]
assert_equal Fixnum , get_return.class
assert_equal 5 , get_return
end

View File

@ -12,9 +12,9 @@ module Risc
def test_chain
#show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, Branch, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn,
Transfer, SlotToReg, SlotToReg, Syscall, NilClass]
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, # 10
SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn,
Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ] # 20
assert_equal 5 , get_return
end

View File

@ -50,13 +50,13 @@ module Risc
end
def test_returns_slot
r2 = RegisterValue.new(:r2 , :Message).set_builder( @builder )
@builder.build{ r2 << space![:next_message] }
@builder.build{ r2 << factory![:next_object] }
assert_equal SlotToReg , built.class
assert_equal :r1 , built.array.symbol
end
def test_returns_slot_reverse
r2 = RegisterValue.new(:r2 , :Message).set_builder( @builder )
@builder.build{ r2 << space![:next_message] }
@builder.build{ r2 << factory![:next_object] }
assert_equal SlotToReg , built.class
assert_equal :r1 , built.array.symbol
end

View File

@ -54,7 +54,7 @@ module Risc
end
def test_pc1
@interpreter.tick
assert_equal 49992 , @interpreter.pc
assert_equal 174632 , @interpreter.pc
end
def test_tick2
@interpreter.tick
@ -68,7 +68,7 @@ module Risc
def test_pc2
@interpreter.tick
@interpreter.tick
assert_equal 49996 , @interpreter.pc
assert_equal 174636 , @interpreter.pc
end
def test_tick_14_jump
14.times {@interpreter.tick}

View File

@ -25,7 +25,7 @@ module Risc
assert_equal 0 , Position.get(@linker.cpu_init).at
end
def test_cpu_at
assert_equal "0xd1fc" , Position.get(@linker.cpu_init.first).to_s
assert_equal "0x2b91c" , Position.get(@linker.cpu_init.first).to_s
end
def test_cpu_label
assert_equal Position , Position.get(@linker.cpu_init.first).class

View File

@ -13,6 +13,7 @@ module Risc
Parfait.boot!
@r0 = RegisterValue.new(:r0 , :Message)
@r1 = RegisterValue.new(:r1 , :Space)
@r2 = RegisterValue.new(:r1 , :Factory)
end
def test_class_name_type
assert_equal :Message , @r0.class_name
@ -77,11 +78,11 @@ module Risc
assert_equal 1 , instr.index
end
def test_slot_to_reg
instr = @r0 << @r1[:next_message]
instr = @r0 << @r2[:next_object]
assert_equal SlotToReg , instr.class
assert_equal @r1 , instr.array
assert_equal @r0 , instr.register
assert_equal 4 , instr.index
assert_equal 2 , instr.index
end
def test_reg_to_byte
instr = @r1[1] <= @r0
@ -91,11 +92,11 @@ module Risc
assert_equal 1 , instr.index
end
def test_reg_to_slot
instr = @r1[:next_message] << @r0
instr = @r2[:next_object] << @r0
assert_equal RegToSlot , instr.class
assert_equal @r1 , instr.array
assert_equal @r0 , instr.register
assert_equal 4 , instr.index
assert_equal 2 , instr.index
end
end
end