How omarandlorraine/fake6502 works
Project type and purpose
• This is an open‐source C library and test harness that emulates a 6502‐style CPU (with NMOS, 2A03, and added CMOS support).
File structure
• Top-level files:
• fake6502.c / fake6502.h – the emulator core
• tests.c – the command-line test harness
• Makefile – build and test targets
• .github/workflows/c-cpp.yml – CI pipeline definition
• No “frontend/backend” split; this is a single library + harness.
• Build targets: compile emulator into an object or static library, link tests, run coverage.
README for insights
• Describes core modifications: passing a CPUState pointer for multiple concurrent emulators.
• Notes on supported CPU variants (6502, 2A03, CMOS extension).
• Mentions ~90% test coverage of documented NMOS instructions and the fact that this repo is “dead.”
Main components and their interactions
a. Emulator Core Module
• fake6502.c / .h implement:
– CPUState struct (registers, flags, memory pointer)
– Fetch–Decode–Execute loop
– Opcode implementations for each variant (NMOS, 2A03, CMOS)
b. CPU State Abstraction
• A data structure passed into core functions allowing multiple instances
c. Test Harness (tests.c)
• Instantiates one or more CPUState instances
• Loads test vectors, steps the emulator, asserts expected register/memory state
d. Build System & CI
• Makefile targets: “all”, “test”, “coverage”
• GitHub Actions workflow: checkout, build, run tests, collect coverage
e. External Dependencies
• Standard C library only (no third-party libraries)
Architectural patterns and design principles
• Modular core + state separation for reentrancy and concurrency
• Data-driven opcode table dispatch in fake6502.c
• Thin harness layer encapsulates test logic and assertions
• Continuous integration ensures regression safety