Making a Compiler: Difference between revisions

no edit summary
[unchecked revision][unchecked revision]
No edit summary
Line 12:
Pros:
* A compiler for the language you want and the target you want might simply does not exist.
* Educational, you get a better idea of [http://wiki.osdev.org/How_kernel[How kernel,_compiler compiler,_and_C_library_work_together and C library work together|how the kernel, compiler, and the run-time libraries work together]], and what it takes to implement a language.
* Speaking of, you can implement your own new programming language, right then and there! How cool is that?
* You can do just about anything with the program being compiled:
Line 25:
* Complete understanding of the language required. Always keep the official language spec at hand.
* Understanding of assembly specific to your target is also required.
* Most of the notes on [[Getting_StartedGetting Started#Getting_motivatedGetting motivated|OSDev motivation]] apply to compilers as well.
* It will be tricky to fully comply with the language spec.
* You would have to be really, really good at this if you wish to compete with GCC in terms of size/speed optimization of the compiled code.
Line 38:
* The "Target" is where the compiled program is meant to run.
* The "run-time" is a set resources (libraries, processes, etc) that exist on the Target. Two machines with identical hardware that differ in availability of run-time resources are sometimes thought of as different targets, as a program might run on one but not the other.
* The "[http://wiki.osdev.org/Executable_Formats[Executable Formats|executable]]" is a file containing information necessary for the Target to launch the program. It can be a flat binary, but is usually more elaborate, containing for example linking and re-location information.
* The "link" signifies that the program knows how to interface with the run-time, and relies on the run-time for some of it's functionality. It is created by the [http://wiki.osdev.org/[Linkers |linker]], and does not exist in free-standing programs (i.e. OS kernel).
 
If the host and the target are the same the product is a "native executable". This is what you see 99% of the time.
Anonymous user