Good way to learn x86-64 Assemlby

Hey,

Does anyone know a good book,pdf,website to learn modern x86-64 assembly?
For me it's currently hard to understand the instructions my c++ code generates, some things I have learnt by looking at the disassembly but many ppl suggest to learn writing assembly is the best way to understand assembly :P
And since I'm really interested in low level code optimizations I kinda have to learn it ._. .
Last edited on
it is a bit dated but the big black book of graphics programming has a ton of good stuff in it.
It is a book on how ID (doom game team) used assembly language. Its almost as much about asm as graphics. The registers are bigger and there are more commands but its not even about the code, its the mindset & approaches and all that are so amazing.


Last edited on
is it suited for asm beginners?^^
I need an tutorial of all the basics etc.
Write programs in C++ and disassemble them. Yes, I'm serious.
thats what i do all the time, but most of the time i don't understand whats going on there.
Godbolts Compiler Explorer helps a little bit to understand it with instruction information, but for whats going on with registers and so on i have no idea.
Last edited on
The assembly in the book varies in complexity from pretty simple to hefty, the assembly in it is dated anyway. It is the "way of doing things" that makes the book so good, not the code, though the code was good for the cpu family it targeted.

A couple of the basic concepts as an example of what it teaches:
-- you learn to look beyond the names and intended uses of the assembly keywords and commands and instead to look at exactly what the function DOES. For a very simple example multiply by 2 via a shift instead of the multiply command is faster.
-- you learn how to evaluate which commands are fast and which are slow, and to prefer the faster ones over the slower ones where possible
-- you learn about the U/V pipes and how to keep them busy

These are more skills and approaches than language specific. It takes you step by step on how they figured out which commands to use and how they tuned sections of code.
Last edited on
-- you learn about the U/V pipes and how to keep them busy

Intel CPU architecture changed a lot since 1993.
That is has :) ... as I said, its not the code but the approaches that I found valuable. Obviously knowing the best way to tune a single core 32 bit processor is of virtually zero value.
I can't explain it well, but the 'how to think about stuff' in that one really opened up assembly programming for me. /shrug if you can find it for 5 bucks somewhere, might be worth a look.

He is going to need something newer for practical purposes. Feel free to toss out a few titles.
Last edited on
Wish I had a recommendation. Intel manuals and tools (like IACA) are great, but getting to the level where they are useful is not easy. And since the op's motivation for assembly is "I'm really interested in low level code optimizations ", that's probably the level to aim to.
http://www.tantalon.com/pete/cppopt/main.htm

Note: some of that advice may have been outdated due to changes to C++. A lot of it should still be valid.
Last edited on
oh yeah, i already know this side, haven't seen it for a while.
yeah i think few numbers might be wrong with modern compilers~, but still a good starting source for a general performance overview.
In general, i just want to roughly understand assembly, to make it easier to read and know what my compiler has generated for me :P, but i find it kinda hard to get good modern assembly tuts.

I'm so nooby with asm, even Goldbolts asm overview already helped me :D
https://www.youtube.com/watch?v=bSkpMdDe4g4
Last edited on
disassembly is another story from writing and tuning your own.
the best way there might just be to write a few simple programs or functions, disassemble them, and use the internet to look up what each command does. You will learn a lot by doing that, but it is a tedious way to do it.
I recommend it though; if you want to learn to read disassembly, you should practice and study disassembly, and I don't know of ANY books on that. Most asm books are on writing it from scratch yourself, and human code does not look much like compiler code.

Registered users can post here. Sign in or register to post.