18 ms·
I would heavily recommend first learning assembly with an ISA that's not x86, though. The x86 ISA has just as much cruft as C, e.g. all the overlapped increasin
by derefr 5y ago
I would heavily recommend first learning assembly with an ISA that's not x86, though. The x86 ISA has just as much cruft as C, e.g. all the overlapped increasingly-sized registers, the now-irrelevant segment registers, etc. And x86 has some stuff that's not legacy, but which makes learning much harder — e.g. assembler-level instructions like LEA that compile to a set of entirely-different opcodes of different shapes depending on what you do with them. (IMHO, for best learning, you should be able to easily disassemble object code in the ISA "by hand" back into assembly, with just an opcode chart for reference. Doing this with arbitrary x86 assembly would be quite the challenge.)
I'm not sure what to recommend as an optimal learning ISA, though. Ideally something that's mostly RISC, with a small but unified memory model, and no virtual memory, and which has all the math ops that embedded RISC ISAs never bother to implement. (In the end, probably no real architecture ever made that exact set of compromises, and so it'd have to be something made up — some kind of bytecode abstract machine ISA designed specifically to be used in education, an ISA equivalent to languages like Logo or Scratch, or OSes like Minix.)
In practice, I think I would recommend learning assembler by programming for the original Gameboy's LR35902 ISA (which is almost, but not exactly, the Z80/8080 ISA). Not because it's the optimal learning ISA per se, but because it gives you a complete machine including graphical video output, with a compact unified address space (no separate IO-register read/write ops), modern tools that target it, and good emulators that almost always include built-in debuggers and memory viewers — where, as well, the memory is small enough to get it all on-screen and have room left over.
Oh, and unlike other ISAs, where people either never hand-write code for them, or where no hand-written code survives in a readable form, with LR35902 we have several complete projects with hand-written assembly codebases (or, well, reverse-engineered + annotated disassemblies of originally hand-written assembly — just as good!) around to be studied. And, of course, they're just the sorts of things kids interested in computers would be interested in studying the workings of: video games! (https://github.com/pret/pokered https://github.com/pret/pokered is a shining example here.)
- mwattsun 5y agoI feel very lucky I learned on the 68000 in the original Mac. If a CPU could ever be considered a work of art, it was the 68000
- deleted 5y ago[deleted]