memory instruction refactor (small)
This commit is contained in:
parent
6eea3f2b2a
commit
b3eeb7db21
@ -16,8 +16,8 @@ module Arm
|
|||||||
@attributes[:condition_code] = :al if @attributes[:condition_code] == nil
|
@attributes[:condition_code] = :al if @attributes[:condition_code] == nil
|
||||||
@operand = 0
|
@operand = 0
|
||||||
raise "alert" if right.is_a? Register::Label
|
raise "alert" if right.is_a? Register::Label
|
||||||
@pre_post_index = 0 #P flag
|
@pre_post_index = @attributes[:pre_post_index] ? 0 : 1 #P flag
|
||||||
@add_offset = 0 #U flag
|
@add_offset = @attributes[:add_offset] ? 0 : 1 #U flag
|
||||||
@is_load = opcode.to_s[0] == "l" ? 1 : 0 #L (load) flag
|
@is_load = opcode.to_s[0] == "l" ? 1 : 0 #L (load) flag
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -39,18 +39,10 @@ module Arm
|
|||||||
operand = @right
|
operand = @right
|
||||||
#TODO better test, this operand integer (register) does not work. but sleep first
|
#TODO better test, this operand integer (register) does not work. but sleep first
|
||||||
operand = operand.symbol if operand.is_a? ::Register::RegisterValue
|
operand = operand.symbol if operand.is_a? ::Register::RegisterValue
|
||||||
unless( operand.is_a? Symbol)
|
unless( operand.is_a? Symbol) #TODO test/check/understand
|
||||||
#puts "operand #{operand.inspect}"
|
add_offset = (operand < 0) ? 0 : 1
|
||||||
if (operand < 0)
|
operand *= -1 if (operand < 0)
|
||||||
add_offset = 0
|
raise "offset too large (max 4095) #{arg} #{inspect}" if (@operand.abs > 4095)
|
||||||
#TODO test/check/understand
|
|
||||||
operand *= -1
|
|
||||||
else
|
|
||||||
add_offset = 1
|
|
||||||
end
|
|
||||||
if (@operand.abs > 4095)
|
|
||||||
raise "reference offset too large/small (max 4095) #{arg} #{inspect}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif (arg.is_a?(Parfait::Object) or arg.is_a? Symbol ) #use pc relative
|
elsif (arg.is_a?(Parfait::Object) or arg.is_a? Symbol ) #use pc relative
|
||||||
@ -60,13 +52,6 @@ module Arm
|
|||||||
if (operand.abs > 4095)
|
if (operand.abs > 4095)
|
||||||
raise "reference offset too large/small (4095<#{operand}) #{arg} #{inspect}"
|
raise "reference offset too large/small (4095<#{operand}) #{arg} #{inspect}"
|
||||||
end
|
end
|
||||||
elsif( arg.is_a?(Numeric) )
|
|
||||||
#TODO untested branch, probably not working
|
|
||||||
raise "is this working ?? #{arg} #{inspect}"
|
|
||||||
@pre_post_index = 1
|
|
||||||
@rn = pc
|
|
||||||
@use_addrtable_reloc = true
|
|
||||||
@addrtable_reloc_target = arg
|
|
||||||
else
|
else
|
||||||
raise "invalid operand argument #{arg.inspect} #{inspect}"
|
raise "invalid operand argument #{arg.inspect} #{inspect}"
|
||||||
end
|
end
|
||||||
@ -76,8 +61,6 @@ module Arm
|
|||||||
add_offset = 1
|
add_offset = 1
|
||||||
# TODO to be continued
|
# TODO to be continued
|
||||||
add_offset = 0 if @attributes[:add_offset]
|
add_offset = 0 if @attributes[:add_offset]
|
||||||
@pre_post_index = 1
|
|
||||||
@pre_post_index = 0 if @attributes[:pre_post_index]
|
|
||||||
w = 0 #W flag
|
w = 0 #W flag
|
||||||
byte_access = opcode.to_s[-1] == "b" ? 1 : 0 #B (byte) flag
|
byte_access = opcode.to_s[-1] == "b" ? 1 : 0 #B (byte) flag
|
||||||
instuction_class = 0b01 # OPC_MEMORY_ACCESS
|
instuction_class = 0b01 # OPC_MEMORY_ACCESS
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "test_stack"
|
|
||||||
require_relative "test_control"
|
|
||||||
require_relative "test_logic"
|
|
||||||
require_relative "test_move"
|
|
||||||
require_relative "test_memory"
|
|
||||||
require_relative "test_compare"
|
require_relative "test_compare"
|
||||||
|
require_relative "test_call"
|
||||||
|
require_relative "test_logic"
|
||||||
|
require_relative "test_memory"
|
||||||
|
require_relative "test_move"
|
||||||
|
require_relative "test_stack"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user