update arm and implement most operators

multiplication wasn’t implemented
and division isn’t part if arm
neither is rotate by register
This commit is contained in:
Torsten Ruger
2015-11-12 20:02:14 +02:00
parent 787f727974
commit 6f0d6d831e
3 changed files with 38 additions and 14 deletions

View File

@ -64,6 +64,26 @@ module Arm
end
end
def translate_OperatorInstruction code
left = code.left
right = code.right
case code.operator.to_s
when "+"
c = ArmMachine.add(left , left , right)
when "-"
c = ArmMachine.sub(left , left , right)
when "&"
c = ArmMachine.and(left , left , right)
when "|"
c = ArmMachine.orr(left , left , right)
when "*"
c = ArmMachine.mul(left , right , left) #arm rule about left not being result, lukily commutative
else
raise "unimplemented '#{code.operator}' #{code}"
end
c
end
# This implements branch logic, which is simply assembler branch
#
# The only target for a call is a Block, so we just need to get the address for the code