diff --git a/.travis.yml b/.travis.yml index 94cc8c71..35d44cf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,4 @@ script: - ruby test/test_all.rb - bundle exec codeclimate-test-reporter rvm: - - 2.3.3 + - 2.3.7 diff --git a/lib/arm/instructions/move_instruction.rb b/lib/arm/instructions/move_instruction.rb index 4bb4453f..7621cd1a 100644 --- a/lib/arm/instructions/move_instruction.rb +++ b/lib/arm/instructions/move_instruction.rb @@ -11,6 +11,7 @@ module Arm @to = to raise "move must have from set #{inspect}" unless from @attributes[:update_status] = 1 if @attributes[:update_status] == nil + @attributes[:update_status] = 0 if @to == :pc @attributes[:condition_code] = :al if @attributes[:condition_code] == nil @attributes[:opcode] = attributes[:opcode] @operand = 0 @@ -20,17 +21,6 @@ module Arm end attr_accessor :to , :from - # arm intructions are pretty sensible, and always 4 bytes (thumb not supported) - # but not all constants fit into the part of the instruction that is left after the instruction - # code, so large moves have to be split into two instructions. - # we handle this "transparently", just this instruction looks longer - # alas, full transparency is not achieved as we only know when to use 2 instruction once we - # know where the other object is, and that position is only set after code positions have been - # determined (in link) and so see below in assemble - def byte_length - 4 - end - # don't overwrite instance variables, to make assembly repeatable def assemble(io) rn , operand , right , immediate = @rn , @operand , @from , 1 diff --git a/test/arm/helper.rb b/test/arm/helper.rb index ca21628e..c374d890 100644 --- a/test/arm/helper.rb +++ b/test/arm/helper.rb @@ -31,7 +31,9 @@ module Arm assert_equal should.length , binary.length , "code length wrong for #{code.inspect}" index = 0 binary.each_byte do |byte | - assert_equal should[index] , byte , "byte #{index} 0x#{should[index].to_s(16)} != 0x#{byte.to_s(16)}" + msg = "byte #{index} 0x#{should[index].to_s(16)} != 0x#{byte.to_s(16)} | " + msg += "#{should[index].to_s(2)} != #{byte.to_s(2)}" + assert_equal should[index] , byte , msg index += 1 end end diff --git a/test/arm/test_move.rb b/test/arm/test_move.rb index 85aca28a..45e82c70 100644 --- a/test/arm/test_move.rb +++ b/test/arm/test_move.rb @@ -10,7 +10,11 @@ module Arm end def test_mov_pc code = @machine.mov :pc, 5 - assert_code code , :mov , [0x05,0xf0,0xb0,0xe3] #e3 b0 f0 06 + assert_code code , :mov , [0x05,0xf0,0xa0,0xe3] #e3 a0 f0 06 + end + def test_mov_pc_r1 + code = @machine.mov :pc, :r1 + assert_code code , :mov , [0x01,0xf0,0xa0,0xe1] #e1 a0 f0 01 end def test_mov_max_128 code = @machine.mov :r1, 128