Skip to content

An emulator for the MOS Technology 6502 microprocessor

Notifications You must be signed in to change notification settings

viktaur/mos-6502

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MOS 6502 emulator

The MOS Technology 6502 is an early 8-bit microprocessor introduced in 1975. It consists of only a few internal registers, 56 instructions with multiple addressing modes, and 64 KB of memory space (using 16-bit address words).

Given its relatively simple design, the 6502 is a fantastic architecture to learn how CPUs actually work and how they can be emulated.

6502 processor in a DIP-40 plastic package

6502 processor die with drawn-in NMOS transistors and labels hinting at the functionality of the 6502's components

Instruction set

The following is the complete set of instructions supported by the 6502 and whether they have been implemented in this project yet.

Load/Store operations

Register Transfers

Stack Operations

Logical

Arithmetic

  • ADC - Add with Carry
  • SBC - Subtract with Carry
  • CMP - Compare accumulator
  • CPX - Compare X register
  • CPY - Compare Y register

Increments & Decrements

Shifts

  • ASL - Arithmetic Shift Left
  • LSR - Logical Shift Right
  • ROL - Rotate Left
  • ROR - Rotate Right

Jumps & Calls

Branches

  • BCC - Branch if carry flag clear
  • BCS - Branch if carry flag set
  • BEQ - Branch if zero flag set
  • BMI - Branch if negative flag set
  • BNE - Branch if zero flag clear
  • BPL - Branch if negative flag clear
  • BVC - Branch if overflow flag clear
  • BVS - Branch if overflow flag set

Status Flag Changes

System Functions

Contributing

This project is a great opportunity for intermediate to advanced Rust developers, as well as more experienced developers coming from a C/C++ background who are interested in learning Rust. It is not only a fun challenge, but will also help you understand the low-level logic that drives everyday devices at a foundational level.

To get started, it would be helpful to compare the existing implementations in this codebase with the instruction set reference. Understanding these implementation patterns will make it easier to learn and write the remaining parts of the instruction set. Another way of helping is by writing more unit tests, with the aim of having at least one test per opcode.

If you're interested in making a contribution, please feel free to open a PR :) !

References

About

An emulator for the MOS Technology 6502 microprocessor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages