4 ms·
I've developed software for 6502 (the first processor I learned assembly language for, but not the first CPU I programmed at the machine code level), Z80, 6809,
by justinlloyd 6y ago
I've developed software for 6502 (the first processor I learned assembly language for, but not the first CPU I programmed at the machine code level), Z80, 6809, 68000 series (x00, x20, x30, x40), a variety of MIPS (R3000, R4000, R10000), ARM and a number of variations on it, x86 and all its variations, T800 Transputers, various 4-bit and 8-bit microcontrollers, and well over a dozen more CPU types over the years.
For real world processors, I would say that the 68000 is probably the best introduction to assembly level programming. For a real-world CPU. Lots of registers, usually a flat and easily understood memory map, a clean instruction set, and instructions that have direct parallels to many of the basic operations you would find in higher level languages, e.g. multiply, divide, addition and subtraction of 32-bit numbers, easily understood loops, various conditionals and so forth. Certain early ARM variants would run a close second of "try this out, it's easy to understand." Though even then, I'd hesitate to introduce someone to ARM programming unless they had a real interest in learning assembly programming.
6502 is simple, I agree with that, but moving beyond the most basic of operations takes careful thought.
So for an introductory assembly language on a real world processor, I would have someone start with 68K. Once they grasp that, which, if they are a reasonably competent programmer, facile in their language of choice, they should be able to crank out 68K assembly that does useful work in a couple of days. It is possible to then consider the 6502 or Z80 or 6809 as options for a less capable, but certainly more difficult next step in assembly language.
I would strongly disagree that 6502 is designed for human readability or that it is the pinnacle of assembly language programming options. For real world processors, I would be hard pressed to rank it in the top 10 of "processor of choice to solve this task because of capability." Perhaps up to about 1982 it could be considered reasonably competent. But "pinnacle" is not a word I would ever use to describe that CPU no matter how fond my memories are of learning to program it or shipping my first video games on it. The 6502 CPU has a number of shortcomings that were clearly evident in the late 1970s when it was at peak popularity. The one thing it did have going for it was that it was cheap and that it was easy to get going on a board with some supporting chips.
- monocasa 6y agoYeah, as someone who's taught a intro to computer architecture curriculum based on the 6502, I wouldn't recommend it. I ended up switching to MSP430 after the first run through. Features of the 6502 ISA like register width being half of pointer width with no way to link a pair of registers together to a full address, relying on you to have to bounce back and forth through memory to construct a full pointer really obfuscated a lot of the concepts I wanted to teach. Yes, "zero page is the real registers", bla bla, but those extra hoops don't do any favors to someone who's just learning computer architecture. 68k looks clean, but I've never had to use it in my career so I shy away from it for probably that reason only.
- justinlloyd 6y agoIf you know even a modicum of assembly language you can grok 68K in under 20 minutes. It works exactly how you expect it to work. I want to load a register, I want to loda a second register, I want to multiply them. The most remarkable caveat in 68K, that I can think of, off the top of my head, is "multiply and divide can be slow than you expect." Which is where the MMU or the x40 comes in. The MSP430 is also a good learning processor, clean instruction set, not too much to take in at once, though there is mental overhead when you need to start being concerned with stack processing and also with some jump instruction limits.
- monocasa 6y ago> If you know even a modicum of assembly language you can grok 68K in under 20 minutes. It works exactly how you expect it to work. I want to load a register, I want to loda a second register, I want to multiply them. The most remarkable caveat in 68K, that I can think of, off the top of my head, is "multiply and divide can be slow than you expect." Which is where the MMU or the x40 comes in. Going to be real, I never liked the split A and D integer register files of the 68k. It always seemed like it would obfuscate one of the base ideas I want students to keep over thier lives. That it's all memory, whether it's 'data', or pointers, or instructions, it's all just bits in memory. Having to load into one part of the processor to use it as an offset seemed antithetical to that goal. > The MSP430 is also a good learning processor, clean instruction set, not too much to take in at once, though there is mental overhead when you need to start being concerned with stack processing It's got clean push and pop instructions, and R1(SP) an otherwise be accessed just like a normal register in the file. What are you thinking about there? > and also with some jump instruction limits. Yeah, I just stuck RAM and ROM within the limit on the emulated system they use so that doesn't come up.
- justinlloyd 6y agoI will agree that the split Address and Data registers are probably not the best architectural decision the desginers made. But in a pool of "be aware of these things", only having to deal with a half-dozen new concepts is a lot easier than the dozens of caveats and new concepts of many other processors. It is easier to teach "multiply is slow but this is how you do it" vs "here's a function you have to call, or need to write from scratch, to do a division." Regarding the stack processing, I mispoke; I was recalling a different CPU, whereby, given an address in the R(0), it is possible to execute an instruction at a different memory address than the one the PC is currently pointing at, effectively giving you a second PC, which was frequently used to execute a function without jumping to the function. The easiest way to describe that concept is a mix-in.
- aap_ 6y agoI think the PDP-11 is about the most elegant modern architecture. The 68k was obviously inspired by it but it's a lot more complex than the original.
- justinlloyd 6y agoCannot decide if sarcasm or serious. The PDP-11 computer was an a good architecture for the time, but "most elegant modern architecture" is so dismissive of everything that has been developed in the past 50 years as to border on the absurd. The instruction set of the PDP-11 (MACRO-11 the programming language) , and the CPU architecture that went with it, was kinda shit to be honest. It was groundbreaking at the time as many systems were, and firmed up many of the standards that we have today, but I wouldn't ever describe the CPU as elegant. Influential, perhaps.