solidify VM model about Call/Ret - PushScope/PopScope
This commit is contained in:
@@ -31,7 +31,8 @@ The VM has:
|
||||
|
||||
* **PC (Program Counter)** — next instruction
|
||||
* **Operand Stack** — value stack
|
||||
* **Call Stack** — frame stack
|
||||
* **Call Stack** — stores execution frames for function calls
|
||||
* **Scope Stack** — stores frames for blocks within a function
|
||||
* **Heap** — dynamic memory
|
||||
* **Globals** — global variables
|
||||
* **Constant Pool** — literals and references
|
||||
@@ -174,12 +175,12 @@ State:
|
||||
|
||||
### 6.6 Functions
|
||||
|
||||
| Instruction | Cycles | Description |
|
||||
|----------------| ------ |---------------------------------|
|
||||
| `CALL addr` | 5 | Call |
|
||||
| `RET` | 4 | Return |
|
||||
| `PUSH_SCOPE n` | 3 | Creates scope (execution frame) |
|
||||
| `POP_SCOPE` | 3 | Removes scope |
|
||||
| Instruction | Cycles | Description |
|
||||
|----------------| ------ |--------------------------------------------|
|
||||
| `CALL addr` | 5 | Saves PC and creates a new call frame |
|
||||
| `RET` | 4 | Returns from function, restoring PC |
|
||||
| `PUSH_SCOPE` | 3 | Creates a scope within the current function |
|
||||
| `POP_SCOPE` | 3 | Removes current scope and its local variables |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user