开发者

Tutorials / books on understanding assembly output [closed]

开发者 https://www.devze.com 2023-01-27 15:03 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消