$ PHP-6502 Emulator
A fully functional 6502 microprocessor emulator written in PHP and distributed as a Composer library. Build custom 6502-based systems with two distinct CPU core implementations — the original MOS 6502 and the enhanced WDC 65C02.
install
composer require andrewthecoder/6502-emulator ### features
- - Dual CPU Variants — MOS 6502 (56 instructions) and WDC 65C02 (70 instructions)
- - Hybrid Execution — JSON-driven instruction definitions with custom PHP handlers
- - Interrupt Support — NMI, IRQ, and RESET with proper edge/level triggering
- - CPU Monitoring — Built-in debugging tools with instruction tracing and cycle counting
- - Full Documentation — Comprehensive PHPDoc annotations for IDE support
### usage
The emulator is designed to be embedded in your own projects. To build a custom 6502-based system:
- Create a custom bus class implementing
BusInterface - Instantiate your preferred CPU variant (
MOS6502orWDC65C02) - Load machine code and call
executeInstruction()in a loop
### project structure
src/Core/ — Shared interfaces (BusInterface, RAMInterface, etc.) src/MOS6502/ — Original 6502 CPU implementation src/WDC65C02/ — Enhanced 65C02 CPU variant tests/ — Unit test suite ### development
./vendor/bin/phpunit — Run tests ./vendor/bin/phpstan analyse src — Static analysis ### learn more
Full documentation, examples, and detailed instructions are available in the README.