6502 Emulation in Computercraft (Fully working Assembler)
What is 6502?
6502 is an older CPU running off an 8bit Assembly language, most commonly used in the 80s
It was soo common, even the Terminator was programmed on it!
The main reason I choose to emulate the 6502 language onto CC was that, well I really enjoy the language and
I wanted to challenge myself to see if I could even do it, with 14 days of continuous study and lots and lots of coding,
here we are!
What are the features of this program so far?
It is a fully functioning 6502 CPU, everything works to that of ~90% accuracy compared to the original, physical version.
Individual features - Multiline Execution, Assembler with label, variables and Decimal Coded Byte support, Syntax Interpreter and Graphical Execution, The entire 6502 Assembly OpCodes.
Memory Specs
The memory method I use utilizes the string.char library to store 1 byte per virtual emulated byte.
Memory - 64K
Stack - 256B
Screen memory - 792B (0200 to 0990, counting end and start indexes.)
Key input - $FF
Random generator - $FE
Each address of the memory is an index divisible by 16, as 16 bytes are used per index, the remainder of this number becomes the memory offset.
Bug Testing
As there are 148 different instruction modes in 6502, I am going to need some help testing if they all work the way they are intended,
if any bugs are found, please post about them below!
Download: pastebin get jEtwni5z 6502
Editor: pastebin get 4YdqE1zS editasm
Example that features key input RNG and screen rendering: pastebin get WxMivJq5 test.asm
P.S I'm also working on getting it working with any vanilla Lua IDE!
Special thanks to, SquidDev for help with the compiler!
Tutorials:
Screenshots:
Update 6/20/17
- Some changes in optimization have broken the screen renderer, I apologize that I didn't notice that sooner, it has been fixed.
- New experimental version (qJ4rjZ8Q, has an extra run mode that is slightly faster. Also, includes an ISP (Instructions Per Second) counter.
- Found a bug with the variable char conversion that made assigning a variable a char, effectively useless, fixed that.
- Added Decimal Flag support!
- Fixed some grammar issues on this page
Edited by Lewisk3, 22 June 2017 - 12:10 PM.