From 9bfc9cf6c2928c728e79bf3e982d244464b433b3 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 11 Nov 2015 20:34:49 +0200 Subject: [PATCH] implementing missing operators --- lib/interpreter/interpreter.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/interpreter/interpreter.rb b/lib/interpreter/interpreter.rb index cfd05c02..5a519e6e 100644 --- a/lib/interpreter/interpreter.rb +++ b/lib/interpreter/interpreter.rb @@ -186,9 +186,9 @@ module Interpreter end def execute_OperatorInstruction - left = get_register(@instruction.left) + left = get_register(@instruction.left) || 0 rr = @instruction.right - right = get_register(rr) + right = get_register(rr) || 0 @flags[:overflow] = false case @instruction.operator.to_s when "+" @@ -197,9 +197,16 @@ module Interpreter result = left - right when "/" result = left / right + when ">>" + result = left >> right + when "<<" + result = left << right when "*" - #TODO set overflow, reduce result to int result = left * right + when "&" + result = left & right + when "|" + result = left | right when "==" result = (left == right) ? 1 : 0 else