From a8453c126d620078bd21ae4a459465395173918f Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 19 Nov 2015 12:48:13 +0200 Subject: [PATCH] use arm shift at runtime arm indexes are in bytes (x4) at compile time but at runtime we only have the array indexes, iw word indexes arm has the nice barrel shifter to save us an extra instruction --- Gemfile.lock | 2 +- lib/arm/translator.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b68cda37..304ca146 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/salama/salama-arm.git - revision: 0a950de25a9d286fccf7d33834534a0c3a6d2682 + revision: 00beb3703b57702e6d8d4743abf7eac2504a3c83 specs: salama-arm (0.3.0) diff --git a/lib/arm/translator.rb b/lib/arm/translator.rb index 0ad7737b..4b783469 100644 --- a/lib/arm/translator.rb +++ b/lib/arm/translator.rb @@ -38,20 +38,18 @@ module Arm end def translate_GetSlot code - # times 4 because arm works in bytes, but vm in words if(code.index.is_a? Numeric) ArmMachine.ldr( code.register , code.array , arm_index(code) ) else - ArmMachine.ldr( code.register , code.array , code.index ) + ArmMachine.ldr( code.register , code.array , code.index , :shift_lsl => 2 ) end end def translate_SetSlot code - # times 4 because arm works in bytes, but vm in words if(code.index.is_a? Numeric) ArmMachine.str( code.register , code.array , arm_index(code) ) else - ArmMachine.str( code.register , code.array , code.index ) + ArmMachine.str( code.register , code.array , code.index , :shift_lsl => 2 ) end end