Compiler Digital Mars D; getting ASM output

I read a book by Andrei Alexandrescu about the programming language D. He is an excellent writer and does a good job explaining aspects of the language D. However, I find it difficult to understand some constructs when I cannot imagine the ASM output or the consequences of certain keywords (for example, in, out etc. Or other designs). Despite the fact that my ASM is pretty bad and I never use it, it helps me understand how certain keywords work on my computer and execute.

The DMD compiler has many interesting functions (code coverage, interface generation (header files), documentation generation, profiling, ...), but I did not see the switch for ASM code output. The compiler creates the .obj files and reads the following link: http://www.digitalmars.com/ctg/obj2asm.html I suspect that I need a tool to manually convert object files. I would prefer a compiler, is there one?

At the bottom of this page I will link to a page where I can pay for mentioning products containing this tool. Based on the GNU background, I frowned a lot. Is this only for C / C ++, or is it also related to the D compiler?

Is there any other way to convert these .obj files into readable ASM code, or should I resort to other D compilers (like GDC or LDC) to get the ASM output? I prefer not to do this. DMD is created by the founder himself, I am sure that he implemented most of the functions correctly / largely optimized.

So, how can I look into the ASM code?

Thanks.

+7
compiler-construction d dmd
source share
3 answers

You can try objconv . This is what I use. The reason DMD does not output assembler using the switch is because it never generates ASM as a discrete step. It generates binary opcodes directly from the internal representation. This is part of the reason it compiles so fast.

Or you can use the DMD obj2asm tool that comes bundled with DMD.

obj2asm somefile.o > somefile.s 
+7
source share

The obj2asm utility obj2asm provided by the DMD compiler suite, which is available for free (with dual GPL and Artistic licenses). See DMD Compiler for Linux on the D programming language website.

+9
source share

The Digital Mars compiler backend is commercially licensed rather than open source, possibly explaining why the tools related to the output file are also proprietary.

For educational purposes, you can try http://dgcc.sourceforge.net/ , which is the D front on the GCC server, thus fully open source.

-one
source share

All Articles