The Binary Language of Moisture Vaporators
&gt; But to build a compiler, you need to be able to see the output. A disassembler had to be built along with the compiler.<p>Until very recently the dominant paradigm, at least for ahead-of-time compilers on Unix, was to emit textual assembler code and run a separate assembler on it behind the scenes. No disassembler needed, you can ask GCC or LLVM based compilers to just give you the intermediate data with -S.<p>&gt; But running obj2asm is a separate process, and the output is filled with all the boilerplate needed to create a proper object file. The boilerplate is rarely of interest, and I’m only interested in the generated code for a function.<p>Sounds like a bug in obj2asm. GNU objdump, for example, has handy -d and -D flags for disassembling only the code for one or all symbols.<p>&gt; One would think that the way to do this would be to have the compiler generate the assembler source code, which would then be run through an assembler like MASM or gas to create the object file. I figured this would be slow and too much work.<p>It was fast enough even for the very first C compilers... &lt;checks calendar&gt; 40 years ago. For actual compilations. Not to mention that when you as a human want to read the assembly code, it doesn&#x27;t matter how &quot;slow&quot; the -S flag&#x27;s output is. No matter how &quot;Alpha&quot; you are, the bottleneck will be you, the human.<p>&gt; Instead, the disassembler logic actually intercepts the binary data being written to the object file and disassembles it [...] I am not aware of any other compiler that does this in the same way.<p>The HotSpot JVM has -XX:PrintAssembly and -XX:CompileCommand=ClassName.methodName flags that do this in the same way.<p>Just like the author, I am not aware of any other, other compiler that does this in the same way. Because just like the author I haven&#x27;t bothered to check. But if I had to bet, I would bet that all major just-in-time compilers do this in the same way.