Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

closed as off-topic by user16764, MichaelT, gnat, Kilian Foth, Bart van Ingen Schenau Mar 5 at 13:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – user16764, MichaelT, gnat, Kilian Foth, Bart van Ingen Schenau
If this question can be reworded to fit the rules in the help center, please edit the question.

    
How much assembly experience do you have? Have you ever tried using GCC without optimization to compile simple C programs into assembly, then reverse engineering the code back to a C program? –  Brian Aug 22 '11 at 18:07
8  
@Brian: I would need to know assembly before being able to do that. –  Billy ONeal Aug 22 '11 at 18:12
    
I have seen a copy of the x86 instruction set. It is 2 volumes, and probably the largest book I have ever seen. Have fun :) –  AngryBird Aug 22 '11 at 19:46
2  
Billy, If you know no assembly at all, then any of them would be pretty good to start from to get the general ideas. Assembly is extremely close to the architecture, so the assembly instructions greatly reflect architecture-specific designs. I started with x86 assembly, and read Kip Irvine's "Assembly Language for Intel-Based Computers". The book was actually paired with an online class at a community college though. I'm not sure what kind of learner you are, but I find guided instruction works best for learning. –  Brian Aug 23 '11 at 7:29
    
@Brian: What do you mean by "any of them"? I don't understand what "them" is -- any book? Any assembler? Any ISA? I've already played with MIPS assembler; I can't find anything on x86 though. –  Billy ONeal Aug 23 '11 at 13:01
show 2 more comments

5 Answers 5

up vote 12 down vote accepted

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.

share|improve this answer
1  
Very good book! –  Coder Aug 22 '11 at 22:40
    
I read the 5th edition of Irvine's book when it was titled "Assembly Language for Intel-Based Computers". :) –  Brian Aug 23 '11 at 7:33
add comment

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.

share|improve this answer
    
Not really going for performance; just want to be able to generate binaries. Will still take a look :) –  Billy ONeal Aug 22 '11 at 18:13
2  
You will also need to learn how to use a particular assembler, not just the assembly opcodes. Each assembler does things totally differently. If you are going to write a lot of assembly code, use masm as it was developed with human coders in mind. If you're just going to write little snippets of inline assembly, you could use gcc with GNU as (also called gas) inline assembly. GNU as' syntax is completely different from masm's. As was written primarily for use as the back end for gcc, to do the executable code generation, and so does not provide many of the features that human coders want. –  Michael Crawford Aug 22 '11 at 18:19
add comment

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.

share|improve this answer
1  
Another suggestion: Write a simple program in C, compile it to assembly, clean it up so your assembler can assemble it, then enhance the assembly version. It's a good way to get some minimum functionality (read from the keyboard, write to the console) going quickly. –  TMN Aug 22 '11 at 21:23
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

protected by MichaelT Mar 4 at 20:06

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.