A simple to use 6502 simulator, featuring a code editor, keyboard input and a display!
- 32kiB of RAM and ROM
- 120x80 display
- Date and time in RAM
- Keyboard and mouse input
- Frequency selector in the range of 1Hz to 1GHz
┌───────────────┐
│ │ 0x0000
│ Zero Page │
│ │ 0x00FF
├───────────────┤
│ │ 0x0100
│ Stack │
│ │ 0x01FF
├───────────────┤
│ │ 0x0200
│ RAM │
│ │ 0x7FFF
├───────────────┤
│ │ 0x8000
│ ROM │
│ │ 0xFFF9
├───────────────┤
│ NMI Vector │ 0xFFFA
│ (unused) │ 0xFFFB
├───────────────┤
│ RES │ 0xFFFC
│ Vector │ 0xFFFD
├───────────────┤
│ IRQ Vector │ 0xFFFE
│ (unused) │ 0xFFFF
└───────────────┘
The Zero Page is still considered as RAM. The main difference between the two is that the zero page uses less cycles to compute memory read and/or write operations.
The RAM is then subdivided as below:
┌───────────────┐
│ │ 0x0200
│ Display │
│ │ 0x277F
├───────────────┤
│ Time Control │ 0x2780
├───────────────┤
│ Year (LO) │ 0x2781
│ Year (HI) │ 0x2782
├───────────────┤
│ Month │ 0x2783
├───────────────┤
│ Day │ 0x2784
├───────────────┤
│ Hours │ 0x2785
├───────────────┤
│ Minutes │ 0x2786
├───────────────┤
│ Seconds │ 0x2787
├───────────────┤
│ Milli (LO) │ 0x2788
│ Milli (HI) │ 0x2789
├───────────────┤
│ Keyboard │ 0x278A
├───────────────┤
│ Mouse X │ 0x278B
├───────────────┤
│ Mouse Y │ 0x278C
├───────────────┤
│ Mouse Input │ 0x278D
├───────────────┤
│ │ 0x278E
│ RAM │
│ │ 0x7FFF
└───────────────┘
The year and the milliseconds data is stored as little-endian, as stated in the picture above.
If more RAM is needed, the display space could be used without any problem. The date and the input section cannot be used for this purpose.
The keyboard input only works when the code editor is not focused.
The time control byte is used to precisely read the time. When that byte is set to 0x02, the data is ready to be read. The user must then write 0x01 to that address, so, the engine won't update the data. After reading it, the user must to clear the first bit (write 0x00 is suggested), so, the engine will update the data and write 0x02 again.
You may read time and input examples for a pratical use.
When the play button is pressed, the 6502 will read the data in the address 0xFFFC and 0xFFFD (RES Vector).
The resulted address will give the entry point of your program (see examples or the minimal code).
Multiple byte data is stored in little-endian, so, the address 0x1234 will be stored the RAM as 0x34 and 0x12
The 6502 features 3 general purpose 8 bit registers, called A (accumulator), X and Y.
The Program Counter is a 16 bit register, called PC, used to point at the instruction in the ROM.
There are also two more 8 bit registers, the S and P registers, which they are used to
point to the next free slot in the stack (0xFF at startup, downwards) and to contain
the flags used for comparisongs and branching, respectively.
MSB LSB
┌───┬───┬───┬───┬───┬───┬───┬───┐
P = │ N │ V │ - │ B │ D │ I │ Z │ C │
└───┴───┴───┴───┴───┴───┴───┴───┘
N: Negative resultV: OverflowB: BRK instructionD: Decimal modeI: IRQ disable (unused)Z: zero resultC: Carry = !Borrow
For a complete list of the implemented intrinsics, you may look at this cheatsheet
- Download the most recent version from this repository
- Enjoy!
- Open the simulator
- Create a file on your pc
- Drag and drop the file on the simulator
- Start editing and compiling the file
.org $8000
init:
; your code here!
.org $FFFC
.word init
.word $0000
- display
- keyboard input
- date in memory
- fix / improve 6502 engine
- render and gui revamp
- options panel + save configurations to file
- code editor instead of code viewer
- panel for the 6502 instruction set
- use an internal 6502 compiler
- error handling
I don't like the way the license system works, so instead of searching for a license that satisfies me, I'm making my own version.
You can keep the source code on your devices; you may compile it and use it for private or public use. If you modify it, you have to explicitly state that you possess an altered version of the software.
Even if you've modified it, I don't want you to use this product for commercial use or to distribute it under your name; I put a lot of effort on this project, for learning purposes and to allow everyone to use a 6502 simulator to learn assembly in the easiest possible way.
Questions? Bugs? Ideas? Something is not clear? Feel free to contact me on Discord @quattromusic!
Join my server for the latest news.
![[image]](https://raw.githubusercontent.com/QuattroMusic/6502-Simulator/main/_data/6502.png)
![[video]](https://raw.githubusercontent.com/QuattroMusic/6502-Simulator/main/_data/hello_6502.gif)