How can I see parse tree, intermediate code, optimization code and assembly code during COMPILATION?

While you can use the -fdump-tree-all and -fdump-rtl-all options in gcc, I don’t think that their output is very useful to a compiler student. FWIW, I started working on gcc as part of my PhD studies, having already completed two undergraduate courses, and I found gcc and its debug files to be opaque and hard … Read more

How Math.Pow (and so on) actually works

pow is usually evaluated by this formula: x^y = exp2(y*log2(x)) Functions exp2(x),log2(x) are directly implemented in FPU. If you want to implement bignums then they can also be evaluated by basic operators with use of precomputed table of sqrt-powers like: 2^1/2, 2^1/4, 2^1/8, 2^1/16, 2^1/32 … to speed up the process In case you need … Read more

How to disassemble a binary executable in Linux to get the assembly code?

I don’t think gcc has a flag for it, since it’s primarily a compiler, but another of the GNU development tools does. objdump takes a -d/–disassemble flag: $ objdump -d /path/to/binary The disassembly looks like this: 080483b4 <main>: 80483b4: 8d 4c 24 04 lea 0x4(%esp),%ecx 80483b8: 83 e4 f0 and $0xfffffff0,%esp 80483bb: ff 71 fc … Read more