5.1.1 Stack-Based vs Register-Based ¶
| Aspect | Stack-Based (fcvm) | Register-Based (e.g., Lua VM) |
| Storage | Operand stack (LIFO) | Virtual registers |
| Instructions | Compact, implicit operands, prone to errors | Explicit operand addressing |
| Complexity | Simple to implement | More complex logic |
| Bytecode Size | Bigger overall (smaller instructions but way more quantiry) | Smaller overall |
We chose a stack-based approach for the following reasons:
- Simpler bytecode generation: The compiler does not have to deal
with registers, knowing it does not have the capacity to remember
data while processing multiple operations.
- Monotyped language: The fact that the Franc C is an integer only
language allows for fixed-size parameter encoding. One of the main
advantages of the register-based approach is to allow for type
encoding.