This project is a simple 6502 CPU emulator written in C. The goal is to understand how the 6502 processor works by implementing its core functionality and executing tests to validate the behavior.
src/
: Contains the source code for the emulator.include/
: Contains the header files.obj/
: Stores the compiled object files.bin/
: Stores the final compiled binary (main
).tests/
: Contains unit tests for the emulator.tests/bin/
: Stores the compiled test binaries.
This project requires:
- A C compiler (e.g.,
gcc
). - GNU Make (for building the project).
- Criterion (a C testing framework).
Install the dependencies with:
sudo apt-get update
sudo apt-get install -y gcc make libcriterion-dev
Install the dependencies with Homebrew:
brew install gcc make criterion
The project uses a Makefile
to simplify the build process.
Run the following command to compile the emulator:
make all
The compiled binary will be located in the bin/
directory:
bin/main
To run the emulator:
./bin/main
The Makefile
also provides a test
target to compile and execute the unit tests. To run the tests:
make test
The tests are compiled into the tests/bin/
directory, and each test binary is executed sequentially.
To clean up all compiled files:
make clean
https://cx16.dk/6502/reference.html
https://www.masswerk.at/6502/6502_instruction_set.html
https://en.wikibooks.org/wiki/6502_Assembly
https://www.youtube.com/playlist?list=PLLwK93hM93Z13TRzPx9JqTIn33feefl37