implementing missing operators
This commit is contained in:
parent
d870553a1f
commit
9bfc9cf6c2
@ -186,9 +186,9 @@ module Interpreter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def execute_OperatorInstruction
|
def execute_OperatorInstruction
|
||||||
left = get_register(@instruction.left)
|
left = get_register(@instruction.left) || 0
|
||||||
rr = @instruction.right
|
rr = @instruction.right
|
||||||
right = get_register(rr)
|
right = get_register(rr) || 0
|
||||||
@flags[:overflow] = false
|
@flags[:overflow] = false
|
||||||
case @instruction.operator.to_s
|
case @instruction.operator.to_s
|
||||||
when "+"
|
when "+"
|
||||||
@ -197,9 +197,16 @@ module Interpreter
|
|||||||
result = left - right
|
result = left - right
|
||||||
when "/"
|
when "/"
|
||||||
result = left / right
|
result = left / right
|
||||||
|
when ">>"
|
||||||
|
result = left >> right
|
||||||
|
when "<<"
|
||||||
|
result = left << right
|
||||||
when "*"
|
when "*"
|
||||||
#TODO set overflow, reduce result to int
|
|
||||||
result = left * right
|
result = left * right
|
||||||
|
when "&"
|
||||||
|
result = left & right
|
||||||
|
when "|"
|
||||||
|
result = left | right
|
||||||
when "=="
|
when "=="
|
||||||
result = (left == right) ? 1 : 0
|
result = (left == right) ? 1 : 0
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user