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
|
||||
@operand = 0
|
||||
|
||||
@rn = nil
|
||||
@left = nil
|
||||
@i = 0
|
||||
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)
|
||||
def length
|
||||
4
|
||||
end
|
||||
|
||||
#(stays in subclases, while build is overriden to provide different arguments)
|
||||
def do_build(arg)
|
||||
# Build representation for source value
|
||||
def build
|
||||
@left = @attributes[:left]
|
||||
arg = @attributes[:extra]
|
||||
|
||||
if arg.is_a?(Vm::StringConstant)
|
||||
# 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)
|
||||
arg = Vm::IntegerConstant.new( arg.position - self.position - 8 )
|
||||
@rn = :pc
|
||||
@left = :pc
|
||||
end
|
||||
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
|
||||
arg = Vm::IntegerConstant.new( arg )
|
||||
@ -89,7 +85,7 @@ module Arm
|
||||
val = shift(val , 0)
|
||||
raise inspect unless reg_code(@first)
|
||||
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(op_bit_code , 12+4+4 +1)
|
||||
val |= shift(@i , 12+4+4 +1+4)
|
||||
|
@ -27,15 +27,15 @@ class TestArmAsm < MiniTest::Test
|
||||
end
|
||||
end
|
||||
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
|
||||
end
|
||||
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
|
||||
end
|
||||
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
|
||||
end
|
||||
def test_b
|
||||
@ -50,7 +50,7 @@ class TestArmAsm < MiniTest::Test
|
||||
assert_code code , :call, [0xff,0xff,0xff,0xeb] #ea ff ff fe
|
||||
end
|
||||
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
|
||||
end
|
||||
def test_cmn
|
||||
@ -62,7 +62,7 @@ class TestArmAsm < MiniTest::Test
|
||||
assert_code code , :cmp , [0x02,0x00,0x51,0xe1] #e1 51 00 02
|
||||
end
|
||||
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
|
||||
end
|
||||
def test_ldr
|
||||
@ -78,7 +78,7 @@ class TestArmAsm < MiniTest::Test
|
||||
assert_code code, :ldrb , [0x00,0x00,0xd0,0xe5] #e5 d0 00 00
|
||||
end
|
||||
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
|
||||
end
|
||||
def test_push
|
||||
@ -90,15 +90,15 @@ class TestArmAsm < MiniTest::Test
|
||||
assert_code code , :pop , [0x00,0x80,0xbd,0xe8] #e8 bd 80 00
|
||||
end
|
||||
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
|
||||
end
|
||||
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
|
||||
end
|
||||
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
|
||||
end
|
||||
def test_str
|
||||
@ -110,7 +110,7 @@ class TestArmAsm < MiniTest::Test
|
||||
assert_code code, :strb , [0x00,0x00,0xc0,0xe5] #e5 c0 00 00
|
||||
end
|
||||
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
|
||||
end
|
||||
def test_swi
|
||||
|
@ -18,7 +18,7 @@ class TestSmallProg < MiniTest::Test
|
||||
start = Vm::Block.new("start")
|
||||
add_code start
|
||||
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
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user