|
@@ -152,8 +152,10 @@ class CodeBox {
|
|
|
Execute(instruction) {
|
|
|
let output = null;
|
|
|
switch(instruction) {
|
|
|
+ // NOP
|
|
|
case " ":
|
|
|
break;
|
|
|
+ // Numbers
|
|
|
case "1":
|
|
|
case "2":
|
|
|
case "3":
|
|
@@ -172,6 +174,7 @@ class CodeBox {
|
|
|
case "f":
|
|
|
this.stack.Push(parseInt(instruction, 16));
|
|
|
break;
|
|
|
+ // Operators
|
|
|
case "+": {
|
|
|
const x = this.stack.Pop();
|
|
|
const y = this.stack.Pop();
|
|
@@ -202,12 +205,14 @@ class CodeBox {
|
|
|
this.stack.Push(y % x);
|
|
|
break;
|
|
|
}
|
|
|
+ // Output
|
|
|
case "n":
|
|
|
output = this.stack.Pop();
|
|
|
break;
|
|
|
case "o":
|
|
|
output = String.fromCharCode(this.stack.Pop());
|
|
|
break;
|
|
|
+ // End execution
|
|
|
case ";":
|
|
|
output = true;
|
|
|
break;
|