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 ._. .
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.
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.
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.
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.
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.
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.