summaryrefslogtreecommitdiff
path: root/src/vm/core.js
diff options
context:
space:
mode:
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;
+ }
}