mano
An assembler and simulator library for the Mano Machine RISC CPU, as described in "Computer System Architecture" by M. Morris Mano.
See github.com/husmus00/mano-rs for examples of CLI, TUI, and web-based Mano Machine simulators built using this library.
Features
- Assembler: Compiles Mano assembly language to machine code
- CPU Simulator: Executes assembled programs instruction by instruction
- State Inspection: Access CPU registers and memory at any point
- Message System: Collect informational, debug, and error messages during execution
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Quick Start
Building a basic simulator requires only three methods: prime(), tick(), and get_state().
use ;
API Overview
Machine
Machine::new()- Create a new machineprime(program: Vec<String>) -> Messages- Assemble and load programtick(messages: &mut Messages)- Execute one instruction cycleis_halted() -> bool- Check if CPU is haltedget_state() -> MachineState- Get current CPU and memory stateget_assembled_program() -> &[String]- Get assembled hex code
Messages
Messages::new()- Create message containerhas_errors() -> bool- Check for error messagesinfo(message: &str)- Add info messagedebug(message: &str)- Add debug messageerror(message: &str)- Add error message
MachineState
Contains CPU registers and memory snapshot:
program_counter,accumulator,instruction_registeraddress_register,data_register,extend_registersequence_counter,is_halted,is_runningmemory_snapshot- First 32 words of memory
Supported Instructions
Memory-Reference: AND, ADD, LDA, STA, BUN, BSA, ISZ
Register-Reference: CLA, CLE, CMA, CME, CIR, CIL, INC, SPA, SNA, SZA, SZE, HLT
Input-Output: INP, OUT, SKI, SKO, ION, IOF
Pseudo-Instructions: ORG, DEC, HEX, END
Notes
Input functionality is planned but not yet provided.
License
Licensed under the MIT License.
References
"Computer System Architecture" by M. Morris Mano (3rd Edition).