

Guide to x86 assembly - georgerobinson
http://www.cs.virginia.edu/~evans/cs216/guides/x86.html

======
big_youth
This is a useful tool to view the assembly of code in the browser.

[http://gcc.godbolt.org/](http://gcc.godbolt.org/)

~~~
pan69
This is indeed pretty awesome. I wish I had this 20 years ago.

------
melling
With ARM used for mobile, would it make more sense to learn it because these
less powerful processors might provide more opportunity to use assembler?

~~~
exDM69
Two questions come to my mind: which "flavor" of ARM? And what hardware would
it run on? There's no "standard ARM" computer like the x86 has the de facto PC
standards (peripherals, firmware, etc).

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.

~~~
pjc50
The RISC "core" of the ARM instruction set is both simple enough to learn
(sixteen registers of which the last two are special, almost all instructions
work equally on all registers) and works unmodified across a range of systems.
It's a popular choice in "intro to assembly" courses for this reason.

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.

~~~
exDM69
Well I agree that the ARM instruction set is more elegant, but I don't see it
as a big enough improvement to warrant the extra hassle of getting set up.
It's too easy for the student to get confused with all the tools and spend
less time on the actual matter at hand.

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.

~~~
pjc50
I meant "you can assume an x86 system will have a floating point unit and
MMX", and you've explained that SSE2 is also a reasonable assumption.

------
cahruhr
There's an updated PDF version at
[https://github.com/aaronbloomfield/pdr/tree/master/book/x86](https://github.com/aaronbloomfield/pdr/tree/master/book/x86)

------
e12e
Also recommend:

[http://www.drpaulcarter.com/pcasm/](http://www.drpaulcarter.com/pcasm/)

------
Yhippa
Oh wow. This thing is what we used over 10 years ago when I was a student
there. I loved how you could call assembly code from a C++ routine.

