increase binary_code size to 32
save a few jump, adds some size to binary 16 just seemed kind of small
This commit is contained in:
@ -11,13 +11,13 @@ module Risc
|
||||
end
|
||||
|
||||
def test_bin_propagates_existing
|
||||
@binary.extend_to(16)
|
||||
@binary.extend_to(32)
|
||||
CodeListener.init( @binary , :interpreter).set(0)
|
||||
assert_equal @binary.padded_length , Position.get(@binary.next_code).at
|
||||
end
|
||||
def test_bin_propagates_after
|
||||
CodeListener.init( @binary , :interpreter).set(0)
|
||||
@binary.extend_to(16)
|
||||
@binary.extend_to(32)
|
||||
assert_equal @binary.padded_length , Position.get(@binary.next_code).at
|
||||
end
|
||||
end
|
||||
|
@ -7,15 +7,18 @@ module Risc
|
||||
@binary = Parfait::BinaryCode.new(1)
|
||||
@bin_pos = CodeListener.init(@binary, :interpreter).set(0)
|
||||
@instruction = DummyInstruction.new
|
||||
13.times {@instruction.last.insert(DummyInstruction.new) }
|
||||
(bin_length-3).times {@instruction.last.insert(DummyInstruction.new) }
|
||||
@position = InstructionListener.init(@instruction , @binary)
|
||||
@position.set(8)
|
||||
end
|
||||
def bin_length
|
||||
32
|
||||
end
|
||||
def test_padding
|
||||
assert_equal 64 , @binary.padded_length
|
||||
assert_equal bin_length*4 , @binary.padded_length
|
||||
end
|
||||
def test_last
|
||||
assert_equal 72 , Position.get(@instruction.last).at
|
||||
assert_equal (bin_length*4)+8 , Position.get(@instruction.last).at
|
||||
end
|
||||
def test_next
|
||||
assert @binary.next_code
|
||||
@ -26,30 +29,30 @@ module Risc
|
||||
end
|
||||
def test_insert_pushes
|
||||
@instruction.insert DummyInstruction.new
|
||||
assert_equal 76 , Position.get(@instruction.last).at
|
||||
assert_equal (bin_length*4)+12 , Position.get(@instruction.last).at
|
||||
end
|
||||
def test_pushes_after_insert
|
||||
@instruction.insert DummyInstruction.new
|
||||
@position.set(12)
|
||||
assert_equal 80 , Position.get(@instruction.last).at
|
||||
assert_equal (bin_length*4)+16 , Position.get(@instruction.last).at
|
||||
end
|
||||
def test_label_last_in_binary
|
||||
before = get(11)
|
||||
assert_equal 52 , Position.get(before).at
|
||||
before = get(bin_length-5)
|
||||
assert_equal bin_length*4-12 , Position.get(before).at
|
||||
label = Label.new("HI","Ho" , FakeAddress.new(0))
|
||||
before.insert( label )
|
||||
assert_equal 56 , Position.get(label).at
|
||||
assert_equal bin_length*4-8 , Position.get(label).at
|
||||
label
|
||||
end
|
||||
def test_after_last_label
|
||||
after = get(12)
|
||||
after = get(bin_length-4)
|
||||
label = test_label_last_in_binary
|
||||
assert_equal 56 , Position.get(label).at
|
||||
assert_equal 56 , Position.get(after).at
|
||||
assert_equal bin_length*4-8 , Position.get(label).at
|
||||
assert_equal bin_length*4-8 , Position.get(after).at
|
||||
assert_equal label.next , after
|
||||
end
|
||||
def test_but_last
|
||||
assert_equal 56 , Position.get(get(12)).at
|
||||
assert_equal bin_length*4-8 , Position.get(get(bin_length-4)).at
|
||||
end
|
||||
def get(n)
|
||||
ins = @instruction
|
||||
|
Reference in New Issue
Block a user