Every now and then, when coding in C++, I find myself needing to know some assembly to understand what’s going on. Sometimes, it’s because I am actually writing assembly code, such as when I was writing the new atomic classes for Qt. More often, it’s because I need to read the assembly generated by the compiler to figure out if it’s optimal or if it’s doing something weird.
So I often found myself downloading the same manuals over and over. I decided to put together a small library of manuals I use often and those I seldom use, but might want to some day. This is the list.
Of course there are more architectures. Those are just the ones that are (somewhat) relevant to me a Qt developer. Also, please note that I have not looked with detail into the POWER and SPARC manual, other than a cursory glance to ensure that they contained the relevant information. For example, one site I found says that Linux 32-bit on PowerPC uses an ABI different than that defined by power.org.
I have not listed quick reference guides, many of which exist. I don’t use them because I often need details of the instructions.
What do you usually use when you code in assembly?
Additional IA-32 and x86-64 resources
The IA-32 ans x86-64 architectures contain a very big number of extensions that are added in different generations of the processors, both by Intel and AMD. The manuals above include the main extensions: MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2 and AVX, plus the AES, FMA, F16C, RDRAND ones. It does not include extensions specific to AMD processors, like 3dNow! (effectively deprecated), SSE4a, FMA4 or XOP.
Other useful manuals:
- Intel® Advanced Vector Extensions Programming Reference (includes AVX2, BMI1, BMI2 references)
- Intel® 64 and IA-32 Architectures Optimization Reference Manual
- AMD64 Architecture Programmer’s Manual Volume 3: General Purpose and System Instructions
- AMD64 Architecture Programmer’s Manual Volume 4: 128-bit and 256 bit media instructions
- AMD64 Architecture Programmer’s Manual Volume 5: 64-Bit Media and x87 Floating-Point Instructions
Additionally, most of the non-general purpose instructions have intrinsic functions associated with them, so you can write really low-level code in C or C++ without actually having to write assembly. Unfortunately, I haven’t found a good, downloadable, and up-to-date intrinsics reference manual. The Intel(R) C++ Intrinsics Reference is the closest I’ve found, but it stops at SSE4 intrinsics, not including the AVX or AES ones.
If you know of one, please leave me a comment.
Glossary
- ABI
- Application Binary Interface
- ILP32
- int, long, pointer are 32-bit, virtually all 32-bit platforms (all of the ABIs listed here)
- LP64
- long and pointer are 64-bit, the 64-bit environment of all Unix platforms here
- LLP64
- long long and pointer are 64-bit, but long is 32-bit; the 64-bit environment of Windows
3 comments
2 pings
Andre
January 10, 2012 at 07:03 UTC (UTC 0)
I’ve never found better intrinsics documentation either. I often use the AMD Instruction Reference (Programmers Manual Volume 4) because I find it to be the most clearest and try out in my IDE if intrinsics exist.
For learning I always find the AMD Software Optimization Guide for AMD Family $family very valuable. It contains a lot of different hints and examples for writing optimized code, including cache / memory / branch optimizations etc. pp.
http://developer.amd.com/documentation/guides/Pages/default.aspx
Kevin Kofler
January 10, 2012 at 08:05 UTC (UTC 0)
For x86, NASM used to have a nice instruction reference in its manual. Unfortunately, they dropped it (replaced it with a complete, but uncommented list) in recent versions. However, it’s still downloadable from SourceForge mirrors: the last version was nasm-0.99.02-xdoc.tar.bz2 from 2007 (which doesn’t mean new instructions as of 2007 are included though).
e8hffff
January 10, 2012 at 09:54 UTC (UTC 0)
Good move.
Architectures and ABIs detailed » Thiago Macieira's blog
January 10, 2012 at 22:22 UTC (UTC 0)
[...] Assembly developer’s libraryJan10 Architectures and ABIs detailed Categories: Assembly by Thiago MacieiraYesterday I wrote about [...]
Machine Code History | Digital Fanatics
January 13, 2012 at 22:59 UTC (UTC 0)
[...] a more modern context, here and here is a list of instruction set manuals and ABI (Application Binary Interface, i.e. calling [...]