From d9dcab1271568f1c4bf70e97b707fb8cf42e10fd Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 23 May 2023 11:52:02 -0500 Subject: fix core boundary wrapping --- src/vm/core.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/vm/core.js') diff --git a/src/vm/core.js b/src/vm/core.js index 6303ee5..9b0fe77 100644 --- a/src/vm/core.js +++ b/src/vm/core.js @@ -19,7 +19,12 @@ class Core { normalize(pc, value) { - return (pc + value) % this.data.length; + const v = (pc + value) % this.data.length; + if (v < 0) { + return v + this.data.length; + } else { + return v; + } } -- cgit v1.2.1