5.1.1 Stack-Based vs Register-Based

AspectStack-Based (fcvm)Register-Based (e.g., Lua VM)
StorageOperand stack (LIFO)Virtual registers
InstructionsCompact, implicit operands, prone to errorsExplicit operand addressing
ComplexitySimple to implementMore complex logic
Bytecode SizeBigger overall (smaller instructions but way more quantiry)Smaller overall

We chose a stack-based approach for the following reasons:

  1. 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.
  2. 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.