We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
http://en.wikipedia.org/wiki/List_of_compilers 选择了许可证类型为“open”的许可证来源”
http://en.wikipedia.org/wiki/List_of_compilers chose ones with License type "open source"
我建议拿起一本编译器教科书。他们解释了编译器所需的所有组件,并且通常从头到尾开发编译器。
我拥有一份来自我的编译器课程的Java 中的现代编译器实现,并且我我对此很满意。
I would suggest picking up a compilers textbook. They explain all the required components of a compiler and usually develop a compiler from start to finish.
I own a copy of Modern Compiler Implementation in Java from my compilers course and I'm quite pleased with it.
您是否想了解如何构建编译器,或者是否想了解 Win32 可执行文件的内部结构?
如果是前者,那么阅读一本关于如何创建编译器的书将比尝试对源代码进行逆向工程更有效。编译器与您见过的任何东西都不同,让作者引导您了解所使用的原理以及常用技术和工具确实很有帮助。还值得指出的是,编译器是分阶段构建的,只有在实现的最后阶段,您才需要了解您所针对的 CPU 和操作系统。如果您对编译器构造不熟悉,那么在进入该阶段之前您需要了解很多知识。
但是,如果您想了解 Win32 可执行文件的格式,那么您需要了解 x86(或 x64)汇编代码和可移植执行 (PE) 文件格式(Windows 用于可执行文件)。有关 x86 汇编代码的介绍,我推荐 Paul Carter 博士的优秀“PC 汇编语言”免费电子书 http:// /www.drpaulcarter.com/pcasm/ 对于 PE,我从这里开始 http://msdn.microsoft.com/en-us/magazine/cc301805.aspx 和 http://msdn.microsoft.com/en-us/magazine/cc301808.aspx
Are you trying to understand how to build a compiler or are you trying to learn what a Win32 executable looks like internally?
If the former then reading a book on how to create a compiler will be way more efficient than trying to reverse engineer source code. Compilers are unlike anything you've ever seen and it really helps to have an author walk you through the principles and common techniques and tools used. It's also worth pointing out that compilers are built in stages and it's only towards the end of the implementation do you need to have any knowledge of the CPU and operating system that you are targeting. If you are new to compiler construction then you have plenty to learn about before you'll get to that stage.
However if you want to understand the format of Win32 executables then you need to understand x86 (or x64) assembly code and the Portable Execution (PE) file format (which is used by Windows for executables). For an introduction to x86 assembly code I'd recommend Dr Paul Carter's excellent "PC Assembly Language" free eBook http://www.drpaulcarter.com/pcasm/ and for PE I'd start here http://msdn.microsoft.com/en-us/magazine/cc301805.aspx and http://msdn.microsoft.com/en-us/magazine/cc301808.aspx
gas
可以将汇编语言转换为目标代码,ld
然后可以链接到适当的运行时以生成程序。gas
can turn assembly language into object code, whichld
can then link with the appropriate runtimes to generate a program.如果您的目标是了解编译器如何工作和/或如何编码,那么您真的应该阅读一本有关该主题的书。但是,在查找源代码示例时,请尝试 Pascal 编译器示例,例如 这个。
Pascal 的语法有些简单,并且在许多书籍中都有实现。
If your objective is to learn how compilers work and/or how to code then, you really should read a book on the subject. However, when looking for source code samples, try Pascal compilers samples like this one.
Pascal is has a somewhat simple grammar and is implemented in many books.
最简单的编程语言是汇编语言,准确地说是 x86 汇编语言。最著名的汇编器 NASM 是开源的;你可以在以下位置查看它的来源:
http://repo.or.cz/w/nasm。 git
NASM 具有确实被“编译”成汇编语句的宏。尽管它不是一种成熟的语言,但它专注于基础知识。
The simplest programming language is Assembly, x86-assembly to be precise. The most famous assembler, NASM, is open-source; you can check out it's source at:
http://repo.or.cz/w/nasm.git
NASM has macro's which are indeed "compiled" into assembler statements. Though it's not a fully fledged language, its focused on the basics.
我建议寻找 MS-DOS 的 Pascal、C 或 SmallC 编译器源( 16 位)。特别是如果它们将自己限制为 16 位平面实模式(<= 64KB 内存模式),那么它们应该相当简单。
对分段实模式的支持会增加大量的复杂性,最好避免这种情况,并且它与 32 位平面保护模式程序(非操作系统 32 位编程)无关。
对于非 x86 处理器,Jack Crenshaw 系列文章的示例程序“让我们构建一个编译器 “这是一个类似 Pascal 的语法编译器,针对 Motorola MC68000 16/32 位处理器。还有 Marcel Hendrix 在 win32 上用 Forth 编写的该系列的版本。
还有TCC - Tiny C 编译器,支持PE-i386 输出(即Win32)。
不过,如果您懒得阅读 Firas Assaad 在评论中给出的整个 SO 链接(其中包含除其中一个链接之外的所有链接),我相信您会发现编译器的源代码非常长。
I would suggest looking for a Pascal, C or SmallC compiler source for MS-DOS (16-bit). Particularly if they limit themselves to 16-bit flat real mode (<= 64KB memory mode), they should be fairly simple.
Support for segmented real mode adds a great deal of complexity that would be best to avoid, and it is irrelevant for 32-bit flat protected mode program (non-OS 32-bit programming).
For a non-x86 processor, the example program for Jack Crenshaw's series of articles "Let's Build a Compiler" which is a Pascal-like syntax compiler targeting the Motorola MC68000 16/32-bit processor. There is also Marcel Hendrix's written in Forth on win32 version of the series.
There is also the TCC - Tiny C Compiler, which support PE-i386 output (i.e. Win32).
Though if you couldn't bother to read the entire SO link that Firas Assaad gave in the comments, which contains all but one of these links, I believe you're going to find the source code of a compiler terribly long.