How umarnurmatov/sim-interpreter works
TOY-ISA is a Ruby assembler plus a C++ simulator for its ELF output. The user workflow is to assemble source into an ELF object, select a simulator execution mode, load the object, and run instructions until the exit syscall. The simulator has linear and cached interpreters plus a threaded dispatcher, backed by shared CPU state, memory, instruction decoding, and ISA definitions. The README documents the assembler’s Rice/ELFIO binding; source excerpts do not expose its internal calls, so that connection is shown only as documented.
Main entry points: base_executor.cpp Base executor · main.cpp CLI entry point · interp_executor.cpp Interpreter · thread_executor.cpp Thread dispatcher
Components 15
Assembly
- Ruby assembler
as.rb
Simulator runtime
- CLI entry point
src/main.cpp - Base executor
src/sim/src/base_executor.cpp - Interpreter
src/sim/src/interp_executor.cpp - Thread dispatcher
src/sim/src/thread_executor.cpp
Machine model
- CPU state
src/sim/include/cpu_state.hpp - RAM
src/sim/include/memory.hpp - Instruction model
src/sim/src/instr.cpp - ISA definitions
src/sim/include/isa.hpp - Bit operations
src/sim/src/bitops.cpp
ELF integration
- ELFIO Ruby binding
src/elfio_ext/elfio_ext.cpp - ELF loader
src/sim/src/loader.cpp
Other components
- Developer
- Assembly source
- ELF object
Connections 21
- Developer → Assembly source: writes
README.md - Developer → Ruby assembler: runs
README.md - Assembly source → Ruby assembler: assembles
README.md - Ruby assembler → ELFIO Ruby binding: uses bindings
README.md - Ruby assembler → ELF object: produces
README.md - Developer → CLI entry point: runs
README.md - ELF object → ELF loader: loads input
README.md - CLI entry point → ELF loader: calls
src/main.cpp - CLI entry point → Interpreter: selects mode
src/main.cpp - CLI entry point → Thread dispatcher: selects mode
src/main.cpp - ELF loader → Base executor: loads bytes
src/sim/src/loader.cpp - Base executor → CPU state: uses state
src/sim/src/base_executor.cpp - Base executor → Instruction model: decodes
src/sim/src/base_executor.cpp - Instruction model → ISA definitions: uses encoding
- CPU state → RAM: owns
src/sim/include/cpu_state.hpp - Interpreter → Base executor: inherits
- Thread dispatcher → Base executor: inherits
- Interpreter → Bit operations: calls
src/sim/src/interp_executor.cpp - Thread dispatcher → Bit operations: calls
src/sim/src/thread_executor.cpp - Interpreter → CPU state: executes on
- Thread dispatcher → CPU state: executes on