How ewriq/evm works
EVM is an experimental CPU simulator. Its documented workflow is assembly source through assembler and binary loader into CPU execution. The graph includes instruction parsing, label resolution, binary encoding and format handling, plus CPU logic and storage stages documented in the README and visible in sampled execution code. Source excerpts establish the principal entry-point and execution relationships; unsampled internals are represented only where the tree and README support the subsystem, without asserting unverified calls.
Main entry points: execute.go Instruction Execution · asm/main.go Assembler and Labels · vm/main.go VM Entry Point · run.go CPU Runtime
Components 20
Assembly and Encoding
- Assembly Source
app/a.vm - Assembler and Labels
app/cmd/asm/main.go - Instruction Parser
app/internal/loader/parser.go - Instruction Encoder
app/internal/crypto/encode.go
Binary Format and Loading
- Binary Header
app/internal/loader/header.go - Executable Binary
app/a.bin - Binary Loader
app/internal/loader/load.go - VM Entry Point
app/cmd/vm/main.go
CPU Execution
- Opcode System
app/internal/opcode/struct.go - Instruction Decoder
app/internal/crypto/decode.go - CPU Runtime
app/internal/cpu/run.go - Control Unit
app/internal/cpu/control.go - Instruction Execution
app/internal/cpu/execute.go - Arithmetic Logic
app/internal/cpu/alu.go
CPU Storage
- Register File
app/internal/register/controller.go - Memory
app/internal/memory/memory.go - Memory Access
app/internal/memory/memory_interface.go - Stack Operations
app/internal/cpu/execute.go - Call Stack
app/internal/cpu/execute.go
Other components
- Programmer
Connections 22
- Programmer → Assembly Source: writes
README.md - Assembly Source → Assembler and Labels: assembles
README.md - Assembler and Labels → Instruction Parser: parses
app/cmd/asm/main.go - Assembler and Labels → Instruction Encoder: encodes
app/cmd/asm/main.go - Assembler and Labels → Binary Header: builds header
app/cmd/asm/main.go - Assembler and Labels → Executable Binary: saves
app/cmd/asm/main.go - Instruction Parser → Opcode System: creates instructions
app/internal/loader/parser.go - Instruction Encoder → Opcode System: encodes instructions
- Executable Binary → VM Entry Point: runs
README.md - VM Entry Point → Binary Loader: loads binary
app/cmd/vm/main.go - VM Entry Point → Binary Header: validates header
app/cmd/vm/main.go - VM Entry Point → CPU Runtime: loads code
app/cmd/vm/main.go - VM Entry Point → Memory: creates memory
app/cmd/vm/main.go - CPU Runtime → Instruction Decoder: fetches instructions
- CPU Runtime → Control Unit: coordinates
- Control Unit → Instruction Execution: dispatches
- Instruction Execution → Arithmetic Logic: calculates
app/internal/cpu/execute.go - Instruction Execution → Register File: reads and writes
app/internal/cpu/execute.go - Instruction Execution → Memory Access: reads and writes
app/internal/cpu/execute.go - Memory Access → Memory: accesses
app/internal/memory/memory_interface.go - Instruction Execution → Stack Operations: handles stack
app/internal/cpu/execute.go - Instruction Execution → Call Stack: handles calls
app/internal/cpu/execute.go