Which 32-bit/64-bit CPU architecture has the easiest instruction set?
assembly, powerpc
Solution
Well, most RISCs are very much alike, so if you know the PPC well, then transitioning to ARM, MIPS, or SPARC will all be a snap. I actually learnt SPARC first and then was able to pick up a MIPS and the PPC in a couple of hours.
The thing that makes the x86 so confusing isn't really its assembly language, but the design of the processor. People tend to get hung up on:
- Segmented memory addressing -- all those ds, cs, es registers: what do they mean, how are they combined with an index register to make a fully resolved memory address? There's actually three different ways that happens, so you're learning a bunch of different modes.
- Nonorthogonal instruction set -- some instructions only work with certain registers, other instructions have meanings that overlap, some things look like they should be fast but are really slow, etc.
- Register-memory architecture -- the x86 is designed to have few (named) registers, so that each opcode usually has one argument that is a register and another argument that is a memory address. This is different from the PPC's load-store arch, where the memory operations are explicit. Since the stack pointer tends to bounce around a lot, this can make it hard to figure out which variable is really being used!
- Spastic stack pointer -- where most PPC calling conventions have you move the stack pointer just once on entering a function and then once when returning, typically x86 code will be `push`ing and `pop`ping all over the place. You end up counting the pushes and pops to figure out just where your stack pointer has gotten to, which always makes my head hurt.
So, to get comfortable with the x86, divide and conquer: pick one of those points, learn how it works, then move on to the next. It may help to start by learning the calling conventions first, because that'll make all the other instructions that reference the stack pointer make more sense.
Problem
I feel extremely comfortable dealing with 32-bit PowerPC assembly code, but I am completely lost when trying to make sense of x86 code. Do any of the other common architectures like ARM, MIPS, Sparc etc have an easier than x86 instruction set?