fix the load memory instruction

This commit is contained in:
Torsten Ruger 2014-06-01 22:06:59 +03:00
parent 31a55b07ac
commit 83d4ce55ca
2 changed files with 24 additions and 18 deletions

View File

@ -31,6 +31,7 @@ module Arm
@rn = arg @rn = arg
if @right if @right
@operand = @right @operand = @right
unless( @operand.is_a? Symbol)
if (@operand < 0) if (@operand < 0)
@add_offset = 0 @add_offset = 0
#TODO test/check/understand #TODO test/check/understand
@ -42,6 +43,7 @@ module Arm
raise "reference offset too large/small (max 4095) #{arg} #{inspect}" raise "reference offset too large/small (max 4095) #{arg} #{inspect}"
end end
end end
end
elsif (arg.is_a?(Vm::StringConstant) ) #use pc relative elsif (arg.is_a?(Vm::StringConstant) ) #use pc relative
@rn = :pc @rn = :pc
@operand = arg.position - self.position - 8 #stringtable is after code @operand = arg.position - self.position - 8 #stringtable is after code
@ -62,8 +64,6 @@ module Arm
def assemble(io) def assemble(io)
build build
puts inspect
i = 0 #I flag (third bit)
#not sure about these 2 constants. They produce the correct output for str r0 , r1 #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 # 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 # so it doesn't matter. Will see
@ -71,20 +71,26 @@ module Arm
# 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 = 1
@pre_post_index = 0 if @attributes[:flaggie]
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
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 val = @operand
val = reg_code(@operand) if @operand.is_a?(Symbol) end
val = shift(val , 0 ) # for the test val = shift(val , 0 ) # for the test
@pre_post_index = 0 if @attributes[:flaggie]
val |= shift(reg_code(@result) , 12 ) val |= shift(reg_code(@result) , 12 )
val |= shift(reg_code(@rn) , 12+4) #16 val |= shift(reg_code(@rn) , 12+4) #16
val |= shift(@is_load , 12+4 +4) val |= shift(@is_load , 12+4 +4)
val |= shift(w , 12+4 +4+1) val |= shift(w , 12+4 +4+1)
val |= shift(byte_access , 12+4 +4+1+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(@pre_post_index, 12+4 +4+1+1+1+1)#24
val |= shift(i , 12+4 +4+1+1+1+1 +1) 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(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) val |= shift(cond_bit_code , 12+4 +4+1+1+1+1 +1+1+2)

View File

@ -88,7 +88,7 @@ module Core
# make char out of digit (by using ascii encoding) 48 == "0" # make char out of digit (by using ascii encoding) 48 == "0"
b = utoa_function.body.scope binding b = utoa_function.body.scope binding
b.remainder = remainder + 48 b.remainder = remainder + 48
b.strb( remainder, right: str_addr ) b.strb( remainder, str_addr )
b.sub( str_addr, str_addr , 1 ) b.sub( str_addr, str_addr , 1 )
b.cmp( number , 0 ) b.cmp( number , 0 )
b.callne( utoa_function ) b.callne( utoa_function )