1.3. Design Philosophy
The assembler uses dependent types to ensure correctness:
-
Type-safe operand sizes: The
OpSizetype indexes register and immediate types viaVWordandVReg, preventing mismatched operand sizes. An 8-bit register cannot be used where a 32-bit operand is expected. -
Structured addressing modes: Memory operands use
MemSpec, which captures the full range of x86 addressing: base, index, scale factor, displacement. TheNonSPRegtype statically prevents using ESP as an index register. -
Verified encoding: Each
Instrvariant maps to exactly one encoding viaencode. These encodings can be verified against real assembler output usingrflproofs. -
Compositional assembly: Programs are built from instruction sequences using
ProgBuilder, which handles label allocation and forward reference resolution.