maxpoletaev / 6502

MOS 6502 CPU emulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ—Ώ 6502

MOS 6502 CPU emulator made for fun.

Current status

βœ…ADC βœ…AND βœ…ASL βœ…BCC βœ…BCS βœ…BEQ βœ…BIT βœ…BMI βœ…BNE βœ…BPL βœ…BRK βœ…BVC βœ…BVS βœ…CLC
❌CLD βœ…CLI βœ…CLV βœ…CMP βœ…CPX βœ…CPY βœ…DEC βœ…DEX βœ…DEY βœ…EOR βœ…INC βœ…INX βœ…INY βœ…JMP
βœ…JSR βœ…LDA βœ…LDX βœ…LDY βœ…LSR βœ…NOP βœ…ORA βœ…PHA βœ…PHP βœ…PLA βœ…PLP βœ…ROL βœ…ROR βœ…RTI
βœ…RTS βœ…SBC βœ…SEC ❌SED βœ…SEI βœ…STA βœ…STX βœ…STY βœ…TAX βœ…TAY βœ…TSX βœ…TXA βœ…TXS βœ…TYA

The Virtual Machine

A CPU on its own is pretty useless. Because of that, the project comes with a basic virtual machine to play around with. It works at 1MHz and connects the CPU to 64K of RAM and memory-mapped stdout area that can be used to print something to the terminal.

The overall memory layout looks like this:

  +---------------------+
  |   0x0000 - 0x00FF   |
  |      Zero Page      |
  +---------------------+
  |   0x0100 - 0x01FF   |
  |        Stack        | <- Stack Pointer
  +---------------------+
  |   0x0200 - 0x02FF   |
  |       Stdout        |
  +---------------------+
  |                     | <- Reset Vector
  |                     |    (your program starts here)
  |                     |
  |   0x0300 - 0xFFFF   |
  |     ROM memory      |
  |                     |
  |                     |
  |                     |
  +---------------------+

There are several examples of programs in the programs directory that can be compiled using xa65 assembler and then executed as mos6502 hello_world.

Unfortunateley, there are no debugging tools at the moment, so println! is your friend.

Resources

About

MOS 6502 CPU emulator


Languages

Language:Rust 99.2%Language:Assembly 0.8%