fix interpreter to simulate 32 bit machine
This commit is contained in:
parent
5c862111b9
commit
f779b5d15f
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user