Skip to content

nopsteam/6502

Repository files navigation

6502 Emulator CI codecov

6502

What's a 6502?

It was the CPU of choice for the very first mass market home computers and so, played a central role in the home computer revolution.
It was the brain of the first computers from Apple, Commodore, Acorn, and Atari. It ran the Atari 2600 game console, and its core was incorporated into the central processor of Nintendo's NES.

Compiling / Building

Installing Dependencies

Arch Linux

yay -Sy clang cmake lcov glfw libx11 libxcursor libxinerama libxrandr vulkan-headers xorg-server-devel xorg-xinput

Ubuntu

sudo apt-get install clang cmake lcov libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev

Usage

Setup

This will build cmake files and download dependencies

make setup

Build

# Debug build
make debug
# Release build
make release

Run Tests

This will build and run unity tests

make test

Code Coverage Checks

This will build and run unity tests and generate reports for coverage (depends on lcov)

make coverage
# This part is optional: Generates a html with more coverage details
genhtml build/coverage/coverage.info --output-directory build/coverage/out

Clean

This will delete generated files for debug and release

make clean

Run Binary

# Debug bin
./build/debug/bin/6502
./build/debug/bin/6502_disasm
# Release bin
./build/release/bin/6502
./build/release/bin/6502_disasm

Simulator

This emulator is based on Easy6502, all ASM examples in easy6502 website should run fine in our implementation.

Compiling ASM

You need to install C65 in your machine, create a file with the ASM you want to compile and run the following command:

cl65 -t none test-program.asm

This will compile and link a binary with your code, to run this in your emulator you need to:

./build/release/bin/6502 <path-to-your-bin>/test-program fps-as-int

You can find some precomiled examples in the resource folder.

State

Implemented OPCODES

  • 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

License

This is free and unencumbered software released into the public domain For more information, please refer to http://unlicense.org/