Introduction
No lecture description
Description
Learn to create your very own C compiler from scratch. In this course we develop a compiler that compiles a subset of the C Programming Language. By the time you finish all modules of this course you will be able to compile C programs that use pointers, structures, unions, arrays, functions, for loops, while loops. do while loops, if statements, switches and much more! This course includes all course modules!
Our compiler also has a preprocessor macro system allowing you to include header files and create definitions just like you would in any C file.
Your compiler is advanced enough to use the GCC standard library so we are able to call C functions from our compiler. Your compiler will be able to compile the C programming language.
This course does not rely on any frameworks we do everything from scratch to ensure the best possible learning experience for students
Module 1
In module 1 of this course we load our C source file that we wish to compile, into memory. We create a lexer to preform lexical analysis on the source input which will convert the source code into a bunch of tokens that our compiler can easily understand. We then pass the tokens through a parser to produce an abstract syntax tree. An AST describes the C program in a logical way that makes it easier for our compiler to understand. For example for the expression 50 + 20 you will end up with a root expression node that has a left operand that has a node of value 50 and a right operand that has a node of value 20. Breaking down problems in this way makes it much easier to create compilers.
Module 2 & 3
In module 2 and 3 of this course we create a code generator that produces 32 bit Intel assembly language that can then be passed through an assembler to produce a program binary that we can run. We also in this module create a resolver system which is responsible for taking a complicated expression such as "a->b.c.e[50] = 50" and breaking it down into simple steps and rules that our code generator can then easily follow. This abstraction is essential to ensure that the code generator does not become over complex. With the use of a resolver system we can ensure the code base remains clean.
Module 4
In module 4 of this course we create a preprocessor and macro system. This preprocessor system allows us to include header files in our C programs and also use a variety of macro keywords such as "#define" "#ifdef" , "sizeof" and many more.
Module 5
In module 5 we build a semantic validator which validates our C code. A semantic validator ensures that we are not setting variables that do not exist or accessing structures that arent there.
This is the only video course in the world that shows you how to create a C compiler, come and learn today!
Requirements
-
You must have a basic experience of assembly language.
Who This Course is For
People with an interest in compiler design
People who are interested in assembly language
People who are interested in the C Programming language
What You Will be Learn
How to build a C compiler from scratch
Full understanding of stackframes and how assembly language is generared for a C source file
Complete Understanding of lexical analysis and parsing
Stronger Assembly language skills will be gained
Compiler Design

