fix the load memory instruction
This commit is contained in:
parent
31a55b07ac
commit
83d4ce55ca
@ -31,15 +31,17 @@ module Arm
|
||||
@rn = arg
|
||||
if @right
|
||||
@operand = @right
|
||||
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}"
|
||||
unless( @operand.is_a? Symbol)
|
||||
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
|
||||
end
|
||||
end
|
||||
elsif (arg.is_a?(Vm::StringConstant) ) #use pc relative
|
||||
@ -62,8 +64,6 @@ module Arm
|
||||
|
||||
def assemble(io)
|
||||
build
|
||||
puts inspect
|
||||
i = 0 #I flag (third bit)
|
||||
#not sure about these 2 constants. They produce the correct output for str r0 , r1
|
||||
# but i can't help thinking that that is because they are not used in that instruction and
|
||||
# so it doesn't matter. Will see
|
||||
@ -71,20 +71,26 @@ module Arm
|
||||
# TODO to be continued
|
||||
@add_offset = 0 if @attributes[:add_offset]
|
||||
@pre_post_index = 1
|
||||
@pre_post_index = 0 if @attributes[:flaggie]
|
||||
w = 0 #W flag
|
||||
byte_access = opcode.to_s[-1] == "b" ? 1 : 0 #B (byte) flag
|
||||
instuction_class = 0b01 # OPC_MEMORY_ACCESS
|
||||
val = @operand
|
||||
val = reg_code(@operand) if @operand.is_a?(Symbol)
|
||||
if @operand.is_a?(Symbol)
|
||||
val = reg_code(@operand)
|
||||
@pre_post_index = 0
|
||||
i = 1 # not quite sure about this, but it gives the output of as. read read read.
|
||||
else
|
||||
i = 0 #I flag (third bit)
|
||||
val = @operand
|
||||
end
|
||||
val = shift(val , 0 ) # for the test
|
||||
@pre_post_index = 0 if @attributes[:flaggie]
|
||||
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(@pre_post_index , 12+4 +4+1+1+1+1)#24
|
||||
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)
|
||||
val |= shift(cond_bit_code , 12+4 +4+1+1+1+1 +1+1+2)
|
||||
|
@ -88,7 +88,7 @@ module Core
|
||||
# make char out of digit (by using ascii encoding) 48 == "0"
|
||||
b = utoa_function.body.scope binding
|
||||
b.remainder = remainder + 48
|
||||
b.strb( remainder, right: str_addr )
|
||||
b.strb( remainder, str_addr )
|
||||
b.sub( str_addr, str_addr , 1 )
|
||||
b.cmp( number , 0 )
|
||||
b.callne( utoa_function )
|
||||
|
Loading…
Reference in New Issue
Block a user