Code Monkey home page Code Monkey logo

6502's Introduction

6502 Emulator

A minimal, single-stepped and beginner friendly 6502 emulator written in C using ncurses for graphics.

thumbnail

DISCLAIMER

This main goal of this project is to understand how CPUs works by directly emulating one and to debug it by single stepping instructions. The code is meant to be readable and understandable, a lot of things could be done better, especially the graphics.

The emulator only shows you what's going on under the hood of a 6502 CPU, without displaying stuff graphically (you will only see hex digits). The example program simply caluclates 10*3 and it's not optimized.

Run

You must have ncurses installed on your machine. This project was developed in a Linux environment.

make
./bin/emulator.out

Or you can run the shortcut script

bash run.sh

Loading a custom program

By default, the emulator loads example.bin. If you want to load a custom binary file, just provide the path as the second argument while launching the emulator:

./bin/emulator.out your_binary_here

Code style

The paradigm I've chosen is modular programming, especially because this is C. System components aren't defined in a OOP way.

Everything is very verbose with a lot of comments.

Design

The project is divided in multiple components:

  • cpu: here you will find the CPU itself, including main methods to interact with the memory
    • instructions handler: here we handle OP codes
  • mem: pretty simple memory implementation, each page has a dedicated array
  • peripherals
    • interface: everyhting ncurses related
    • keyboard handler: listener for key presses

Dump feature

After quitting, the program dumps its memory to a .bin file.

Example program

The loaded program multiplies 10 by 3, in order to try it you must single step instructions until you see 1E (30) in the third memory cell in the zero page. You can continue to single step it but nothing will happen.

TODO

Do you want to contribute? Here are some things that are still a WIP.

  • check for errors on cpu_fetch() calls
    • due to uint16_t always being between 0x0000 and 0xFFFF we don't have to perform extra checking while fetching memory.
  • add remaining comments to instructions.c
  • create a better interface
  • add the possibility to load custom programs

References

6502's People

Contributors

f0lg0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.