rename first hash argument from right to left in logic inst
This commit is contained in:
parent
ef17bbf9dd
commit
ccafb09224
@ -11,29 +11,25 @@ module Arm
|
|||||||
@attributes[:condition_code] = :al if @attributes[:condition_code] == nil
|
@attributes[:condition_code] = :al if @attributes[:condition_code] == nil
|
||||||
@operand = 0
|
@operand = 0
|
||||||
|
|
||||||
@rn = nil
|
@left = nil
|
||||||
@i = 0
|
@i = 0
|
||||||
end
|
end
|
||||||
attr_accessor :i, :rn
|
|
||||||
|
|
||||||
# Build representation for source value
|
|
||||||
def build
|
|
||||||
@rn = @attributes[:right]
|
|
||||||
do_build @attributes[:extra]
|
|
||||||
end
|
|
||||||
|
|
||||||
# arm intrucioons are pretty sensible, and always 4 bytes (thumb not supported)
|
# arm intrucioons are pretty sensible, and always 4 bytes (thumb not supported)
|
||||||
def length
|
def length
|
||||||
4
|
4
|
||||||
end
|
end
|
||||||
|
|
||||||
#(stays in subclases, while build is overriden to provide different arguments)
|
# Build representation for source value
|
||||||
def do_build(arg)
|
def build
|
||||||
|
@left = @attributes[:left]
|
||||||
|
arg = @attributes[:extra]
|
||||||
|
|
||||||
if arg.is_a?(Vm::StringConstant)
|
if arg.is_a?(Vm::StringConstant)
|
||||||
# do pc relative addressing with the difference to the instuction
|
# do pc relative addressing with the difference to the instuction
|
||||||
# 8 is for the funny pipeline adjustment (ie oc pointing to fetch and not execute)
|
# 8 is for the funny pipeline adjustment (ie oc pointing to fetch and not execute)
|
||||||
arg = Vm::IntegerConstant.new( arg.position - self.position - 8 )
|
arg = Vm::IntegerConstant.new( arg.position - self.position - 8 )
|
||||||
@rn = :pc
|
@left = :pc
|
||||||
end
|
end
|
||||||
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
|
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
|
||||||
arg = Vm::IntegerConstant.new( arg )
|
arg = Vm::IntegerConstant.new( arg )
|
||||||
@ -89,7 +85,7 @@ module Arm
|
|||||||
val = shift(val , 0)
|
val = shift(val , 0)
|
||||||
raise inspect unless reg_code(@first)
|
raise inspect unless reg_code(@first)
|
||||||
val |= shift(reg_code(@first) , 12)
|
val |= shift(reg_code(@first) , 12)
|
||||||
val |= shift(reg_code(@rn) , 12+4)
|
val |= shift(reg_code(@left) , 12+4)
|
||||||
val |= shift(@attributes[:update_status_flag] , 12+4+4)#20
|
val |= shift(@attributes[:update_status_flag] , 12+4+4)#20
|
||||||
val |= shift(op_bit_code , 12+4+4 +1)
|
val |= shift(op_bit_code , 12+4+4 +1)
|
||||||
val |= shift(@i , 12+4+4 +1+4)
|
val |= shift(@i , 12+4+4 +1+4)
|
||||||
|
@ -27,15 +27,15 @@ class TestArmAsm < MiniTest::Test
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
def test_adc
|
def test_adc
|
||||||
code = @machine.adc :r1, right: :r3, :extra => :r5
|
code = @machine.adc :r1, left: :r3, :extra => :r5
|
||||||
assert_code code , :adc , [0x05,0x10,0xa3,0xe0] #e0 a3 10 05
|
assert_code code , :adc , [0x05,0x10,0xa3,0xe0] #e0 a3 10 05
|
||||||
end
|
end
|
||||||
def test_add
|
def test_add
|
||||||
code = @machine.add :r1 , right: :r1, :extra => :r3
|
code = @machine.add :r1 , left: :r1, :extra => :r3
|
||||||
assert_code code , :add , [0x03,0x10,0x81,0xe0] #e0 81 10 03
|
assert_code code , :add , [0x03,0x10,0x81,0xe0] #e0 81 10 03
|
||||||
end
|
end
|
||||||
def test_and # inst eval doesn't really work with and
|
def test_and # inst eval doesn't really work with and
|
||||||
code = @machine.and( :r1 , right: :r2 , :extra => :r3)
|
code = @machine.and( :r1 , left: :r2 , :extra => :r3)
|
||||||
assert_code code , :and , [0x03,0x10,0x02,0xe0] #e0 01 10 03
|
assert_code code , :and , [0x03,0x10,0x02,0xe0] #e0 01 10 03
|
||||||
end
|
end
|
||||||
def test_b
|
def test_b
|
||||||
@ -50,7 +50,7 @@ class TestArmAsm < MiniTest::Test
|
|||||||
assert_code code , :call, [0xff,0xff,0xff,0xeb] #ea ff ff fe
|
assert_code code , :call, [0xff,0xff,0xff,0xeb] #ea ff ff fe
|
||||||
end
|
end
|
||||||
def test_bic
|
def test_bic
|
||||||
code = @machine.bic :r2 , right: :r2 , :extra => :r3
|
code = @machine.bic :r2 , left: :r2 , :extra => :r3
|
||||||
assert_code code , :bic , [0x03,0x20,0xc2,0xe1] #e3 c2 20 44
|
assert_code code , :bic , [0x03,0x20,0xc2,0xe1] #e3 c2 20 44
|
||||||
end
|
end
|
||||||
def test_cmn
|
def test_cmn
|
||||||
@ -62,7 +62,7 @@ class TestArmAsm < MiniTest::Test
|
|||||||
assert_code code , :cmp , [0x02,0x00,0x51,0xe1] #e1 51 00 02
|
assert_code code , :cmp , [0x02,0x00,0x51,0xe1] #e1 51 00 02
|
||||||
end
|
end
|
||||||
def test_eor
|
def test_eor
|
||||||
code = @machine.eor :r2 , right: :r2 , :extra => :r3
|
code = @machine.eor :r2 , left: :r2 , :extra => :r3
|
||||||
assert_code code , :eor , [0x03,0x20,0x22,0xe0] #e0 22 20 03
|
assert_code code , :eor , [0x03,0x20,0x22,0xe0] #e0 22 20 03
|
||||||
end
|
end
|
||||||
def test_ldr
|
def test_ldr
|
||||||
@ -78,7 +78,7 @@ class TestArmAsm < MiniTest::Test
|
|||||||
assert_code code, :ldrb , [0x00,0x00,0xd0,0xe5] #e5 d0 00 00
|
assert_code code, :ldrb , [0x00,0x00,0xd0,0xe5] #e5 d0 00 00
|
||||||
end
|
end
|
||||||
def test_orr
|
def test_orr
|
||||||
code = @machine.orr :r2 , right: :r2 , :extra => :r3
|
code = @machine.orr :r2 , left: :r2 , :extra => :r3
|
||||||
assert_code code , :orr , [0x03,0x20,0x82,0xe1] #e1 82 20 03
|
assert_code code , :orr , [0x03,0x20,0x82,0xe1] #e1 82 20 03
|
||||||
end
|
end
|
||||||
def test_push
|
def test_push
|
||||||
@ -90,15 +90,15 @@ class TestArmAsm < MiniTest::Test
|
|||||||
assert_code code , :pop , [0x00,0x80,0xbd,0xe8] #e8 bd 80 00
|
assert_code code , :pop , [0x00,0x80,0xbd,0xe8] #e8 bd 80 00
|
||||||
end
|
end
|
||||||
def test_rsb
|
def test_rsb
|
||||||
code = @machine.rsb :r1 , right: :r2 , :extra => :r3
|
code = @machine.rsb :r1 , left: :r2 , :extra => :r3
|
||||||
assert_code code , :rsb , [0x03,0x10,0x62,0xe0]#e0 62 10 03
|
assert_code code , :rsb , [0x03,0x10,0x62,0xe0]#e0 62 10 03
|
||||||
end
|
end
|
||||||
def test_rsc
|
def test_rsc
|
||||||
code = @machine.rsc :r2 , right: :r3 , :extra => :r4
|
code = @machine.rsc :r2 , left: :r3 , :extra => :r4
|
||||||
assert_code code , :rsc , [0x04,0x20,0xe3,0xe0]#e0 e3 20 04
|
assert_code code , :rsc , [0x04,0x20,0xe3,0xe0]#e0 e3 20 04
|
||||||
end
|
end
|
||||||
def test_sbc
|
def test_sbc
|
||||||
code = @machine.sbc :r3, right: :r4 , :extra => :r5
|
code = @machine.sbc :r3, left: :r4 , :extra => :r5
|
||||||
assert_code code , :sbc , [0x05,0x30,0xc4,0xe0]#e0 c4 30 05
|
assert_code code , :sbc , [0x05,0x30,0xc4,0xe0]#e0 c4 30 05
|
||||||
end
|
end
|
||||||
def test_str
|
def test_str
|
||||||
@ -110,7 +110,7 @@ class TestArmAsm < MiniTest::Test
|
|||||||
assert_code code, :strb , [0x00,0x00,0xc0,0xe5] #e5 c0 00 00
|
assert_code code, :strb , [0x00,0x00,0xc0,0xe5] #e5 c0 00 00
|
||||||
end
|
end
|
||||||
def test_sub
|
def test_sub
|
||||||
code = @machine.sub :r2, right: :r0, :extra => 1
|
code = @machine.sub :r2, left: :r0, :extra => 1
|
||||||
assert_code code, :sub , [0x01,0x20,0x40,0xe2] #e2 40 20 01
|
assert_code code, :sub , [0x01,0x20,0x40,0xe2] #e2 40 20 01
|
||||||
end
|
end
|
||||||
def test_swi
|
def test_swi
|
||||||
|
@ -18,7 +18,7 @@ class TestSmallProg < MiniTest::Test
|
|||||||
start = Vm::Block.new("start")
|
start = Vm::Block.new("start")
|
||||||
add_code start
|
add_code start
|
||||||
start.instance_eval do
|
start.instance_eval do
|
||||||
sub :r0, right: :r0, :extra => 1 , :update_status_flag => 1 #2
|
sub :r0, left: :r0, :extra => 1 , :update_status_flag => 1 #2
|
||||||
bne start ,{} #3
|
bne start ,{} #3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user