Hacker News new | past | comments | ask | show | jobs | submit login
The Art of Assembly Language Programming (wustl.edu)
131 points by wyclif on Aug 11, 2011 | hide | past | favorite | 40 comments

If you aren't fluent in assembly language, the biggest marginal benefit you get from learning it is the ability to read the assembly output from your C compiler for debugging or low-level optimization. For that purpose I've always recommended these two old MSDN columns by Matt Pietrek on Just Enough Assembly Language to Get By:

Part 1: http://www.microsoft.com/msj/0298/hood0298.aspx

Part 2: http://www.microsoft.com/msj/0698/hood0698.aspx

They're outdated in some ways but still relevant.

Once you have the fundamentals down, the best source for up-to-date knowledge relevant to performance optimization and assembly programming for x86 machines is Agner Fog's manuals:


That said, there is a lot of room for improvement on Matt Pietrek's columns. This is a great blog post series waiting to happen for anyone up to the task. Take out the cruft about ENTER, LEAVE, LOOP, etc, include more about basics like signed/unsigned comparisons (JG/JGE/JL/JLE are the signed counterparts of JA/JAE/JB/JBE, where the mnemonic is that 'A' stands for above and 'B' for below), and so on. I'm trying to get an assembly guru and technical blogger coworker of mine interested in writing this. If that doesn't work, maybe I'll have to roll up the sleeves and write it myself.

Well, that depends on your needs, actually.

If you want to write trainers for video games, knowing Assembly is a must!

Well, sorta. Knowing just enough to get by, and being able to look up the rest is good enough.

I used to write trainers for the original XBox. Unlike PC trainers, which can often rely on simply putting the same value in the same memory location over and over, XBox required that you modify the code in memory.

I still do it for PC games occasionally, but it's gotten harder... Windows seems to try to prevent hacks by loading the code into different places in RAM each time.

tl;dr - There are still uses for Assembly other than just debugging.

I said the greatest marginal benefit was from debugging. I didn't say it was the only one. :)

"Your knowledge of assembly language will help you write better programs, even when using HLLs."

Assembly was the first real coding I did after learning BASIC. It taught me:

1) How to build and structure an application - from intrinsics like 'divide' upwards, I now seem more able to build large/complex systems than people who only learnt HLLs

2) Fundamental datatypes like DWORDs that have helped me optimise performance of HLL apps

3) To appreciate the heavy lifting provided by a language like Ruby - and an understanding of how it does what it does

Application developers that have never worked on the bare metal are poorer for it.

This is also somewhat dated, although it does make it as far as the Pentium, and it is a brilliant read.

Graphics Programming Black Book - Michael Abrash


Some funny quote showing it is dated :)

"If a program requires 1.5 megabytes, it will not fit on a 1.44 Mbyte floppy. Likewise, if an application requires 2 megabytes RAM, the user will have to install an extra megabyte if there is only one available in the machine. Even on big machines with 32 or more megabytes, writing gigantic applications isn't excusable."

Double the numbers, substitute "mega" with "giga" and "floppy" with "usb stick" and it's up to date again. :)

For a short while, anyhow.

It is surprising how many people are willing to speak out against assembly language based only on conversations they've had or articles they've read.

Most people will speak out against any language because of some troll or flame-war they've followed on the Internet.

If you want to learn assembly, do it. There doesn't have to be a practical application. You can learn something just because you think it's cool. It's not always about the salary or the market-usefulness of each skill you learn.

There is a much newer version of this book that uses HLA.


The No Starch Press book is really just the Nutshell book for HLA, a language of the author's invention that is a cross between x86 assembly and Pascal. This web site, on the other hand, appears to be the contents I was expecting to find in a book titled "The Art of Assembly Language".

Why oh why did the author give both of these very different creatures the same title?

Speaking of, it looks like there are at least three different versions here for free:


This is not a good book if you want to learn assembly. Instead the author will teach you his own language HLA (High Level Assembly), which is actually more like Pascal with some assembly mixed in. The writing style is also incredibly verbose.

