Ver Fonte

Implement C and R

Implemented the Call and Ret instructions.
ApisNecros há 1 ano atrás
pai
commit
4130af3910
1 ficheiros alterados com 15 adições e 0 exclusões
  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;