add <= operator for fibo

This commit is contained in:
Torsten Ruger 2014-05-28 20:10:16 +03:00
parent 5c0f62ebb9
commit 4186c9cafe
3 changed files with 14 additions and 3 deletions

View File

@ -18,6 +18,10 @@ module Arm
block << cmp( left , right )
Vm::BranchCondition.new :le
end
def integer_greater_or_equal block , left , right
block << cmp( left , right )
Vm::BranchCondition.new :ge
end
def integer_less_than block , left , right
block << cmp( left , right )
Vm::BranchCondition.new :lt

View File

@ -39,6 +39,10 @@ module Ast
code = l_val.greater_than into , r_val
when "<"
code = l_val.less_than into , r_val
when ">="
code = l_val.greater_or_equal into , r_val
when "<="
code = l_val.less_or_equal into , r_val
when "=="
code = l_val.equals into , r_val
when "+"

View File

@ -97,15 +97,18 @@ module Vm
def less_or_equal block , right
RegisterMachine.instance.integer_less_or_equal block , self , right
end
def greater_or_equal block , right
RegisterMachine.instance.integer_greater_or_equal block , self , right
end
def greater_than block , right
RegisterMachine.instance.integer_greater_than block , self , right
end
def equals block , right
RegisterMachine.instance.integer_equals block , self , right
end
def less_than block , right
RegisterMachine.instance.integer_less_than block , self , right
end
def equals block , right
RegisterMachine.instance.integer_equals block , self , right
end
def == other
code = class_for(CompareInstruction).new(self , other , opcode: :cmp)
end