make arm use branch_lsteners
This commit is contained in:
parent
9fc7f9b528
commit
956c2ebe54
@ -41,6 +41,11 @@ module Arm
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# if branch_to is implemented it must return the label it branches to
|
||||||
|
def branch_to
|
||||||
|
@first unless opcode == :swi
|
||||||
|
end
|
||||||
|
|
||||||
def handle_call(io)
|
def handle_call(io)
|
||||||
case @first
|
case @first
|
||||||
when Risc::Label
|
when Risc::Label
|
||||||
|
@ -38,6 +38,7 @@ module Elf
|
|||||||
|
|
||||||
@machine.object_positions.each do |slot , position|
|
@machine.object_positions.each do |slot , position|
|
||||||
next if slot.is_a?(Parfait::BinaryCode)
|
next if slot.is_a?(Parfait::BinaryCode)
|
||||||
|
next if slot.class.name.include?("Arm")
|
||||||
if( slot.respond_to? :rxf_reference_name )
|
if( slot.respond_to? :rxf_reference_name )
|
||||||
label = "#{slot.rxf_reference_name}"
|
label = "#{slot.rxf_reference_name}"
|
||||||
else
|
else
|
||||||
|
@ -97,6 +97,7 @@ module Risc
|
|||||||
instruction = instruction.next
|
instruction = instruction.next
|
||||||
end
|
end
|
||||||
branches.each do |branch|
|
branches.each do |branch|
|
||||||
|
next if branch.branch_to.nil? #nil allowed for when there is no branch
|
||||||
label_pos = Position.get(branch.branch_to)
|
label_pos = Position.get(branch.branch_to)
|
||||||
label_pos.position_listener( BranchListener.new(branch) )
|
label_pos.position_listener( BranchListener.new(branch) )
|
||||||
end
|
end
|
||||||
|
@ -15,6 +15,15 @@ module Arm
|
|||||||
code = @machine.call( -4 ,{} )#this jumps to the next instruction
|
code = @machine.call( -4 ,{} )#this jumps to the next instruction
|
||||||
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_has_branch_to
|
||||||
|
label = Risc::Label.new("HI","ho" , FakeAddress.new(0))
|
||||||
|
code = @machine.b( label )
|
||||||
|
assert_equal label , code.branch_to
|
||||||
|
end
|
||||||
|
def test_branch_to_for_swi
|
||||||
|
code = @machine.swi( 0x05 )
|
||||||
|
assert_nil code.branch_to
|
||||||
|
end
|
||||||
def test_method_call
|
def test_method_call
|
||||||
Risc.machine.boot
|
Risc.machine.boot
|
||||||
bin = Parfait::BinaryCode.new(1)
|
bin = Parfait::BinaryCode.new(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user