summaryrefslogtreecommitdiff
path: root/src/vm/core.js
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-05-23 11:52:02 -0500
committersanine-a <sanine.not@pm.me>2023-05-23 11:52:02 -0500
commitd9dcab1271568f1c4bf70e97b707fb8cf42e10fd (patch)
tree10b1d24e0db7e25a26a95bdaacd1219e3af5e64f /src/vm/core.js
parent2880c1565102d8a969846c5e68300ced88066943 (diff)
fix core boundary wrapping
Diffstat (limited to 'src/vm/core.js')
-rw-r--r--src/vm/core.js7
1 files changed, 6 insertions, 1 deletions
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;
+ }
}