25

There are lots of books on assembly. However, they usually deal with ISAs about which I don't care, such as MIPS or ARM. I don't deal with these architectures; there's no reason for me to try to learn them.

But x86 assembly books seem... nonexistent.

Let's say for example I'm trying to build a toy compiler generating Windows Portable Executable files.

Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information on x86 assembly? What about that book makes it special?

Matthieu
  • 4,599
Billy ONeal
  • 8,083

5 Answers5

18

I used Assembly Language for x86 Processors as a textbook when I was in college and found it very easy to understand. I have the older fourth edition and compared it to the sixth edition and didn't notice much change, so you could probably pick up an older copy cheap. People complain about his use of his own library for I/O, but he tells you how to do it the "hard" way in latter chapters.

dboss
  • 596
18

The obvious place to go is Intel's website, where you can find programming and reference manuals for download that contain everything there is to know about the x86 architecture.

Here: IntelĀ® 64 and IA-32 Architectures Software Developer's Manuals

Jesper
  • 2,599
9

The Art of Assembly Programming is an excellent resource that has quite a bit about x86 programming.

x64 ABI documentation is also useful. I was trying to find a link to the version that was on AMDs website, but I can't seem to find it anymore, so I guess this one will have to do.

Something that can help quite [a bit] while learning is, instead of trying to write a complete app from scratch in assembly, instead write most of it in C (or any other compiled language really) and then call a chunk of assembly code from that. Once you've done that, reverse it, write an assembly program, and call some C functions from that.

Edit: Fixed a typo.

Orclev
  • 221
4

A very good book for learning x86 Assembly is Pentium Processor Optimization Tools. While the book's main focus is the optimization of assembly code, it teaches Pentium assembly along the way, and is a good reference book as well.

It is long out of print but is not hard to find used.

It comes with a floppy disk containing an "assembly code optimizer". It does not actually optimize your code, but instead produces a commented listing that points out where inefficiencies such as pipeline stalls lie.

The tool that comes with a book is a limited version of a more featureful product that the author's company used to sell, but for reasons I am unfamiliar with they are long out of business. I don't know why - I would think such a tool would sell like hotcakes.

x86 in general is a very complex topic as there are many variants that are supported by different models of microprocessors. Once you know the basics you will want to consult Intel's or AMD's databooks for the precise chip you are targeting. Unfortunately code that runs fast on one model of CPU may not be as fast on a different chip.

Matthieu
  • 4,599
1

Why not try the wikibook - http://en.wikibooks.org/wiki/X86_Assembly. It gives a good introductory start to assembly language.

The hard bit about assembly is realising how simple it is, and that you need to stay with that simplicity.