Expand description
LC3 Memory Module
This module implements the memory system for the LC3 (Little Computer 3) Zero-Knowledge Virtual Machine.
§Design
- The LC3 uses a 16-bit address space, allowing for 65,536 (2^16) memory locations.
- Each memory location stores a 16-bit word.
- The memory is implemented as a fixed-size array of 65,536 16-bit unsigned integers.
- Memory operations include reading, writing, and clearing.
- The module implements the
Index
andIndexMut
traits for convenient array-like access.
§Usage
Create a new memory instance:
use lc3_zkvm::memory::Memory;
let mut memory = Memory::new();
// Read from and write to memory:
memory.write(0x3000, 0x1234);
let value = memory.read(0x3000);
// Use array-like indexing:
memory[0x3000] = 0x5678;
let value = memory[0x3000];