whittling arm_translator

This commit is contained in:
Torsten Ruger 2016-12-15 18:21:08 +02:00
parent e2c006b5ad
commit 94c423c2b3

View File

@ -37,36 +37,34 @@ module Arm
ArmMachine.mov( code.to , code.from) ArmMachine.mov( code.to , code.from)
end end
def translate_GetSlot code def translate_GetSlot( code )
ArmMachine.ldr( *slot_args_for(code) )
end
def translate_SetSlot( code )
ArmMachine.str( *slot_args_for(code) )
end
def slot_args_for( code )
if(code.index.is_a? Numeric) if(code.index.is_a? Numeric)
ArmMachine.ldr( code.register , code.array , arm_index(code) ) [ code.register , code.array , arm_index(code) ]
else else
ArmMachine.ldr( code.register , code.array , code.index , :shift_lsl => 2 ) [ code.register , code.array , code.index , :shift_lsl => 2]
end end
end end
def translate_SetSlot code def byte_args_for( code )
if(code.index.is_a? Numeric) args = slot_args_for( code )
ArmMachine.str( code.register , code.array , arm_index(code) ) args.pop if(code.index.is_a? Numeric)
else args
ArmMachine.str( code.register , code.array , code.index , :shift_lsl => 2 )
end
end end
def translate_GetByte code def translate_GetByte code
if(code.index.is_a? Numeric) ArmMachine.ldrb( *byte_args_for(code) )
ArmMachine.ldrb( code.register , code.array , arm_index(code) )
else
ArmMachine.ldrb( code.register , code.array , code.index )
end
end end
def translate_SetByte code def translate_SetByte code
if(code.index.is_a? Numeric) ArmMachine.strb( *byte_args_for(code) )
ArmMachine.strb( code.register , code.array , arm_index(code) )
else
ArmMachine.strb( code.register , code.array , code.index )
end
end end
def translate_FunctionCall code def translate_FunctionCall code