Tutorials / books on understanding assembly output [closed]
There are times when understanding disassemblies from higher languages such as C or C++ are useful. Reading a book on assembly is obviously a necessary part of understanding compiler output, but in my experience writing assembly code from scratch is quite a different thing than reading and understanding the opcodes a comp开发者_StackOverflowiler produces. The books i know on assembly don't cover that part very well, altough I believe if you ever get in touch with assembly then mostly by trying to understand compiler output.
Do you know good in-depth tutorials (or maybe books) on how to interpret compiler output?
What I have in mind would be a presentation of common high language idioms and how they are translated to assembly by common compilers (msvc and gcc).
Many similar questions here on SO:
- Learning Assembly
- Resources for learning ARM assembly
- Good x86 assembly book
Most posters aim to the same thing as you, that is read assembly code and not write new one.
Everything[*] I know about reading x86 assembly, I learned by single-stepping in a debugger in disassembly view. It's useful to have an opcode reference open at the same time, but to be honest you can live without most of the time, because as long as the compiler isn't optimizing too much, you know what it's actually doing from the C source, contents of variables, etc.
[*] Well, most things.
You could compile some c,c++ files and keep the assembler output (option -s I think) and compare the generated output to your source files.
This should help you to understand the generated assembler code and recognize repeating patterns (method/function calls, returns, loops, initialization etc.). Do not enable optimization this would transform the generated code and make it harder to understand.
精彩评论