How benaliossama/vm works
Project type and purpose
• This is a Corewar game implementation in Rust, consisting of two collaborating tools:
• An Assembler that translates .s files into .cor binaries
• A Virtual Machine (VM) that loads .cor players into a circular memory arena and executes them cycle by cycle
• The user’s focus is on the VM; the Assembler is a separate component (see playground/asm_ref)
File structure
• Top-level:
• Cargo.toml / src/…: Rust project defining the VM’s code (arena.rs, vm.rs, instructions.rs, process.rs, etc.)
• Makefile & README.md: build and run instructions
• playground/: test harness containing reference assembler (playground/asm_ref), reference VM (playground/vm_ref), sample players (playground/players_src) and helper scripts
• src/ directory follows a modular layout:
• arena.rs – circular memory manager
• process.rs, player.rs – process & player state
• instructions.rs, counter.rs – decoding & parameter counting
• vm.rs, utils.rs, config.rs – overall VM orchestration, configuration, utility functions
• No external dependencies beyond Rust std; testing is via sample .cor files and scripts in playground/
README for additional insights
• Confirms core modules: memory management, processes, instruction decoding, scheduling, lifecycle checks
• Make targets: make run launches VM with sample players
• todo.md tracks progress on missing instructions, features
Final advice
• Ring buffer nature of the arena and the cyclical scheduler
• Do not overcomplicate: clarity and separation of core subsystems (Loading, Memory, Execution, Scheduling) is key