implement arm branches

which backfired into interpreter as
plus actually means 0 or plus in arm
may still change back but for now
This commit is contained in:
Torsten Ruger 2015-11-14 00:20:03 +02:00
parent 12e210fdf5
commit 6127d92ca9
2 changed files with 21 additions and 1 deletions

View File

@ -78,6 +78,10 @@ module Arm
c = ArmMachine.orr(left , left , right)
when "*"
c = ArmMachine.mul(left , right , left) #arm rule about left not being result, lukily commutative
when ">>"
c = ArmMachine.mov(left , left , :shift_asr => right) #arm rule about left not being result, lukily commutative
when "<<"
c = ArmMachine.mov(left , left , :shift_lsl => right) #arm rule about left not being result, lukily commutative
else
raise "unimplemented '#{code.operator}' #{code}"
end
@ -92,6 +96,22 @@ module Arm
ArmMachine.b( code.label )
end
def translate_IsPlus code
ArmMachine.bpl( code.label)
end
def translate_IsMinus code
ArmMachine.bmi( code.label)
end
def translate_IsZero code
ArmMachine.beq( code.label)
end
def translate_IsOverflow code
ArmMachine.bvs( code.label)
end
def translate_Syscall code
call_codes = { :putstring => 4 , :exit => 1 }
int_code = call_codes[code.name]

View File

@ -59,7 +59,7 @@ module Interpreter
old = get_register( reg ) # also ensures format
if val.is_a? Fixnum
@flags[:zero] = (val == 0)
@flags[:plus] = (val > 0)
@flags[:plus] = (val >= 0)
@flags[:minus] = (val < 0)
log.debug "Set_flags #{val} :#{@flags.inspect}"
else