How avr34/ggvm works
GGVM is a stack-based virtual machine for executing a custom assembly language, including graphics instructions backed by the gg drawing library. The principal workflow is to provide an assembly file, tokenize it, expand imports and register labels, then execute instructions that manipulate stack and variables, branch, and draw or save images. The README documents local and system-wide imports and the planned instruction set; source excerpts show the CLI, tokenizer, VM lifecycle, dispatch, and memory structures. Implementation details for several graphics operations and the standard-library routines were not sampled.
Main entry points: core.go Graphics operations · main.go CLI entry · tokenizer.go Tokenizer · vm.go VM lifecycle
Components 16
VM runtime
- VM lifecycle
internal/vm/vm.go - Import expansion
internal/vm/core.go - Instruction dispatch
internal/vm/vm.go - Core operations
internal/vm/core.go - Stack and variables
internal/vm/mem/mem.go - Core instruction set
internal/vm/core/Instructions.go
Graphics output
- Graphics operations
internal/vm/core.go - Graphics instruction set
internal/vm/ggwrapper/Instructions.go - gg drawing library
- Saved image
Assembly libraries
- Assembly program
- Math routines
std/math - Example programs
examples/core
Other components
- Assembly user
Connections 19
- Assembly user → CLI entry: runs file
main.go - CLI entry → Tokenizer: tokenizes source
main.go - CLI entry → VM lifecycle: starts VM
main.go - VM lifecycle → Import expansion: expands imports
internal/vm/vm.go - VM lifecycle → Instruction dispatch: steps tokens
internal/vm/vm.go - Instruction dispatch → Core operations: dispatches core
internal/vm/vm.go - Instruction dispatch → Graphics operations: dispatches graphics
internal/vm/vm.go - Core operations → Stack and variables: reads and writes
internal/vm/core.go - Graphics operations → Stack and variables: uses stack
internal/vm/core.go - Tokenizer → Core instruction set: loads commands
internal/vm/tokenizer/tokenizer.go - Tokenizer → Graphics instruction set: loads commands
internal/vm/tokenizer/tokenizer.go - Core operations → Core instruction set: executes opcodes
internal/vm/core.go - Graphics operations → Graphics instruction set: executes opcodes
- Graphics operations → gg drawing library: draws with
README.md - Graphics operations → Saved image: saves output
README.md - Assembly program → CLI entry: provides source
main.go - Import expansion → Math routines: imports routines
README.md - Import expansion → Assembly program: expands imports
- Example programs → Assembly program: contains programs