I'm an experienced C/C++ programmer and I occasionally look at the generated assembly to check for optimizations, loop unrolling, vectorization, etc. I understand what's going on the surface level, but I have a hard time understand what's going on in detail, especially with high optimization levels, where the compiler would do all kinds of clever tricks. I experiment with code in godbolt.org and look up the various opcodes, but I would like to take a more structured way of learning x86-64 assembly, especially when it comes to common patterns, tips and tricks, etc.
Are there any good books or tutorials you can recommend which go beyond the very beginner level?
I find reading assembly output from compilers to be a good start, it also helps you develop a mental model of what compilers expect in terms of stack hygiene.
Before godlbolt, https://godbolt.org/ there was `gcc -S` and now there is [3]
for interleaving source and assembly output. Keep the reference manual close and write lots of little experiments to confirm your findings.[1] https://en.wikipedia.org/wiki/GotoBLAS
[2] uses macros and intrinsics https://github.com/oneapi-src/oneDNN
[3] https://stackoverflow.com/questions/3867721/is-there-any-c-c...