数字Mars D编译器;获取ASM输出
我正在读 Andrei Alexandrescu 写的关于 D 编程语言的书。他是一位出色的作家,并且在解释 D 语言的各个方面做得非常好。然而,当我无法想象 ASM 输出或某些关键字(例如 in、out 等或其他构造)的结果时,我发现某些构造很难理解。尽管我的 ASM 非常糟糕并且我从未使用过它,但它对我能够理解某些关键字如何在计算机上发挥作用以及正在完成的工作有很大帮助。
DMD 编译器有许多有趣的功能(代码覆盖率、生成接口(头文件)、生成文档、分析等),但我还没有看到输出 ASM 代码的开关。编译器确实生成 .obj 文件,并通过阅读以下链接:http://www.digitalmars。 com/ctg/obj2asm.html 我怀疑我需要一个工具来手动转换目标文件。我想要一个编译器开关,有吗?
在该页面的底部,我链接到一个页面,我可以在其中为提及包含该工具的产品付款。来自 GNU 背景的我对此非常不以为然。这仅适用于 C/C++,还是也适用于 D 编译器?
有没有其他方法可以将这些 .obj 文件转换为可读的 ASM 代码,或者我必须求助于其他 D 编译器(例如 GDC 或 LDC)来获取 ASM 输出?我宁愿不这样做。 DMD 是由创始人本人创建的,我确信他正确/很大程度上优化了大多数功能。
那么,如何查看ASM代码呢?
谢谢。
I am reading the book from Andrei Alexandrescu about the D programming language. He's an excellent writer and does a pretty good job at explaining aspects of the D language. I however find certain constructs hard to understand when I cannot imagine the ASM output or consequences of certain keywords (such as in, out, etc. or other constructs). Even though my ASM is pretty bad and I never use it, it helps me a lot to be able to understand how certain keywords work out to the computer and the work being done.
The DMD compiler has many interesting features (code coverage, generating interfaces (header files), generating documentation, profiling, ...) but I haven't seen a switch to output ASM code. The compiler does generate .obj files, and from reading the following link: http://www.digitalmars.com/ctg/obj2asm.html I suspect I need a tool to convert the object files manually. I would prefer a compiler switch, is there one?
On the bottom of that page, I get linked to a page where I can pay for the products mentioning containing that tool. Coming from a GNU background I highly frowned up on that. Is this for C/C++ only, or does this also apply for the D compiler?
Is there any other way to convert these .obj files to readable ASM code, or must I resort to other D compilers (such as GDC or LDC) to acquire ASM output? I prefer not to. DMD is created by the founder himself, I'm sure he implemented most features correctly / largely optimized.
So, how can I take a peek at the ASM code?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
obj2asm
实用程序由 DMD 编译器套件提供,可免费使用(在 GPL 和 Artistic 双重许可下)。请参阅 D 编程语言网站上的 Linux 的 DMD 编译器。The
obj2asm
utility is provided by the DMD compiler suite, which is available for free (under a dual GPL and Artistic license). See DMD Compiler for Linux on the D Programming Language website.您可以尝试 objconv。这就是我用的。 DMD 不通过开关输出汇编程序的原因是它从不生成 ASM 作为离散步骤。它直接从其内部表示生成二进制操作码。这是它编译速度如此之快的部分原因。
或者您可以使用 DMD 附带的 DMD obj2asm 工具。
You could try objconv. It's what I use. The reason DMD doesn't output assembler via a switch is because it never generates ASM as a discrete step. It generates binary opcodes directly from its internal representation. This is part of the reason why it compiles so fast.
Or you can use the DMD obj2asm tool which comes packaged with DMD.
Digital Mars 编译器的后端是商业许可的,而不是开源的,这也许可以解释为什么与后端输出相关的工具也是专有的。
出于教育目的,您可以尝试 http://dgcc.sourceforge.net/ 这是一个 D 前端GCC 后端,因此完全开源。
The Digital Mars compiler's backend is commercially licensed, not open source, perhaps explaining why tools relating to the backend output are also proprietary.
For educational purposes you might try http://dgcc.sourceforge.net/ which is a D front end on the GCC backend, thus entirely open source.