fix interpreter to simulate 32 bit machine

This commit is contained in:
Torsten Ruger 2015-11-13 20:31:35 +02:00
parent 5c862111b9
commit f779b5d15f

View File

@ -196,9 +196,9 @@ module Interpreter
when "-" when "-"
result = left - right result = left - right
when ">>" when ">>"
result = left >> right result = left / (2**right)
when "<<" when "<<"
result = left << right result = left * (2**right)
when "*" when "*"
result = left * right result = left * right
when "&" when "&"
@ -210,9 +210,9 @@ module Interpreter
else else
raise "unimplemented '#{@instruction.operator}' #{@instruction}" raise "unimplemented '#{@instruction.operator}' #{@instruction}"
end end
if( result.is_a? Bignum) if( result > 2**32 )
@flags[:overflow] = true @flags[:overflow] = true
result = result % 2**62 result = result % 2**32
else else
result = result.to_i result = result.to_i
end end