seperate position create and register

many test fixes
This commit is contained in:
Torsten Ruger
2018-06-15 22:00:49 +03:00
parent 9c93b38b8f
commit 698c845297
16 changed files with 75 additions and 55 deletions

View File

@ -18,7 +18,7 @@ module Arm
@machine = Arm::ArmMachine
@binary = FakeBin.new
Risc::Position.clear_positions
Risc::Position.new(@binary , 0)
Risc::Position.create(@binary).set(0)
end
# code is what the generator spits out, at least one instruction worth (.first)

View File

@ -18,9 +18,9 @@ module Arm
def test_method_call
Risc.machine.boot
bin = Parfait::BinaryCode.new(1)
Risc::Position.new(bin , 0x20)
Risc::Position.new(bin).set(0x20)
code = @machine.call( bin ,{} )#this jumps to the next instruction
Risc::Position.new(code, 0)
Risc::Position.new(code).set(0)
assert_code code , :call, [0x08,0x0,0x0,0xeb]
end
def test_swi

View File

@ -82,7 +82,7 @@ module Arm
end
def test_too_big_add
code = @machine.add :r1 , :r1, 0x222
Risc::Position.new(code,0)
Risc::Position.create(code).set(0)
# add 0x02 (first instruction) and then 0x220 shifted
assert_code code , :add , [0x02,0x1c,0x91,0xe2] #e2 91 1e 02
# added extra instruction to add "extra"
@ -91,14 +91,14 @@ module Arm
def label( pos = 0x22 + 8)
label = Risc::Label.new("some" , "Label" , FakeAddress.new(pos))
Risc::Position.new(label , pos)
Risc::Position.create(label).set(pos)
#Risc::Position.set(l , pos , @binary)
label
end
def test_move_object
code = @machine.add( :r1 , label)
Risc::Position.new(code,0)
Risc::Position.create(code).set(0)
assert_code code , :add , [0x22,0x10,0x9f,0xe2] #e2 9f 10 22
end

View File

@ -26,7 +26,7 @@ module Arm
end
def test_mov_big
code = @machine.mov :r0, 0x222 # is not 8 bit and can't be rotated by the arm system in one instruction
Risc::Position.new(code,0)
Risc::Position.new(code).set(0)
# mov 512(0x200) = e3 a0 0c 02 add 34(0x22) = e2 90 00 22
assert_code code , :mov , [ 0x02,0x0c,0xb0,0xe3]
assert_code code.next , :add , [ 0x22,0x00,0x90,0xe2]