Easy 6502
skilldrick.github.io
skilldrick.github.io
I love it because:
1. My first computer (an Acorn Electron) had a 6502 processor, and gave me my first exposure to assembler.
2. It's been built so you can do all the exercises in the browser. I really like stuff like this (e.g. Scrimba), as it makes it so much more likely that you'll get started.
A related point: as I go through it, I'm thinking about which instructions are really necessary (maybe all of them?) and why it would be inconvenient if you didn't have a particular instruction.
https://en.wikipedia.org/wiki/One-instruction_set_computer
There is even ZISC:
https://en.wikipedia.org/wiki/No_instruction_set_computing
Check out brainfuck if you are into stuff like this.
I wonder, can Turing machine count as "Zero Insturction Set"? Technically there is no sequence of instructions.
I think this article describes it better than I could and I get why they chose that name:
It seems to program with such a reduced instruction set requires one to be either a genius or a computer (i.e. generated code). I'm neither :(
For instance:
https://github.com/arthaud/c2bf
It seems like this is a frivolous subject, but it is actually quite enlightening to realize just how little is required to get something that computes, it changes how you view the whole concept of computation.
The ones added in the 65C02 offer some insight there, a very brief overview from the Wikipedia page:
https://en.wikipedia.org/wiki/WDC_65C02#New_and_modified_ins...
Somewhat related and mentioned in one of the comments downthread, you can view Woz's SWEET16 as a 'the 16 bit CPU a 6502 system designer and programmer wished they had' take.
[0] https://www.masswerk.at/6502/6502_instruction_set.html#illeg...
For example, STX. You could emulate it with PHA, TXA, STA, PLA.
But overall, you are correct that the 6502 was extremely primitive in various ways, especially compare to the 8080 and followers.
BIT isn't super useful and is generally used to allow multiple entry points into a subroutine with slightly different starting instructions, not something it was intended for and not really needed.
There's a few instructions that aren't used that often unless you're being really hacky:
- RTI isn't something you'll normally be using unless you're writing an IRQ handler.
- TSX/TXS are only for changing the stack pointer, not a usual thing but might be used at times.
[0]https://8bitworkshop.com/v3.9.0/?platform=vcs&file=examples%...
They are incredibly fascinating!
https://archive.org/details/a2_Visible_Computer_v1.0_1982_12...
It's far too ancient to be of anything but historical interest now but it does run on a 6502.
I thought x86 was pretty dang fun.
Arm v8 seems to have fixed some of the arm v7 cruft -- what do YOU not like about arm?
My 2nd favorite is Z80 -- that also had 'automatic' move-a-string instruction (LDIR / LDDR). 8051 is OK. Z8 is OK. And MSP-430 is pdp-11esque.
I find it difficult to read, it's aesthetics mostly, not necessary an architectural thing as such, the choice of mnemonics, why "ubfx", what's "rsb" - have to lookup these things constantly when I need them, while 6502 or x86 I can just open and read after all those years.
But that's just a personal preference certainly - yeah, I was fine with the abovementioned LDIR on Z80, heh.