Dragon Zap Instructor
Daniel McCarthy is a seasoned software engineer, boasting an impressive career spanning over 14 years in the industry. Holding a Master's Degree in Advanced Computer Science from Cardiff Metropolitan University, his broad spectrum of experience encompasses everything from web development to complex compiler and interpreter development. Daniel has honed his skills in bootloader and kernel development. In testament to his proficiency in the field, he has designed two proprietary programming languages: Craft, a general-purpose language, and Marble, a web-focused language akin to PHP. Moreover, he has successfully developed compilers for the C programming language. A testament to his versatility, Daniel demonstrates proficiency in an extensive list of programming languages that includes C, C++, Java, x86 Assembly language, PIC assembly, SQL, PHP, HTML5, JavaScript, CSS, and of course, his own creations, Craft and Marble. His professional portfolio also includes the development of Linux kernel modules, a task he has executed with proficiency in a professional context. Currently, Daniel is channeling his wealth of experience and expertise into the education sector, with the aim of nurturing the next generation of professional software engineers.
Ask a question
Questions (8)
Hugo Rozas
2 years ago
The Module 3 is not yet completed, no?; In the index list it says "Uncategorized" and also the lesson "200. Creating the define macro" don't looks like be the last one, also I dont see atachments (source code).
Daniel McCarthy
2 years ago
Hi Hugo, Yes its completed it is currently being uploaded that is why its uncategorized, it is unforunate but the staff member responsible for uploading took a wedding vacation without informing Dragon Zap so there has been delays with this, apologies for the inconvinence he has told me personally that he will finish uploading my course by Saturday I will hold him to that as I know everyone at Dragon Zap personally. Thanks
arup dash
2 years ago
I am using mac m2. can I follow this course on a VM with linux installed ? the processor is not x86. so ?
Daniel McCarthy
2 years ago
Yeah its not a problem it just might run a bit more slow depending on the processor. If your Mac processor has a compatible instruction set with x86 instruction set then youll be able to do emulation on the hardware its self which is faster, this is automatic in most cases due to virtual box having virtualization enabled. However if you dont have a comaptible instruction set the emulation will be slower as it will be in software only. However this shouldnt impact your ability to follow the course
arup dash
2 years ago
I think m2 uses ARM architecture so even if I install linux through VM. it wont be enough. right? I need to have a linux machine for this course?
arup dash
2 years ago
Hey Daniel, waiting for your reply.
Daniel McCarthy
2 years ago
Hi, My original advice applies, you should use a virtual machine with Linux installed on it. You shouldnt have a problem. Also I believe there are ARM Linux distributions so you should be fine, even if you choose AMD or Intel distribution it will be emulated so dont worry. For faster contact you can reach me directly daniel@dragonzap.com Apologies for the delay Thank you Dan
Daniel McCarthy
2 years ago
Here are the steps install virtual box software, download Ubuntu ISO from Ubuntu website, create a new virtual machine on virtual box software, attach the ISO as a disk image on the virtual box software, now install ubuntu on the virtual machine, I found a tutorial online for you for installing virtual box on Mac: https://www.youtube.com/watch?v=hd0Lbtly41Y
Dele kasim
2 years ago
Hi Dan, do you plan to make Modules 2 and 3 availabley on UDEMY at some point in the future
Daniel McCarthy
2 years ago
Hi dele No module 2 and 3 will not be released on udemy at any point in the future . Only dragonzap are allowed to sell module 2 and 3. This was a hard decision but neccessary. Udemy instructor share was significantly reduced last year and to keep providing high quality content I have to remain profitable. Dragon Zap provide generous royalty payments. Thanks Dan
Lane Beals
2 years ago
Does your assembly course on Udemy cover enough assembly material for what's used in this course?
Daniel McCarthy
2 years ago
Yes but I can also provide a discount for the assembly course on Dragon Zap so please send me an email at daniel@dragonzap.com for that
Hugo Rozas
2 years ago
Hi Dan, Module 4 is finished (242-249)?; The title there says "Uncategorized"; Also I not see there Source Code like the other modules.
Daniel McCarthy
2 years ago
Hello Hugo, Thanks for letting me know I will get the upload team to fix this Dan
Konstantin2013july
3 months ago
Hello Dan! Thank you for a great course! Do you have any books which you can recommend, so I could extend your example compiler by classes and exception handling? Thank you!
Daniel McCarthy
3 months ago
Hello Konstantin, You are welcome. I have not yet written a book on compiler development and I have never read any compiler development books. I did however write my bachelors dissertation on compiler development however I wrote that nearly 10 years ago so my experience has improved since then. If your interested I uploaded it for you here: https://we.tl/t-W06apOoOSR Kind regards,
Konstantin2013july
3 months ago
Hello Dan! Thank you for your answer! Of course I'm really interested. But by your link I see only some art to download, maybe you can upload it to Google drive? And another point, I saw your answers about Udemy and just want to let you know - maybe it's just my experience, but Udemy was the only way for me to find out about your Compiler and OS courses. I couldn't even imagine that such courses exists, but again - it can be only my case, so it's just for your information.
Daniel McCarthy
3 months ago
Thanks for the information, Dragon zap continues to promote my content on Youtube and various platforms but more needs to be done to make the courses more known. I don't have google drive but if you drop me an email daniel@dragonzap.com I will email you the whole PDF over free of charge Thanks
Tyler Roberts
3 months ago
Dose this c compiler allow us to compile C into runnable code. The reason is we convert the code to nasm but do we make a nasm to machine code step?
Daniel McCarthy
3 months ago
Hello Tyler, Thanks for your question, the course is designed to teach you how to make a compiler not an assembler, therefore we compile only to assembly language. If you wish to make an assembler you can use the skills you learned in the parsing part of this course and build an assembler based on the Intel instruction manual and generate the opcodes manually. An assembler would of added another 10 hours to the course so I considered it off-topic
Tyler Roberts
2 months ago
in gcc compiler you can compile multiple C objects together using ld dose this compiler allow that or is it just a single .c to .bin?
Daniel McCarthy
2 months ago
Hello Tyler, yes we compile only to assembly language in the course. We do not create an assembler, just a compiler that takes C and produces assembly. Therefore its very possible for it to be assembled and linked with multiple objects.
Tyler Roberts
2 months ago
i mean can the C compiler take 2 different .c files and compile them together into a single nasm. or are you saying that the linking of diffrent C files happents at the nsam level?
Sameera Khatoon
1 month ago
Hello Tyler, here is the link to c program compilation guide. I hope this helps you. https://drive.google.com/file/d/1WkBcYB991AbNYgpU4FybIK0-djgigNVW/view?usp=sharing
Daniel McCarthy
1 month ago
Hello Tyler, sorry for the late reply Its easier to email me direct if you have follow up questions as the Dragon Zap question interface needs a bit of a revamp. My email is daniel@dragonzap.com Our C compilers job is to compile source code into assembly code, that gets passed through NASM which produces a object file, then with a linker we can link the objects together to create a single executable file. This is how all compilers work even GCC, though GCC has a linker built within it. When working with C we produce objects and link them later on. Email me if you want a detailed explanation as I can answer any questions you have in detail Thanks, Dan