Guide to x86 assembly
cs.virginia.edu
cs.virginia.edu
Perhaps the R.Pi could do it, but it's certainly easier that you can just run the code on the desktop computer you're working on. The university behind OP probably has a lab full of Linux x86 desktop computers ready to use. They probably don't have a bunch of R.Pis or ARM devkits around.
I don't see any advantages in ARM over x86 for taking your first baby steps in assembly. Either will do but the latter is probably easier to set up.
There's a lot that I'd like to learn but unless you can incorporate it into something where you'll use it, the payoff will be small. There's so little time and so much to learn.
His examples about doing a website to learn a language are spot on. If you know you are going to visit a place, why not learn the language before hands, it will motivates you and you will be able to use what you learned eventually.
By comparison, x86-32 has more baggage from x86-16 and is less orthogonal. It also suffers from nonstandardisation of the vector instructions like ARM does, although you can reasonably assume FPU and MMX these days.
AMD64 might be an interesting choice to start with these days.
When learning assembly, what matters is getting used to instructions, registers, control flow and explicit memory accesses rather than statements, expressions, functions and variables. It really doesn't matter which ISA you're learning, the actual skill you learn is how to read the documentation of a CPU architecture and tools to write and debug assembly code.
> It also suffers from nonstandardisation of the vector instructions like ARM does, although you can reasonably assume FPU and MMX these days.
This is not correct. ARM has at least 7 different FPU ISAs: 5 versions of VFP and 2 versions of NEON. I have devices at hand with three different float units (all consumer devices). In x86 world you can rely on SSE2 safely, it's been around since Pentium 4 (1999) and is required on all 64 bit architectures (by contrast, NEON is rather new). But this is kind of a moot point since introductory assembly courses don't go too deep on floating point units anyway.
Additionally, in the ARM world, there's several revisions of the ISA/architecture being used, ARMv7 (32bit) and ARMv8 (64bit) and a dozen different variants for embedded products. And two different instruction encodings (thumb). It's not at all less confusing.
> AMD64 might be an interesting choice to start with these days.
For basic user space programming it probably doesn't make a difference but for bare metal/kernel programming, the AMD64 architecture is more, not less, confusing than the x86_32.
But in my opinion, it really doesn't matter what you learn first. The details of the ISA itself is of secondary importance, understanding how to read the documentation of the architecture and getting some hands on experience is way more important.
A Cortex-M3 or -M4 would be significantly nicer still for that reason (also it has a nice stripped down ISA), but I don't know of any systems with as much nice tooling as the R.Pi.
Granted, there's one major quirk on ARM CPUs. Instruction predicates, conditional execution for each instruction based on flags. However it's falling out of favor, because it requires CPU flags register to have a lot of read ports. That in turn limits frequencies, instruction reordering opportunities and consumes power. ARMv8 doesn't have predicates in 64-bit mode anymore.
It's same LoaDs [1] / STores [1], SUBstract / ADD / CoMPare, MULtiply / DIVide, SHift Left / SHift Right, XOR / AND / OR / NEGate / NOT and conditional BRanching / Bcc [2] based on flags-register everywhere. On top of that, if it's anything modern, there's usually FPU, vector extensions and MMU control.
[1]: But "MOV" on x86, "MOVE" on 680x0.
[2]: JMP/Jcc on x86. "cc" is short for condition code, like "Jump Equal", "Jump Not Equal".
So, back to my original question: I still think it's better to start with ARM because it's more useful. You can learn a little assembler then ship. You don't need to master assembler. For example, you might do a Mandlebrot and optimize your register usage to avoid touching memory and ship that app.
You can learn enough in an a few days to ship something that might be amazing on mobile or a Raspberry Pi. Perhaps there are some vector operations in ARM?
In order to use assembler you need a good reason because most optimizing compilers are good.
Mandelbrot you'd do anyways easily as a pixel shader. I'd guess it's trivial to get 60 fps full screen for something like 30 iterations. Second best option is using ARM NEON. But I doubt anyone is interested seeing another useless app in any store.
Amazing performance wise on Raspberry Pi needs to be written in Videocore IV assembler. 24 Gflops there. On RPi2, you could also try NEON vector instructions, but I doubt it can hold a candle to VCIV even if using all 4 cores.
And don't forget soon ARMv7 assembler is thing of a past. 64-bit ARMv8 is rather different to code for. In a few short years only place where you'll find 32-bit CPUs are cheap microcontrollers.
But anyways, it really doesn't matter which CPU architecture is used for educational purposes. 6502 would do. Or heck, PDP-11. For most programmers, it's enough to just have some idea how things work under the hood.