247 points · by whobre · 1y ago · 289 comments
The 68000 has more registers and wider data types: but the registers are all uniformly the same. It's really just two registers A and D, copied a bunch of times in to D0 to D7, and A0 to A7. Whatever you can do with D0 can be done with D3 and so on. Some A's are dedicated, like for a stack pointer.
Simplicity of structure has to be balanced with simplicity of programming.
It's not that easy to program the 6502, because in moderately complex programs, you're constantly running into its limitations.
The best way to learn how to hack around the limitations of a tiny machine is to completely ignore them and become a seasoned software engineer. A seasoned engineer will read the instruction set manual in one setting, and other pertinent documents, and the clever hacks will start brewing in their head.
You don't have to start with tiny systems to get this skill. When you're new, you don't have the maturity for that; get something that's a bit easier to program with more addressing modes and easier handling of larger arrays, more registers, wider integers.
6502 is fun and neat, especially if you want to program those machines. If you want more modern approach, it's not really all that suitable. Do what we did in the 90's then and start with MIPS if you want to follow the path of glory days or just start out with Neon. I'd even argue Z80 with all its registers and complexities is more similar to what you'll find today (far from it, but let's entertain the connection between past and present as OP does).
There's nothing inherently complicated about modern asm. Take FASM, start. It's not complicated, but it gets complex rather quickly which was and will be always true for such low level approach. Then you start macroing and sooner or later you have your own poor man's C on top.
But again Z80 looks like a very good option too because it has GB/GBC plus ZX Spectrum. The same goes to 68K -- Mac 68K, Sega Genesis and Neogeo are popular hits.
When I was writing my reply to another question (https://news.ycombinator.com/item?id=42891200), I was thinking about a new software engineering education system which starts from a retro platform and goes up from there. Maybe all three can fit the bill. I'm very much against the "elegant/pure" way of teaching.
BTW totally agree 6502 essentially has 3 registers. You don't get to touch the others.
This shouldn't be discounted, since it has great pedagogical value in itself. On the other hand, personal opinion here, is that not many things are transferable to modern ISAs. Even back in the 90's, we were shown to work on MIPS instead. 68k is very nice to read and write, almost feels like higher language, but overall ROI for newer stuff is maybe just jump into Neon, x86_64, or as someone said RV directly. It's not _THAT_ hard. It gets complex as programs grow though.
Practically anything non-trivial uses those zero page addresses as extra registers.
Of course they all are technically registers, but they really can't be used for anything useful the way the index registers and accumulator can
Learning to hack around the limitations of a tiny machine is a good step toward becoming a seasoned software (and possibly hardware) engineer!
The advantage of tiny systems is that you can understand them completely, from silicon to OS to software.
The 6809 is simpler than the 68K, and more powerful and orthogonal than the 6502, but there isn't the same software base for it. I think Motorola was onto something with the 6809 and 68K instruction sets and programmer-facing architecture. IIRC PDP-11/VAX and NS32K are similarly orthogonal.
It’s a shame that Tandy missed the boat on including coprocessors for game support in their computers, especially that one. If they’d just included decent audio and maybe something for sprite management it would’ve been highly competitive.
Atari 800 featured powerful video processing with display lists and sprites, 4-channel audio, etc., but was much less successful.
As I understand it, Radio Shack did not encourage third-party software and support for its systems, not realizing that it was the key to success.
OS-9, originally a 6809 OS, seems to have survived for quite some time.
(Unless you want to really dive into "how can I work around limitations", and then you pick an F8 and pull your hair as much as you like)
MC68k just has tons of quirks which aren't really going to be relevant in the modern day and age. (About the only thing it has going for it is the huge variety of hardware platforms that happened to make use of it, many of which still have thriving retro communities around them. But that's more of a curiosity as opposed to something genuinely relevant.)
Using RISC-V for executing programs written in high-level programming languages is fine. It should be noted that in the research papers that have coined the name RISC, where there was a list of properties defining what RISC means, one of them was that RISC ISAs were intended to be programmed exclusively in high-level languages and never in assembly language. From this point of view, RISC-V has certainly followed the original definition of the term RISC, by making the programming in assembly language difficult and error prone.
On the other hand, learning assembly programming with RISC-V is a great handicap because it does not expose the programmer to some of the most fundamental features of programming in an assembly language, because RISC-V does not have even many features that existed in Zilog Z80 or in vacuum-tube computers from 70 years ago, like integer overflow detection and indexed addressing.
Someone who has learned only RISC-V has an extremely incomplete image about how a normal instruction set architecture looks like. When faced with almost anyone of the several thousands of different ISAs that have been used during the last three quarters of a century a RISC-V assembly programmer will be puzzled.
6502 is also too quirky and unusual. I agree that among the old ISAs DEC PDP-11 or Motorola MC68000 are better ISAs for someone learning to program in an assembly language from scratch. Writing assembly programs for any of these 2 is much simpler than writing good assembly programs for RISC-V, where things as simple as doing a correct addition are quite difficult (by correct operation I mean an operation where any errors are handled appropriately).
I also agree the 6502 is not a simple ISA. However after learning 6502 machine code, MIPS, AVR, and ARMv6-M were all easy to learn.
RISC-V is simply the best ISA I've ever used. It's got everything you need, without unnecessary complexity.
> RISC ISAs were intended to be programmed exclusively in high-level languages and never in assembly language.
That's a misunderstanding. RISC was designed to include only the instructions that high level language compilers found useful. There was never any intention to make assembly language programming difficult.
Some early RISC ISAs did make some of the housekeeping difficult for assembly language programmers by for example having branch delay slots, or no hardware interlocks between things such as loads or long-running instructions such as multiple or divide and the instructions that used their result. So if you counted wrong and tried to access the result register too soon you probably silently got the previous value.
That all went completely out the window as soon as there was a second implementation of the same ISA with a different number of pipeline stages, or more of less latency to cache, or a faster or slower divide instruction. And it was just completely untenable as soon as you got CPUs executing 2 or 3 instructions in each clock cycle instead of 1. The compiler could not calculate when it was safe to use a result because it didn't know what CPU version the code would be running on.
Modern RISC -- anything deigned since 1990 -- is completely fine to program in assembly language.
Scaled indexed addressing is useful in 80386 and successors only because they lack general support for addressing modes with register update, and also because they have INC/DEC instructions that are one-byte shorter than ADD/SUB, so it is preferable to add/subtract 1 to an index register, instead of adding/subtracting the operand size.
Scaled indexed addressing allows the writing with a minimum number of instructions of some loops where multiple arrays are accessed, even when those arrays have elements with different sizes. When all array elements have the same size, non-scaled indexed addressing is sufficient (because you increment the index register with the common operand size, not with 1).
However there are many loops where scaled index addressing is not enough for executing them with a minimum number of instructions, while using post-incremented/pre-decremented addressing still allows the minimum number of instructions (e.g. for arrays of structures or for multi-dimensional arrays).
Unfortunately not even MC68020 has complete support for auto-incremented addressing modes, because besides auto-incrementing with the operand size there are cases when one needs auto-incrementing with the increment in a register, like provided by CDC 6600, IBM 801, ARM, HP PA-RISC, IBM POWER and their successors (i.e. when the increment is an array stride that is unknown at compile-time).
On x86-64, using scaled indexed addressing is a necessity for efficient programs. On the other hand on ISAs like ARM, which have both scaled indexed addressing and auto-indexed addressing, it is possible to never use scaled indexed addressing without losing anything, so in such ISAs scaled indexed addressing is superfluous.
This said, 65XX on an early Commodore computers was extremely rewarding to use because there was no memory protection and you could write code altering video memory, mess with sprites, fonts, borders, interrupts, write self modifying code etc etc. 68000 assembly on Amiga was more safe and controlled.
https://bitsavers.org/pdf/dec/pdp11/1120/PDP-11_Handbook_Sec...
You scale up the complexity of the programs you need to build with the complexity of the chips. In the 6502 lab it was a lot about learning the basics of how things like an MMU works and building basic ones out of TTL logic gates. In the 68k lab you take an MMU for granted and do more ambitious things with that. There's useful skills both from knowing what the low level hardware is like as intimately as a 6502 can get versus the skills from where it is easier to program because you have more modern advantages and fewer limitations.
The other thing about that order was that breadboarding the 6502 hardware was a lot more complex, but it made up for it in that writing and debugging 6502 assembly was a lot easier. There are a ton of useful software emulators for the 6502 and you can debug your code easily before ever testing it on lab hardware. At one point in that lab I even just wrote my own mini-6502 emulator specific to our (intended) breadboard hardware design. On the other side, there a lot fewer software emulators for the 68k and the debug cycle was a lot rougher. The 68k breadboard hardware was a bit more "off the shelf" so it was easier to find an existing emulator that matched our (intended) hardware design, but emulator itself was buggier and more painful to use and ultimately testing on the real hardware was the only trustworthy way to deal with it. I also wasn't going to try to write my own 68k emulator. (Though some of the complexity there was the realities of hardware labs in that the hardware itself starts to pick up its own localized quirks from being run only on breadboards for years.)
The 68000 instruction set is very C-like (probably because it draws a lot of inspiration from the PDP-11 which was C's first target). Implementing it sucks (I know from experience) because the ISA is on the large side and all the little pragmatic exceptions add up. But because these exceptions are fairly pragmatic, they're not really a big issue when writing code.
As for modern CPUs and OoO etc, that's only about performance. The CPU, no matter sophisticated, must produce exactly the same results as the simplest in-order CPU.
Hardware is never going to spill a register to RAM when you didn't write that. The maximum that is going to happen -- and this is pretty recent -- is that memory at small offsets from the SP might be treated as if it was extra registers, and this renaming can be tracked over smallish adjustments to the SP.
"You can't understand what modern CPUs do" is much overblown. Just write good clean code and it will work well on everything.
You can't do that on modern CPUs, because the nominal ISA has a very distant relationship to what happens inside the hardware.
The code you write gets optimised for you dynamically, and the machine is better at it than you are.
You may as well write in a high-level language, because the combination of optimising compilers with optimising hardware is probably going to be faster than any hand-written assembler. It's certainly going to be quicker to write.
The 68000 is a very nice, clean machine to code for, but the main point of doing it today is historical curiosity. It's quite distant from modern computing.
If you want to learn a small, yet powerful instruction set with a few quirks go for ARM v6M. It‘s still in meaningful production (no the Monster 6502 doesn‘t count), has good platform support in the latest open source toolchains (debuggers, compilers, assemblers, linkers, etc.).
If you value openness of the architecture enough to deal with a less mature platform (as of early 2025) then pick a RISC-V MCU instead. If you can‘t decide pick a RP2350 :-).
The ARMv6M instruction set is small and no loading constants doesn‘t require long winded instruction sequences if you do it as documented (PC-relative load instead of shifting in immediate data). You don‘t have to deal with self modifying code and/or the zero page to index memory. Your registers are the same width as the address space. Yes it‘s 32 bits, but that makes it simpler to learn, use and teach than all 8/16 bit and most 16 bit instruction sets I’ve seen because you don‘t have to work around to narrow registers for common operations. To anyone who thinks this sounds boring: don‘t worry ARMv6 still has enough quirks you can use for code golfing.
I started on PIC16 assembly, and dabbled in a bunch of other architectures, but my favorite in terms of cleanness has been MIPS32.
Nitpick: you can still buy new made 6502s, MCUs with 6502 cores, and peripheral chips from Western Design Center. They sell through e.g. Mouser:
https://www.mouser.com/c/?m=Western%20Design%20Center%20%28W...
The early ARM ISAs are good, as you say.
I don't think the 6502 would be a good fit because zero-page doesn't really translate to any useful modern concept. Quite a lot of 6502 coding is Zero-page management.
I went with 8 bit AVR as an instruction set for my silly fantasy console project. It has an in-browser editor and assembler to let people write 8 bit code. The AVR has the best 8-bit instruction set I have found, it's still not perfect (only loading constants to some registers) but definitely built with the hindsight provided by it's predecessors.
If you wanted to avoid the management of data types, I would suggest an instruction set with floating point registers. The same management of bytes into words and dwords, signed and unsigned etc. has to happen on a CPU without floating point support. It's an added complication, which you may or may not want to expose students to.
If the intent is to use Asm to teach from the point of view of "every instruction is a clearly defined action" I would use something with 32-bit ints and 32-bit floats.
If you wanted people to feel our pain, go with 6502, Z80, or PIC depending how sadistic you are.
What is particularly funny about your example is that 40 years later you still cant do multiplication or addition in js. You have to install packages (that are multiple computers in size!) after you make up your mind which of the 20+ different modules (read: "dependencies") has the right kind of multiplication for you! I'm not bitter, it's objectively ridiculous :)
* it should actually be c = a × b Without the asterix, we did actually have arithmetic reasonably standardized before IT de-standardized it.
But it's true that with only 8 bits, the problem happens very soon. However, if one doesn't want to solve basic problems "the hard way", one probably won't be interested in assembly programming anyway.
Granted, this extends across a wide range of assembly languages, but it'd be nice to start with a instruction set without this issue.
I can't even guess what you might be referring to.
Where it becomes "deeply flawed" is if you're trying to develop large, complex programs for it, mainly because there's no way to efficiently implement pointers or local variables -- you only have 3 registers, none of which are truly "general purpose", and none of which are wide enough to hold a pointer; and stack operations are severely limited. (This also means that writing a C compiler that targets 6502 and generates efficient code is almost impossible).
So, in idiomatic 6502 code, all variables are global; and if you need dynamically managed objects, you keep track of them using indices into statically-allocated arrays. This is difficult to scale as your programs get large and complex, because at some point you're going to waste an afternoon finding out that your "tmp7" variable in one routine is getting clobbered by another routine 5 levels deep down the call chain that also uses "tmp7" for some unrelated purpose.
It was a perfect processor for its time and its target market, but it made heavy design compromises to achieve its goals, and Moore's law quickly made those compromises obsolete.
Your overall argument is perfect, but I'd question the use of "quickly" since people were selling essentially 6502-based stuff for how long, 20 years at least? From the Apple II in 1977 to the SNES which was released in 1990 and still getting games in 1995, so that's 18 years of that CPU being highly relevant and worth learning.
Of course, you're 100% right that, assuming money was no object and you could buy and use whatever hardware you wanted to, it wasn't long before you could escape those compromises since the x86 and the 68000 (and probably others I don't know) brought much better architectures to those who could afford them.
I've coded on a bunch of embedded 8-bit platforms over the decades, and 6502 is great. A, X, Y registers - it's really quite simple. It has various standard and useful addressing modes. It has pretty much the same status register that exist in modern 8-bit MCUs. There's nothing "deeply flawed" about it.
32-bit MCUs are probably a bit too complex for a beginner, 8-bit MCUs will teach a newcomer a lot about the basics of computing in an easy to learn way. It will teach them the significance of "a byte" and working with raw data that maybe you don't exactly get with 32-bit MCUs. There isn't that much to master with a 6502, it's pretty simple, but amazing things can still be done with it.
[1] https://youtube.com/playlist?list=PLowKtXNTBypFbtuVMUVXNR0z1...
It's totally not the same thing of course. A whole lot of transistors and clock speed go to making that feat possible.
I have taught 68K, MIPS, ARM, x86, etc., and the overall good student feedback I got by teaching 6502 is mostly because of the surrounding context that comes with the CPU. The reason 6502 clicked better than other modern alternatives (MIPS, ARM, x86, etc.) was because we use it to program a real machine that is simple to understand (i.e. Nintendo Entertainment System). Rudimentary memory mapped IO, no operating system, no pipelined instructions, no delay slots, no network, no extra noise, ...it's just a simple box with a a clock inside, a CPU, some memory addresses, some helper chips, IO mapped to memory addresses, and that's pretty much it!!! So, even though I agree that the 6502 is not the simplest instruction set out there, THIS simplicity of the system helped a lot.
And about the limitations of the 6502 CPU, these limitations were also important for students to understand that these instructions have a reason to be the way they are. CPUs were designed and wired given the constraints of that time, and that reflects on how we programmed for them.
So, even thought this was mostly empirical, I have to say picking 6502 and the NES to teach beginners was successful. Once again, not really because it was the 6502, but because the 6502 forced us to go simple in terms of the sytem we were moving bits left and right.
Once students played around with the 6502 and saw NES tiles moving on the screen, then it was super cool to evolve and show them how the 68000 did things differently, and then evolve more and show how MIPS came, show how pipelining works, how to take advantage of delay slots, and being able to compare the differences of RISC and CISC. It's super simple to evolve once the basics are there.
If you like the PDP-11 then you get the same qualities slightly restricted in the MSP430 and slightly enhanced in the 68000.
But, really, just forget all those relics and learn either RISC-V (the best answer) or else one of the half-dozen Arm variations. I'm partial to ARM7TDMI myself for sentimental reasons doing a lot with it in the mid 2000s. The Thumb mode is probably slightly easier to learn than the original Arm mode, but neither is as satisfactory as RISC-V.
There's a GCC fork [0], macro11 [1] (GCC and clang also both have macro11 backends), ack [2] and more.
Getting hold of a modern compiler is trivial.
> It's kind of hard to get hold of a PDP-11 these days.
The PiDP-11 [3] emulator that runs on a Pi, is fairly popular among the retro crowd. So sourcing something hardware wise that behaves that way is easily possible.
The Computer History Simulation Project [4] will give you easy access to simulating a PDP-11 on just about anything that you own.
But if you want the original hardware, then they're in the $400-500 range, in my area. Easy to source.
[0] https://github.com/JamesHagerman/gcc-pdp11-aout
[1] https://gitlab.com/Rhialto/macro11
[2] https://github.com/davidgiven/ack
Then just get 2.11 BSD (or V7 Unix if you're a minimalist/masochist), install it, and you're free to write/run/debug all the PDP11 assembly you want.
But I do question the value of doing this. I'm a big believer in the notion that you can't train skills by proxy, so if your goal is to become proficient in writing assembly for modern architectures, then you might as well do so by learning a modern architecture.
I rewrote EMPIRE into PDP-11 assembler.
But DEC spurned that opportunity, while IBM took it over with the clumsy 8086 instruction set.
There's no purpose to learning the -11 anymore.
It's very utilitarian and most commonly just used for debugging and reverse engineering. So why would you waste time on the assembly language of a long-obsolete platform?
Plus, the best way to learn assembly is to experiment. Write some code in your favorite language and look at the intermediate assembler output, or peek under the hood with objdump or gdb. Try to make changes and see what happens. Yes, you can do that with an emulator of a vintage computer, but it's going to be harder. You need to learn the architecture of that computer, including all the hardware and ROM facilities the assembly is interacting with to do something as simple as putting text on the screen... and none of this is going to be even remotely applicable to Linux (or Windows) on x86-64.
It's not until I learned assembly language that I understood pointers, and from there, I could implement a basic OOP system in C and finally understand what objects are all about. It only clicked when I learned how to do it from scratch.
For a small taste of the past,
I studied electronics, so naturally we began with assembly (Motorola HC11). By the end of the course everyone had independently developed their macros to do things like for-loops, so it was a natural progression from there to C. By the end of the C course "C-style OOP" had also emerged naturally, which led to the next course in C++.
The downside of this approach is that it there is no gradual route from there to functional paradigms (or non-imperative in general). Also, one develops the habit of always thinking of how the language works under the hood, which can be counter, productive. E.g. when I was trying to learn Haskell, my mind was trying to understand how the interpreter worked.
Learning assembler is not just about the language, but understanding how the machine works (buses, memory-mapped peripherals, etc). In older platforms this is much simpler, so while ARM instructions can be easier to learn than the CISC instructions of the HC11, everything else is much friendlier for the beginner in the HC11.
For example, I'm working on an AArch64 code generator, more specifically, generating floating point code. I have a function:
float test(float a, float b) { return a * b; }
Compiling it with: dmd -c test.c -arm -vasm
yields: test:
0000: A9 BE 7B FD stp x29,x30,[sp,#-32]! // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldstpair_pre
0004: 91 00 03 FD mov x29,sp // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#addsub_imm
0008: BD 00 0F A0 str s0,[x29,#12] // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldst_pos
000c: B9 40 1B A0 ldr w0,[x29,#0x18] // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldst_pos
0010: 1E 21 08 00 fmul s0,s0,s1 // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#floatdp2
0014: A8 C2 7B FD ldp x29,x30,[sp],#0x20 // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldstpair_post
0018: D6 5F 03 C0 ret // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#branch_reg
It emits the address, the hex instruction, the instruction mnemonic, and the URL to the instruction specification.Yes, I know the code isn't quite correct, did I mention I was working on it? :-)
I have found good results with model of teaching since them and wish that more people tried it.
Nowadays, normally people learn assembly after they learn higher level lang like C or Java.
Let me take that back, I did learn 16 bit x86 assembly and the int21 DOS commands in college.
Circuit design and/or HDL, then you can make the CPU to run your hand-assembled program. ;-)
It was a very different time. Those people would be equally astonished at our casual computing devices and ignorance at how they work.
Oddly enough, my current karma score is 6502. Synchronicity indeed.
By the time the 1950s were over, we had higher level languages.
Like before The Beatles recorded their first album.
The reason is that BASIC and low-level monitors can fit into tiny amounts of memory.
Hell, I'm not even sure the era existed.
Grace Hopper was creating the first few high level languages for UNIVAC I. A-0 was complete in May 1952. A-2 (the first which saw extensive use) was created in August 1953.
As far as I can tell, UNIVAC I never had an assembler. If you weren't using A-0, programmers were expected to just type in raw machine code. Here is a UNIVAC programming manual from 1953 [1], and there is no mention of an assembler. Oh, and if you think you see instruction mnemonics... no, those are just letters which the CPU instruction maps onto.
Over in the IBM world, at least the 701 launched with a proper symbolic assembler in April 1953. But it also launched with Speedcoding [2], a somewhat higher level language halfway between non-symbolic assembler (it decodes mnemonics, but the programmer has to specify all addresses as absolute numbers) and an interpreter.
None of the other early computers seem to have had assemblers (though some, like the Manchester Mark 1, had high level languages).
There might have been some programmers at IBM who might have had access to a the prototype 701, and the symbolic assembler before Speedcoding existed [3]. But for everyone else, they seem to have gotten access to high-level languages at the same time, or before they got access to assemblers.
[1] http://www.bitsavers.org/pdf/univac/univac1/UNIVAC_Programmi...
[2] https://en.wikipedia.org/wiki/Speedcoding
[3] It's also possible that Speedcoding development was largely finished before the first 701 was operational. I'm finding it hard to find exact dates for that.
It was for me. In 1977 I lived in a little cabin in Oregon. I bought an Apple II as a diversion. Within a year I was working on a program that later became "Apple Writer" (https://en.wikipedia.org/wiki/Apple_Writer), written entirely in assembly.
Some in this conversation identify 6502 assembly as rather clunky and difficult to use. In retrospect I have to agree, but in 1977 I didn't have a basis for comparison.
There were no fast, high-level languages available for the Apple II, so my little program became an Apple product, primarily from the lack of alternatives.
Consider this -- Apple Writer lived in 8 kilobytes of RAM, but actually did things. It even had a macro language people used to process address lists.
I just boosted my main system to 96 gigabytes of RAM to be able to more easily host DeepSeek locally (I have an RTX 4090). I just realized that's enough RAM to hold almost 12 million copies of Apple Writer.
This is all pretty surreal ... but I've had occasion to say that a number of times since 1977.
The 32-bit ARM ISA, yes, but ARMv7 came much later. You're basically limited to ARM2 on the Archimedes, according to https://en.wikipedia.org/wiki/Acorn_Archimedes
Last I checked the 65C02 was still being manufactured and sold.
It can also at a blazing 14 MHz.
A RISC-V CH32V003 32 bit processor with 2k RAM and 16k of flash running at 48 MHz costs $0.10 for an 8 pin package (6 available I/O pins) or $0.20 for the 20 pin package. Once programmed, it needs only electricity between 2.8V and 5.5V to be applied to start running.
https://www.aliexpress.com/item/1005005036714708.html
You can get it on a ready-made board or kit for as little as $1.
https://www.youtube.com/watch?v=dfXWs4CJuY0
https://www.olimex.com/Products/Retro-Computers/RVPC/open-so...
The recommended dev board, with a USB programmer/debugger interface for your PC, plus 5 of the 20 pin chips, costs $8.35 about the same as a bare 65C02 chip.
https://www.aliexpress.com/item/1005004895791296.html
You can make your own cool shit like this, which uses the $0.10 8 pin chip.
https://www.youtube.com/watch?v=1W7Z0BodhWk
It's as easy to learn the instructions of as a 6502 -- there are fewer of them! -- and far easier to write useful code for.
MUCH easier to learn than a 68000, and no more difficult to use. TBH the A and D register split always annoyed the hell out of me in early Mac days.
If you have a memory-mapped frame buffer, you can write a single byte to it if you need a status checkpoint or tracking a variable. If you have a keyboard, you can probably read its buffer or use it for triggers.
Maybe modern debugging environments and tools make it easier, but I tend to think of my university assembly language class which featured original Intel SDK-86 boards with LEDs and hex keypads to interact with.
There are tutorials on youtube for it as well, such as Ben Eater's tutorial.
True but I've always found that there was a special 'charm' to these old CPUs because you have to build the circuit you described as a bare minimum, which is not difficult and makes you learn a range of skills.
Programming anything of moderate complexity on the 6502 is hard. 8 bits are way too restrictive (e.g. screen addressing on the Commodore 64). Multiplications/divisions need to be hand-rolled. And even 16 bit sums/subtractions are simple but still not trivial to perform efficiently.
The 8086+DOS platform is way easier to work on, in comparison (if one wants to learn basic assembly).
In the context of someone's first contact with assembly language, that's a good thing! Translating various multiplication and division algorithms to assembly is a great way to learn it.
It seems unnecessary to learn any algorithm including the multiplication algorithm in assembly language.
Besides, if assembly language is good enough for Knuth to express all the algorithms in TAOCP, it's good enough for me...
One day, I asked my friend Shal Farley, what was a stack? He said "Imagine a stack of plates. You added a plate (pushed it on the stack), and took off a plate (popped it off the stack). Suddenly, Shal had turned the lights on! I instantly understood it.
Then, I began working with a 6800 microprocessor on a little board. It had something like 40 instructions, that all fit on a card. 40 instructions were simple to learn, and suddenly, I got it.
I want back to the -10 manual, and it all made sense.
Mine was wanting to make games and hitting the performance wall in basic.
I guess most people just give up once they see the ugliness of what they got from Intel.
The 6502, on the other hand, is a derivate of the 6800, a genuine microprocessor design that takes fast random access into account. And thus, taking fast memory for granted, it became viable to outsource some of the internals. From this perspective, the 6502 provides a plenitude of 256 slightly slower registers in the zeropage. – However, if you're using the 6502 like this, you may discover that you lose some of the much acclaimed advantage in cycle count per instruction.
Besides increasing the number of registers, Z80 has added many features that were standard in any general-purpose computer (e.g. signed integer support and indexed addressing), but which were missing in Datapoint 2200/Intel 8008/Intel 8080, simply because Datapoint 2200 had not been designed to be used in general-purpose computers but only for implementing the logic required inside a serial terminal.
However many programs for Z80 did not make good use of its additional functions, because they were intended to remain compatible with the legacy Intel 8080 systems.
Intel 8086 did not have this problem, because it was only source-code compatible with 8080, not binary compatible, so any application had to be recompiled for it, and fully using the new ISA did not have any additional disadvantage.
Unlike 6502, Intel 8080 and Z80 had a few 16-bit operations, which were intended for address computations, while data operations were expected to be handled using the 8-bit accumulator.
Despite the intended use and the limited set of 16-bit operations, implementing complicated arithmetic operations, e.g. floating-point arithmetic, was still faster using the 16-bit address registers and operations for handling data. With properly optimized programs, Z80 and even 8080 could be much faster than 6502 for number crunching. (Though faster is only relative, because FP64 floating-point operations took many milliseconds per operation on any 8-bit microprocessor, many billions of times slower than on a modern laptop or desktop CPU.)
PS: regarding the DP2200 not being meant as a small system, I'm not so sure about this based on my own reading. But, certainly, it wasn't marketed as such.
And, regarding the educational merits of the 6502, it may be a good second language, as it requires you to think about your implementation. (Personally, I'm more for the PDP-1, which Ed Fredkin – "world's best programmer", no less – once claimed to have inspired IBM's RISC architecture. ;-) )
Still do, really, though I’m decades beyond wanting to write anything in assembly now.
Main downside is that with 68K you're more likely to be loading your program into an OS rather than bare metal hardware, and have to deal with things like relocation.
It's taught to all computer science and software engineering students. Most students would take it in their first year, second semester.
We cover everything from the basics to hand-compiling code with functions, stacks, arrays, pointers etc.
We have our own emulator and even web platform for students to step forward (and backward!) their code: https://cgi.cse.unsw.edu.au/~cs1521/mipsy/
I feel like learning modern assembly would be more useful, but maybe 6502 assembly is far easier to pick up? The first language I learned was Atari BASIC around 1991, and it was enough to get me to keep on moving to better languages and more powerful CPUs, but I wonder where I would have ended up if I learned assembly either before or after Atari BASIC. I try to keep up with technology, and have read quite a bit on different assembly dialects. I still haven't learned an assembly that I can program in, and I suppose it's because there are so many other high-level languages now and I feel like I need to keep up to what is used in "industry" rather than what is more obscure (but might help in debugging).
And as it turned out, I didn't have any problems adapting to the expanded PPC ISA. Being on the 6502 already taught me how to chop problems down into tiny bits and now the bits didn't have to be so tiny. I certainly wasn't trying to do 8-bit chained adds for bigger quantities anymore; it didn't make sense to when I had 32-bit registers and an FPU.
In so many of these years I had not learned C. I went from assembly to scripting languages, and was a very early adopter of Javascript since the same month it first came out. Only in the last 10 years have I learned C, and it was so easy! After learning Assembly and Javascript, C was right in the middle.
I've programmed in over a dozen languages through the years, but I'm really happy with Assembly, C, and Javascript as my stack depending on the project.
I spent my teenage years grabbing cracks and texts from BBS', and enjoyed the whole scene. It's really what sparked my interest into writing software, and I always wished I had learned some lower-level skills beyond running a debugger and poking at memory. I felt like if I knew Assembly, I could get into deeper debugging (cracking was initially my "exciting" topic to cover, but now I feel like it would just be understanding memory better when I run into a strange error).
We have found that when needed, students pick up the newer/more advanced assembly languages (e.g. ARM, x86) fairly well, so we believe the early and universal introduction to MIPS does provide benefits.
Many of the instructions have similar mnemonics, such as the conditional branch instructions (BEQ, BNE, BCC, BCS, BMI, BPL, BVS, BVC), as well as the arithmetic instructions like ADC, SBC, EOR.
Not really (perhaps leaving mnemonics aside). The 6502 has little in common with the first ARM. The ARM's designers liked the simplicity and speed of the 6502 and it was their favourite 8-bit ISA. And a visit to the Western Design Center convinced them to design their own CPU.
However, the early RISC papers were the biggest influence on the design of the ARM. There is even a clue in the name 'Acorn RISC Machine'.
The simplicity of RISC-V is illusory. Because it lacks many features of normal ISAs, like ARM or Intel/AMD x86-64, writing programs that are both efficient and robust, i.e. which handle safely any errors, is quite difficult in assembly language.
For a simpler programming in assembly language it is hard to beat DEC PDP-11 and Motorola 68000 derivatives.
However those are no longer directly useful in practice. For something useful, the best would be to learn assembly programming using a development board for some Cortex-M microcontroller, preferably a less ancient core, e.g. with Cortex-M23 or Cortex-M33 or Cortex-M55 or Cortex-M85, i.e. cores implementing the Armv8-M ISA (the latter 2 also implement the Helium vector extension).
Probably some development board with a microcontroller using Cortex-M33 would be the easiest to find and it should cost no more than $20 to $30. I would not recommend for learning today any of the development boards with obsolete cores, like Cortex-M0+, Cortex-M3, Cortex-M4 or Cortex-M7, even if those boards can be found e.g. at $10 or even less.
Such a development board can be connected to any PC with a USB cable. All the development tools are free (there are paid alternatives, but those are not better than the free GNU tools).
You can compile or assemble your program on the PC, then load and run it on the development board. You can have a serial console window connecting to your program, by using a serial port on the development board and a USB serial interface. All such development boards have LEDs and various connectors for peripherals, allowing you to see what your program does.
I think that learning to program in assembly such an Armv8-M microcontroller is more useful than learning something like 6502. Armv8-M is less quirky than 6502 or RISC-V and it is something that you can use for implementing some useful home device or even professionally.
Otherwise, the best is to learn the assembly language of your personal computer, e.g. x86-64 or Aarch64, but that is much more difficult than starting with a microcontroller development board from ST (e.g. a cheap STM32 Nucleo variant), NXP, Infineon, Renesas, Microchip, etc.
The Pi Pico 2 RP2350 has dual Cortex-M33 cores (and RISC-V), and costs US$5.
Do you have some examples of this?
There are absolutely no reasons for omitting these essential features, because their hardware implementation is many times simpler and cheaper than either the software workarounds for their absence or than the hardware workarounds that can be implemented in other parts of the CPU core, e.g. instruction fusion.
6502 is much more similar to a normal CPU than RISC-V, because it has both integer overflow detection and indexed addressing.
While I believe that other ISAs are better than 6502 for learning assembly language for the first time, I consider 6502 as a much better choice than RISC-V.
RISC-V could be used for teaching if that would be done in the right way, i.e. by showing how to implement with the existing RISC-V instructions everything that is missing in RISC-V. In that case the students would still learn how to write real programs instead of toy didactic programs.
However I have not seen any source teaching RISC-V in this way and it would be tedious for newbies, in the same way as if they were first taught how to implement a floating-point library on a CPU without floating-point instructions, instead of being allowed to use the floating-point instructions that any CPU has today.
- learn assembly as subroutines inside your "daily driver" language on your regular PC, which is going to be x64
- microcontroller with in-circuit debugger where you can connect it to flashing lights (obvious candidate is Arduino, which is AVR, or STM32 which is ARM)
Back in the day the first of these was easier in environments like BBC Basic inline assembler or MS-DOS COM files (which are headerless executables that can be extremely small.) You could also learn either of those in emulators.
The modern CPU with orthogonal instruction set is just as easy (possibly easier because you have more and larger registers, making it easier to get ‘real’ results) until you start to look at performance.
Then, you hit the problem of having to understand how your target CPU does out-of-order execution, how large its caches are, how they are organized, etc.
Modern CPUs out there that have very little of that exist, though.
Eventually, I ended up doing ASM with 68000 (Mac Plus), but by then, I was well on my way with higher-level languages.
Starting from Machine Language helped me a lot in understanding some of the more fundamental concepts of software. It was also an excellent troubleshooting teacher, which has probably been the most valuable software development skill I have.
These days, though, with the current complexity of CPUs, I don’t think it would be reasonable to start folks off with assembly/machine languages, anymore. I’m not sure that “retro” CPUs would really represent some of the difficulties experienced with highly parallel processors. I would worry that it might encourage an “idealized” view of the underlying architecture.
For me, it was Z80, just because Radio Shack had a book on it. I never actually built or programmed a Z80 system, but I still fall back on that knowledge when working with microcontrollers.
Of course there are also synthesizable FPGA implementations, cycle-accurate software implementations, etc.
SBC is implemented by adding the ones-complement (XOR FF) of the number or register. And the carry flag is backwards compared to other architectures, such as the Z80. On input, Carry Set means that you don't want an additional one subtracted, and Carry Clear means you do want an additional one subtracted. Then on output, Carry Set means that no borrow took place, and Carry Clear means that borrow took place. When borrow takes place, you get an additional one subtracted, and that lets you chain the low bytes up to the high bytes and subtract bigger numbers.
CMP is like SBC, except it always adds the extra one whether your input carry is set or not, making it act like you'd expect comparison to act.
(So, technically, the carry is like a ones' complement / two's complement switch. And this is also all we need to implement a borrow in two's complement math.)
https://en.wikipedia.org/wiki/MMIX
has a quite deep corpus and what looks to be a good introduction:
https://www.mmix.cs.hm.edu/getstarted.html
(and I say that as a person who owns a much battered copy of Inman & Inman's _Apple Machine Language_)
MMIX might be good for educational use in an academic setting, but literally anything else would be better if you want to have fun working with it. Nothing beats the magic of seeing your first program run on a real computer.
It is Purpose built, load-store etc...
You can use the simplified MMIX-SIM
Then you can move to typical RISC features like full pipeline, cache, etc...
Then you can move to actual hardware etc..
But I am probably bitter, I learned on a Heathkit ET 3400, and I find that a lot of the quirks of the 6800 are something I had to get around to understand modern processors.
MMIX may not be 'useful' for real applications, but being intentionally free of those quirks is very useful for understanding the core concepts, at least for the few people I have had try it.
The 6502 was designed to be easily implemented with relatively few transistors. For that it was amazing. There is a reason it was popular! But its CPU registers are only 8-bit, its call stack is 256 bytes, and for real work you need to use the zero page (zpage) well. None of these are likely to relevant to a modern software developer using assembly. Its design encourages the use of global locations, again, an approach that don't make sense on modern systems.
I say this as someone who admires what the 6502 was able to achieve in its time, and I even have a long-running page dedicated to the 6502: https://dwheeler.com/6502/
If you want retro and easy, the 68000 has it beat in terms of simplicity of development. The 68K is quite regular & a little more like modern systems (sort of).
However, I think starting retro is often a disservice. Most the time the reason to use assembly is performance. If you're running code on chips more than a dollar or so, getting performance out of modern architectures is MUCH different than retro computers. For example, today a lot depends on memory cache latency, yet is typically not a serious concern on most retro computers. So learners will learn to focus on the wrong problems.
If you want a modern simple architecture, may I suggest RISC V? That's under a royalty-free open source license, and real computers use it today. It's pretty simple (your basic load-store architecture) and you can pick only the modules you care about. Full disclosure: I work for the Linux Foundation, but I'd say that anyway.
Plausible alternatives are ARM and x86. If you subset them, they're okay.
The reality is that assembly languages reflect the underlying system, and that will change over time.
Zero page is like a having 256 generic RISC registers (a bit faster than accessing to other memory areas).
Very easy to understand how the assembly is micro-coded
Cons:
It is impossible to create a "generic" memory pointer with an index >255 without auto-modifying code.
It is a true 8bit only system and cannot manipulate 16bit word easily Steve Wozniac created a small VM just to manage 16 bit Integers (see the his Byte magazine articles).
Too much addressing mode.
So I like 6502, but I disagree a bit.
It was called SWEET16: https://en.m.wikipedia.org/wiki/SWEET16
A BYTE Magazine article by Wozniak: http://amigan.1emu.net/kolsen/programming/sweet16.html
Porting Sweet 16 by Carsten Strotmann (with source code) http://www.6502.org/source/interpreters/sweet16.htm
Sure it is. Just store your pointer in zero page, set Y to 0 and use the (ZP),Y addressing mode.
(Actually, what I wished for was slightly different: only the high byte of the effective address would be fetched from zero page, the low byte being the Y register. In this way, one could keep both bytes of the pointer in zero page, LDY the low byte and use my zp indirect mode. The first use of a pointer would cost an extra instruction / 2 cycles, but further uses of the same pointer would be cheaper.)
I'm not saying 6502 assembly can't be an interesting endeavor, but it's a bit restrictive for a first language. Maybe if you already know some low-level programming like C. But it's still easier to do things with a few more registers. And it's not like you have to use every register and instruction available on the CPU to write some assembly.
I wrote one in Swift a few years back, and then ended up developing it further into an NES emulator capable of playing Donkey Kong. It was a great learning experience.
https://github.com/davidly/a1/
The full title is " 6502 and Apple 1 emulator for 8080/Z80 CP/M 2.2 machines " which I guess gives a better idea of the (impressive) scope.
That was pretty great for learning assembly, I can't comment on any other approach - no doubt there are other good options.
The 6502 wasn't. Everything about the 6502 was "do more with less" and you had to be really clever to eke out performance on it. But that's a good thing! A clean, big CISC architecture like the former ones is also a good compiler target. The 6502 was deeply weird, but programming it in assembly was necessary to get it to fly. That's an era. If you want to relive that era, then go for it. It's much more quirkily fun that, say, the 8080 (the Z80 is another beast, though backwards compatible) and much more mainstream than the otherwise better 6809, all of which are also from the "assembly language required for performance" era.
Problems with the ISA become obvious the moment you want to scale your program beyond toy complexity. The stack is absurdly tiny, and trying to use it as a calling convention quickly becomes both a performance and a nesting depth bottleneck. I work around this for my larger projects by using zeropage scratch as a sortof manually-managed local scope for routines, but it requires carefully tracking which otherwise global bytes my programs are using at various nesting levels. Recursion is off the table both with this technique (difficult to manage) and with the stack (256 bytes will be exhausted very quickly). The C compilers I'm aware of work around this (slowly!) by using a separate software stack for arguments to functions.
It's pretty fun though! I'm working on a full modern indie game for the NES, which is 100% programmed in 6502 assembly for performance reasons. The existing C toolchains for the NES are either very slow (cc65) or not yet mature (llvm-mos). Most of the true complexity in the project is algorithmic stuff, like resource allocation and deciding how much work to do on a given frame. The 6502 ISA is a bit slower to write than higher level code, but it's not really a major limiter now that I've got my process down.
Here's that game if you're interested: https://zeta0134.itch.io/tactus
The problem was that Applesoft basic set the high bit on data going out a serial or parallel port which was a problem for printing and sending data out through a modem. So if you wanted to keep the high bit one had to use 6502 assembly.
In any event, try out the KIM-1 simulator if you want to use your 6502 coding skills: https://maksimkorzh.github.io/KIM-1/
"Another group inside [MOS] designed the KIM-1... One of the first "public" uses for the design was the Apple I microcomputer, introduced in 1976."
Also, the JOLT was used in the Atari VCS prototype.
MAI was later acquired by Synertek and the company was rebranded as Synertek Systems and then created the SYM-1, a 6502-based SBC, in 1976.
Biggest issue is that register width is half of pointer width, so for arbitrary pointers you at least need to make a trip through the zero page.
That fact alone really obfuscates a lot of what you're trying to teach as a first stab in assembly.
I say this as someone who has a whole lesson plan in 6502 asm.
But all that being said, 68000 or modern ARM or RISCV are also good targets. I am probably just a little nostalgic for the 6502.
If you could so something like LD[$0f] #65 - then yeah, you have registers. But you can't do that sort of thing with zero page. You'd still need to do: LDA #65 STA $0f
This is using a 16 byte address in zp as a ptr + y offset
For LD[$0f] #65
It's more instructions but you LDA #65 STA ($0f),Y (assume Y = 0)
That said, I loved the zero page on the 6502...
I end up having to talk myself down like "no, we're here to learn, not to create another language"
You can go through that in one pleasant sitting.
If you want to learn to write programs in assembly language or to debug disassembly of programs written in higher languages, then learn the language for the platform that you want to target. This also covers the "I want to write/understand retro stuff" case.
If you want to understand how high-level programs are compiled into assembly language, then read Aho[1].
If you want to understand how algorithms are implemented in assembly, read Knuth[2]. Knuth invented a hypothetical computer "MIX" with its own assembly level instruction set and I believe that MIX has actually been implemented in software several times.
If you just want to play a little bit with assembly, "dipping your toes in the water", then I agree with the OP that 6502 is simple and easy to learn, but it is not practical for many modern use cases and has sharp edges.
[1] "Compilers - Principles, Techniques and Tools", by Alfred V. Aho et al. https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniq...
[2] "The Art of Computer Programming", Volume 1, by Donald Knuth, Section 1.3 "MIX" (p. 124 in the 3rd edition) https://en.wikipedia.org/wiki/The_Art_of_Computer_Programmin...
Back in the 70s I was fully aware that learning computers was the key to the universe. And if you wanted to learn how computers worked, you have to learn assembler. And if you want to be more than a beta programmer, you had to learn assembler.
> Knuth invented a hypothetical computer "MIX" with its own assembly level instruction set
I never bothered with that. Why, when real computers are available? MIX is a waste of time.
> it is not practical for many modern use cases and has sharp edges
All CPUs have their sharp edges. Like learning to use a milling machine, you don't want to drive the cutter into the vise. Sure, the 6502 doesn't have a divide instruction, but writing a divide routine is a good start to learning how to make the 6502 dance.
6502 has 56 mnemonics, RV32I/RV32E has 37.
But mnemonics are arbitrary. Are BCC, BCS, BEQ, BMI, BNE, BPL, BVC, BVS really different instructions, or just one instruction with a field specifying the condition.
If you look at 8080 and Z80 assembly languages you see the same binary instructions represented with different mnemonics and some things that have different mnemonics in one are the same mnemonic with different arguments in the other.
6502, original, has 151 of the 256 eight bit opcodes used, but when you add in the immediate data or address it has millions of possible instructions:
with ABS ABS,X ABS,Y modes: ADC, AND, CMP, EOR, LDA, ORA, SBC, STA
with ABS ABS,X modes: ASL, DEC, INC, LDX (act ABS,Y), LDY, LSR, ROL, ROR
with ABS mode: BIT, CPX, CPY, JMP, JSR, STX, STY
So that's (38 + 28 + 7) * 65536 = 3,080,192 instructions right there.
Immediate and the various Zero Page instructions add another few thousand.
Similarly with RISC-V RV32I when you fill in the Rd, Rs1, Rs2 fields and immediates/offsets there are again many millions of possible instructions.
If I was to think of the most approachable assembler it would be the ARM assembler for the original ARM2. A real thing of beauty. Which is not what anyone would normally say about any assembly language! I remember going from ARM to MIPS and being utterly horrified by its ugliness compared to ARM!
Having worked with the 6809 series as well, it wouldn't be a bad choice either. The Freescale 68HC12 is still in production. Little systems with limited-yet-real I/O give the programmer very useful feedback.
The 6502 won in the marketplace though, apparently due to its lower cost (the 6809 had nearly triple the transistors.)
It's nice that it's still in production if you want to build a breadboard system.
For teaching, I would instead go with RISC-V. In particular RISC-V with the bitmanip extensions, which make some things much easier and gives it feature-parity with the base set on x86 and ARM. The Raspberry Pico 2 has two RISC-V CPUs with those. The board is easy to use, widely available and has a lot of support. There are also alternative boards with the same MCU but other form factors and features.
Around the same timey I had to learn AVR8 family assembly (for ATMega328P) which was a joy in comparison.
I don't think AVR assembly is any better or easier then 16bit Intel, but just the fact that it's a usable and actually triable thing makes a world of difference.
I guess what i'm trying to say is that you shouldn't underestimate the importance of learning something useful instead of something antiquated, even when it is not the simplest thing to do.
Also, for me the excellent 68000 instruction set was design wise far more a continuation of the clean Z80 style than the messy 6502.
I learned M68K in a college class in 1995. When I saw x86 asm 2 years later it looked like a mess. But I've never needed to write asm for a job.
I'm thinking about learning 6502 because my first computer (Atari 800) and first dedicated game console (original Nintendo NES) both used the 6502 and it would be fun to write games for them when I retire.
On the other hand, the cleaner, more modern architectures are easily targeted by compilers. If you really want to live the "assembly language required for performance" era, the 6502 is fine. Equally quirky is MCS-51. I've written nontrivial assembly language projects for both "back in the day".
Nevertheless, when I went to teach a short intro to CPU class to high school students recently, I chose the venerable 6502 for programming. Why? Because performing the 8-bit arithmetic and performing hand assembly are all very manageable on the 6502. Any 8-bit CPU would do, frankly, but the connection between 6502 and early microcomputer history is intriguing (and I was familiar with it).
Everyone here is talking about how there are better assembly languages to learn first, but I wonder how many of them are practical for hand assembly. I still maintain that learning (and debugging software for) any CPU architecture beyond the 6502 was easy because of the skills I learned as a teenager, hand assembling 6502 code. That experience put me miles ahead of my colleagues who didn't have that experience when it came to working with low-level coding in the decades to follow.
a9 01 8d 20 d0 a9 93 20 d2 ff ...
When we got a KIM-1, we were able to write meaningful programs on it in a weekend, since we already had memorized all the hex.
LDA #97
JSR $FFD2
writes "A" to the screen.It was even more of a pain with 80 columns when half of the text was in the main memory and the other half was the bank switched memory.
Only on the OG Integer ROM Apple ][ and then again on the later 1985 enhanced ROM //e
VAX or 68K would be cleaner CISC ISA to learn first.
8086 (16 bit) x86 has the advantage of being ubiquitous and you can run on "hardware" everywhere. but the disadvantage of being a little weird wrt. segment registers. x86 32-bit is complicated, but at least flat memory space and you can mostly ignore the segments.
MIPS or one of the RISC-V variants is a second one to learn to contrast RISC load/store with CSIC.
Is this author arguing the 6502 is preferable because it's simpler? Or because there are more/better resources for learning?
You can't just make a 24-bit pointer w/o doing things using the direct page, which is admittedly a bigger problem for a C compiler than an assembler.
You always have to be able to know what mode the 'A' register is in (8/16) as well as the index registers. These are separate switches. Even disassembling code on the '816 is tainted by this, because for any section of code you look at, you have to know what mode the thing is in to accurately disassemble the code.
So basically, it's a 16-bit processor, sometimes which is a bit maddening.
What is the best platform to learn assembly on and where do I start? Books, videos, building my own computer, etc?
Yes.
> However, they are not ideal to start with: the “S” in RISC stands for “simple”, but the simplicity is more about internal implementation of the chips than the instruction set.
That is in fact a much better description of the 6502, which is not even a RISC but rather something almost prehistoric, where you figure out how much circuitry you could fit on a chip (or board) and then figured out what instruction set you could fit to that hardware.
Note that 6502 was the first machine code I learned as a 17 year old in 1980, after I got bored with BASIC after two days. I learned z80 on a ZX81 the year after and PDP-11 the same year. VAX in 1982, 6809 in 1983, and 68000 in 1984.
> Modern microprocessors are almost exclusively programmed with high-level languages and the direct usage of assembly instruction is not high on the list of priorities for CPU designers nowadays.
That's just absolutely not true.
They might be in some way "harder" than a CISC instruction set such as VAX but any of the above are far simpler to program than 6502, especially the base RISC-V RV32I instruction set.
> To illustrate this point, loading a 64-bit constant to a register on ARM64 can take 4 instructions with bit shifting.
Whereas you can't do it at all on a 6502! Loading a 64 bit constant into 8 zero page locations takes 16 instructions and 32 bytes of code on a 6502.
Let's not even talk about adding or comparing or multiplying two such values.
The GNU assembler for ARM64 doesn't help you out, but on RISC-V you can just type ...
li x10,0xfedcba9876543210
... and the assembler will generate the multiple instructions for you.https://store.arduino.cc/products/arduino-uno-rev3
are affordable and have good tooling. Memory capacity is tiny but it is fast, andthere is a lot of I/O, you can even write console programs that use the serial ports or better, programs that do physical things and also communicate over the serial ports -- in some ways AVR-8 boards are more capable than conventional computers, phones, etc. So far as I can tell, AVR-8 was the last 8-bit architecture, if it has a real weakness it is that, compared to other microcontrollers, it's a dead end because you're going to upgrade to ESP-32 or ARM if you need more.
The 6052 has more registers than the PDP-8 but just barely. Writing compilers for the 6052 is difficult because there just aren't enough registers not to mind a limited set of addressing modes. If you want to do anything interesting with the 6502 you are likely to use virtual machine [1] techniques such as Wozniak's SWEET16 or the atrocious UCSD p-System [3] or Infocom's Z Machine [4]. That kind of stuff is really fun, but so is writing straightforward AVR-8 code.
I have fond memories of the 6809 which supported really advanced software engineering techniques at the time [5] but if I had to pick a classic 8-bit architecture that is easy to find hardware for today it would have to be the Z-80, or the successor eZ80, which I think the only 24 bit micro that didn't suck (had real 24 bit index registers!) Boards are available [6]
[1] as in 'Java Virtual Machine', not 'VM/CMS'
[2] https://en.wikipedia.org/wiki/SWEET16
[3] http://pascal.hansotten.com/ucsd-p-system/
[4] https://en.wikipedia.org/wiki/Z-machine
[5] https://en.wikipedia.org/wiki/OS-9
[6] https://www.olimex.com/Products/Retro-Computers/AgonLight2/o...
It's hard to fathom the 6502 came out in '75, the 6809 in '78 and the 68000 in '79
Its been a while now, but I remember feeling that the 68k was clearly powerful and elegant and a proper cpu, but also that I had little hope of understanding all the details. The 6502 was my first, and with hindsight was far less elegant with plenty of warts, but I felt at the time that I understood it pretty well. The 6802 was somewhere inbetween, I guess, and a very nice cpu to work with
I've never thought about it before, but I suppose I benefited from that progression 6502->6809->68k. Whether or not it makes sense now, I couldn't say.
(Never got on with the Z80. That brash upstart /s)