|
@@ -290,6 +290,15 @@ class CodeBox {
|
|
|
if(this.stacks[this.curr_stack].Pop() === 0){ this.Move(); }
|
|
|
break;
|
|
|
// Stack manipulation
|
|
|
+ case "&": {
|
|
|
+ if (this.stacks[this.curr_stack].register == null) {
|
|
|
+ this.stacks[this.curr_stack].register = this.stacks[this.curr_stack].Pop();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.stacks[this.curr_stack].Push(this.stacks[this.curr_stack].register);
|
|
|
+ this.stacks[this.curr_stack].register = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
case ":":
|
|
|
this.stacks[this.curr_stack].Duplicate();
|
|
|
break;
|
|
@@ -351,7 +360,7 @@ class CodeBox {
|
|
|
output = true;
|
|
|
break;
|
|
|
default:
|
|
|
- throw new Error();
|
|
|
+ throw new Error(`Unknown instruction: ${instruction}`);
|
|
|
}
|
|
|
}
|
|
|
catch(e) {
|