Skip to content

Repository files navigation


A MOS 6502 CPU emulator build in Rust


Note

A Nerd Font is strongly recommended in your terminal emulator for proper rendering of UI icons.

What is the MOS 6502

The MOS 6502 is an 8-bit microprocessor that was designed by a small team led by Chuck Peddle for MOS Technology [...].

When it was introduced, the 6502 was the least expensive microprocessor on the market by a considerable margin. It initially sold for less than one-sixth the cost of competing designs from larger companies, such as the 6800 or Intel 8080. Its introduction caused rapid decreases in pricing across the entire processor market. Along with the Zilog Z80, it sparked a series of projects that resulted in the home computer revolution of the early 1980s.

Source: Wikipedia


asciicast


Home

Settings

Running

Core Features

Emulator

  • Virtual Screen: A 32x32 pixel screen using the Unicode half-block character with a custom color palette.
    • Color Palette: Supports 16 custom colors. For more information, see the Color List.
  • Flags Container: Displays the status flags ($N, V, D, I, Z, C$), highlighting active flags in bright green.
  • Register Container: Live tracking of registers ($AC, XR, YR, SP$).
  • Stack Viewer: A scrollable list showing stack addresses and values, with the current stack pointer highlighted.
  • Memory Viewer: A hexadecimal grid tracking system memory layout, complete with vertical scrolling.
  • Disassembly Program Viewer: Automatically disassembles loaded ROM bytes into opcodes and functions (with indented code and labeled addresses). Includes a scrollbar.
  • Settings Menu: Adjustable CPU speed settings and repository links.
  • Footer Bar: Quick reference guide for keyboard shortcuts and controls.

Home Menu

  • File Browser: Lists files and folders present in the current directory, enhanced with Nerd Font icons.
  • Start Address: Automatically detects files ending with _demo.bin and configures the start address to 0xC000.
  • Emulation Speed: Adjusts the Hz / MHz target.

Built with...

This project was built to help me learn Rust while using my emulator knowledge. Here is wh

  • Rust: for the whole app ! ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧
  • Ratatui: to create a nice looking TUI
  • ca65: to compile the ASM code
  • ld65: to link the .o file into a .bin file

Installation & Quick Start

The easiest way to get the emulator is to install it directly via crates.io using Cargo:

cargo install rust6502

Tip

To fully test the emulator, download the demo .bin files attached to the Github Release !

  1. Just run rust6502 and use the built-in File Explorer to navigate to your .bin files and press Start

ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧

Implemented Demo Programs:

Rainbow

Hello World !

Hackclub Logo

Stardance Devlogs ᕙ( •̀ ᗜ •́ )ᕗ

On Stardance you can watch the full development process via all the devlogs I've created here: Rust 6502 Devlogs

Development

Important

You must have Rust and Cargo installed on your computer

Dependencies

Building Rust-6502 from source

  • Clone the repository with
git clone https://github.com/wirenux/Rust-6502.git
cd Rust-6502
  • Then install the dependencies and run the program with:
cargo run

Test & Validation

To build custom assembly files without error (handling proper memory origin segments and interrupts), it is recommended to use the cc65 toolchain (ca65 for assembly and ld65 for linking):

ca65 program.s -o program.o
ld65 program.o -C linker.cfg -o program.bin

To verify instruction behavior and debugging assembly routines I have used the Masswerk 6502 Assembler & Emulator

Documentation

For more information about the emulator subsystem, check out the dedicated documentation:

Boring Stuff

Use of AI

  • Writing small ASM programs during development to test CPU behavior, and brainstorming.

Credits

This project is created by @wirenux in Rust and use Ratatui.

License

This project is release under the MIT License.

About

A MOS-6502 emulator build in Rust

Topics

Resources

Stars

Watchers

Forks

Releases

Contributors

Languages