by eatonphil · 5y ago · 0 comments
I think it's fairly common to recommend beginners to write a compiler but I think it's less common to actually recommend trying to emulate parts of x86. I think it's a particularly easy way to get started just because it's the architecture you already know or because its the architecture that all compiler tutorials use (if they don't use LLVM). And if you are a programmer you probably incidentally have gcc, gdb, and objdump on your system ready to help you out.
Doing both compilers _and_ emulators really helped my understanding of x86 and C (even if I wasn't writing C).
My background is in web development and my reason for doing these projects/writing is purely educational.
[0] https://notes.eatonphil.com/compiler-basics-lisp-to-assembly...
[1] https://notes.eatonphil.com/compiler-basics-an-x86-upgrade.h...
[2] https://notes.eatonphil.com/emulating-amd64-starting-with-el...
[3] https://notes.eatonphil.com/emulator-basics-a-stack-and-regi...
For example, the codegen for some C++ that was discussed a few days ago [1]
I also wrote another article which explain how C++ code can be understood in terms of C code: https://www.avabodh.com/cxxin/cxx.html
This website also has another article which explains how a C++ code can be understood in terms of C code. https://www.avabodh.com/cxxin/cxx.html