strangely the coredumps stopped. sure didnt feel like they would

This commit is contained in:
Torsten Ruger 2014-05-16 23:08:45 +03:00
parent 88eeb2bf65
commit fee82643e5
2 changed files with 14 additions and 8 deletions

View File

@ -16,9 +16,8 @@ module Arm
@add_offset = 0 #U flag
@is_load = opcode.to_s[0] == "l" ? 1 : 0 #L (load) flag
end
# attr_accessor :i, :pre_post_index, :add_offset, :byte_access, :w, :is_load, :rn, :rd
# arm intrucioons are pretty sensible, and always 4 bytes (thumb not supported)
# arm intructions are pretty sensible, and always 4 bytes (thumb not supported)
def length
4
end
@ -68,6 +67,8 @@ module Arm
# 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
@add_offset = 1
# TODO to be continued
@add_offset = 0 if @attributes[:add_offset]
@pre_post_index = 1
w = 0 #W flag
byte_access = opcode.to_s[-1] == "b" ? 1 : 0 #B (byte) flag
@ -75,6 +76,7 @@ module Arm
val = @operand
val = reg_code(@operand) if @operand.is_a?(Symbol)
val = shift(val , 0 ) # for the test
@pre_post_index = 0 if @attributes[:flaggie]
val |= shift(reg_code(@first) , 12 )
val |= shift(reg_code(@rn) , 12+4) #16
val |= shift(@is_load , 12+4 +4)

View File

@ -38,11 +38,17 @@ module Core
buffer = Vm::StringConstant.new(" ")
context.program.add_object buffer
str_addr = Vm::Integer.new(0) # address of the
block.add_code Vm::CMachine.instance.mov( str_addr , right: Vm::Integer.new(1)) #move arg up
block.add_code Vm::CMachine.instance.add( str_addr , left: buffer) # string to write to
reg1 = Vm::Integer.new(1)
block.add_code Vm::CMachine.instance.mov( reg1 , right: str_addr ) #move arg up
block.add_code Vm::CMachine.instance.add( str_addr , left: buffer ) # string to write to
block.add_code Vm::CMachine.instance.add( str_addr , left: str_addr , right:6 ) # string to write to
context.str_addr = str_addr
itos_fun = context.program.get_or_create_function(:utoa)
block.add_code Vm::CMachine.instance.call( itos_fun , {})
# And now we "just" have to print it, using the write_stdout
block.add_code Vm::CMachine.instance.add( str_addr , left: buffer ) # string to write to
block.add_code Vm::CMachine.instance.mov( reg1 , right: buffer.length )
ret = Vm::CMachine.instance.write_stdout(block)
# function.return_type = ret
function
end
@ -62,8 +68,8 @@ module Core
# ADD r10, r10, 48 #'0' # make char out of digit (by using ascii encoding)
block.add_code Vm::CMachine.instance.add( remainder , left: remainder , right: 48 )
#STRB r10, [r1], 1 # store digit at end of buffer
block.add_code Vm::CMachine.instance.strb( remainder , right: str_addr ) #and increment TODO check
# CMP r1, #0 # quotient non-zero?
# block.add_code Vm::CMachine.instance.strb( remainder , right: str_addr, offset: 1 , flagie: 1)
block.add_code Vm::CMachine.instance.strb( remainder, right: str_addr , :offset => -1 , flaggie: 1) # CMP r1, #0 # quotient non-zero?
block.add_code Vm::CMachine.instance.cmp( number , right: 0 )
#BLNE utoa # conditional recursive call to utoa
block.add_code Vm::CMachine.instance.callne( function , {} )
@ -71,8 +77,6 @@ module Core
#automatic block.add_code pop( [:pc] , {} )
return function
end
end
extend ClassMethods