Some time ago, I decided to create a CPU emulator in order to better understand how these work.
This emulator is built as a C library.
- Include the emulator header
#include "6502_emulator.h"
- Initialize the library
cpu_library_init();
- Create and set the CPU's IO functions
cpu_read_byte = read_byte;
cpu_write_byte = write_byte;
- Reset the CPU
cpu_reset();
- Make the CPU run
while(1) {
cpu_clock();
}
- This website contains information about architecture, registers, instructions and addressing modes.
- I also used some of the information present in this book to make sure that the emulator behaves correctly.