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
|
||||
@operand = 0
|
||||
raise "alert" if right.is_a? Register::Label
|
||||
@pre_post_index = 0 #P flag
|
||||
@add_offset = 0 #U flag
|
||||
@pre_post_index = @attributes[:pre_post_index] ? 0 : 1 #P flag
|
||||
@add_offset = @attributes[:add_offset] ? 0 : 1 #U flag
|
||||
@is_load = opcode.to_s[0] == "l" ? 1 : 0 #L (load) flag
|
||||
end
|
||||
|
||||
@ -39,18 +39,10 @@ module Arm
|
||||
operand = @right
|
||||
#TODO better test, this operand integer (register) does not work. but sleep first
|
||||
operand = operand.symbol if operand.is_a? ::Register::RegisterValue
|
||||
unless( operand.is_a? Symbol)
|
||||
#puts "operand #{operand.inspect}"
|
||||
if (operand < 0)
|
||||
add_offset = 0
|
||||
#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
|
||||
unless( operand.is_a? Symbol) #TODO test/check/understand
|
||||
add_offset = (operand < 0) ? 0 : 1
|
||||
operand *= -1 if (operand < 0)
|
||||
raise "offset too large (max 4095) #{arg} #{inspect}" if (@operand.abs > 4095)
|
||||
end
|
||||
end
|
||||
elsif (arg.is_a?(Parfait::Object) or arg.is_a? Symbol ) #use pc relative
|
||||
@ -60,13 +52,6 @@ module Arm
|
||||
if (operand.abs > 4095)
|
||||
raise "reference offset too large/small (4095<#{operand}) #{arg} #{inspect}"
|
||||
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
|
||||
raise "invalid operand argument #{arg.inspect} #{inspect}"
|
||||
end
|
||||
@ -76,8 +61,6 @@ module Arm
|
||||
add_offset = 1
|
||||
# TODO to be continued
|
||||
add_offset = 0 if @attributes[:add_offset]
|
||||
@pre_post_index = 1
|
||||
@pre_post_index = 0 if @attributes[:pre_post_index]
|
||||
w = 0 #W flag
|
||||
byte_access = opcode.to_s[-1] == "b" ? 1 : 0 #B (byte) flag
|
||||
instuction_class = 0b01 # OPC_MEMORY_ACCESS
|
||||
@ -96,12 +79,12 @@ module Arm
|
||||
op = shift_handling
|
||||
val = shift(val , 0 ) # for the test
|
||||
val |= shift(op , 0)
|
||||
val |= shift(reg_code(@result) , 12 )
|
||||
val |= shift(reg_code(rn) , 12 + 4) #16
|
||||
val |= shift(@is_load , 12 + 4 + 4)
|
||||
val |= shift(reg_code(@result) , 12 )
|
||||
val |= shift(reg_code(rn) , 12 + 4) #16
|
||||
val |= shift(@is_load , 12 + 4 + 4)
|
||||
val |= shift(w , 12 + 4 + 4 + 1)
|
||||
val |= shift(byte_access , 12 + 4 + 4 + 1 + 1)
|
||||
val |= shift(add_offset , 12 + 4 + 4 + 1 + 1 + 1)
|
||||
val |= shift(add_offset , 12 + 4 + 4 + 1 + 1 + 1)
|
||||
val |= shift(@pre_post_index, 12 + 4 + 4 + 1 + 1 + 1 + 1)#24
|
||||
val |= shift(i , 12 + 4 + 4 + 1 + 1 + 1 + 1 + 1)
|
||||
val |= shift(instuction_class,12 + 4 + 4 + 1 + 1 + 1 + 1 + 1 + 1)
|
||||
|
@ -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_call"
|
||||
require_relative "test_logic"
|
||||
require_relative "test_memory"
|
||||
require_relative "test_move"
|
||||
require_relative "test_stack"
|
||||
|
Loading…
Reference in New Issue
Block a user