ソースを参照

Implement C and R

Implemented the Call and Ret instructions.
ApisNecros 1 年間 前
コミット
4130af3910
1 ファイル変更15 行追加0 行削除
  1. 15 0
      starfish.js

+ 15 - 0
starfish.js

@@ -463,6 +463,21 @@ class CodeBox {
                     this.pointer.X = this.stacks[this.curr_stack].Pop();
                     break;
                 }
+                case "C": {
+                    const currCoords = new Stack([this.pointer.X, this.pointer.Y]);
+                    this.stacks.splice(this.curr_stack, 0, currCoords);
+                    this.curr_stack++;
+                    this.pointer.Y = this.stacks[this.curr_stack].Pop();
+                    this.pointer.X = this.stacks[this.curr_stack].Pop();
+                    break;
+                }
+                case "R": {
+                    const newCoords = this.stacks.splice(this.curr_stack - 1, 1).pop();
+                    this.curr_stack--;
+                    this.pointer.Y = newCoords.Pop()
+                    this.pointer.X = newCoords.Pop();
+                    break;
+                }
                 // End execution
                 case ";":
                     output = true;