I don't know a good comprehensive book about modern x86 assembly. Can you recommend one?

These are pretty indispensable when it comes to modern x86 assembly: http://www.intel.com/products/processor/manuals/

Not only the assembly language but also the organization of a whole x86 based computer architecture, including memory buses and interrupt controllers and whatnot. I've spent weeks reading these things and trying to figure out how a modern operating system is built with the hardware at hand.

Every piece of hardware should have a manual like this!

Also keep an eye out for the printed version. Every now and then Intel offers the printed version for free (including shipping).

No, this book is about x86 assembly language. You are thinking of the newer versions that use HLA.

I haven't had the need to write assembly language programs in years. However, I've still found x86 assembly quite useful to know due to having to reverse engineer binaries and DLLs.

So knowing x86 still has some practical value, and with reverse engineering, just knowing a small subset of x86 will go a long way.

"Unfortunately, MS-DOS is not a modern multitasking operating system and it does not support shared memory. However, we can easily write a resident program that provides this capability missing from DOS. The following sections describe how to create two types of shared memory regions - static and dynamic."

One word: badass.

Darn. All the exercises and labs appear to be missing. Anyone know where else to find them? Or am I not missing anything by not having them?

I don't consider myself a "real" assembly programmer. I can, however, try to debug compiled c code via gdb disassemble and not get totally lost.

I managed to pick up this ability after getting to know assembly programming, and the subsequent "higher level manifestations" in C/C++, from Paul Carter's open source ebook: http://www.drpaulcarter.com/pcasm/

When I first downloaded this book in 2002, I was fairly comfortable with the linux command line, gcc and emacs, but I knew nothing about assembly and computer architecture (registers/interrupts etc).

Whereas other books on assembly were somehow tied to DOS, this was a free book that wasn't tied to any OS and was easy to understand.

Along with JWasm -- http://www.japheth.de/JWasm.html -- and DOSBox, this can make for a lot of fun.

Assembly provided me with my "there is no spoon" moment on the arduino platform. It's easy to pick up and suddenly, you know kung-Fu.

I enjoyed the practical approach. I started off with 8086 in the Microprocessor lab, played with motor Rotations- Serial port and parallel port communication, keyboard interfacing, DOS Interrupts,LED interfacing etc. It was the most amazing time of my career. I fell in love with microprocessors.

I always feel these books on assembly are like car user manuals. The knowledge of driving is far from that.

Don't get me wrong, I appreciate the free book. But there's a need for a good assembly book to learn the ropes.

This one is decent. Its teaching style is basically "assembly as a first programming language".


I'd hate to be in the passenger seat when you break down.

Looks like it might have been nice were not so x86-specific, and obsolete x86 at that.

Yeah. These days it's ARM assembly that I care about.

Little offtopic: I think the layout and the colors of this site are great!

Any recommendations for learning AMD64/x64 assembly programming?

Writing it. Lots of it. Assembly is not a language that you can grok by looking at it. Use the official Intel manuals for reference. There are lots and lots of deprecated/incomplete/incorrect assembly language references out there.

I got my black belt in assembly by writing a 1 kilobyte software synth for a 4k intro that was never finished (but the synth was playable). That was one cool project!

Rosasm is the best!

Are you betov, the author of Rosasm?

I am not. I am making fun of endless battles betov and rhyde had on usenet.

"Converting CFGs to assembly language" Nice we didn't cover how to actually implement it in our theoretical computer science class.

Nice post, however it's a bit dated I wonder if there is a newer version.

The Art of Assembly is, itself, an immensely useful and dated piece of work. I remember flipping through this years ago. Certainly worth the read, though it's likely not worth pouring one's self into too far, as it isn't so easily applicable these days.

...unless maybe you want to write highly-optimized code for special applications, or maybe to write compiler code generators. Assembly language knowledge is still useful otherwise to understand what the machine really does.

Someone has to write the systems code you depend on.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact