As I prepare to teach a college engineering problem-solving class in C next year, I’ve been thinking about effective tools for demonstrating how the compiler, which is essential for generating efficient code for a target architecture, converts code into instructions the processor can execute. This process applies to compiled or native languages as opposed to interpreted ones like Python.

One way to demonstrate this is by requesting the compiler to generate the assembly source from the C code. Most compilers can do this, and I often use it to check if the compiler efficiently uses the target processor’s resources or to understand how certain transformations are handled by the tool.

Another approach is to use your preferred IDE, add a breakpoint once the program is compiled, and request the disassembly display. This allows you to step through the code as it is executed and keep an eye on the registers/memory. However, this method requires an IDE, the compiler, and a linker to be installed and configured. Unfortunately, the relationship between the source lines and the assembler is not always straightforward. Additionally, it only works for your system and processor architecture.



I was searching for a web-based solution similar to Python Tutor, which also supports C/C++ (here). Sadly, Python Tutor doesn’t show the assembler code. That’s when I discovered Compiler Explorer (https://godbolt.org/). It has all the features I need and more.

You can select your compiler (LLVM, GCC, ICL, CL, etc.) and the target architecture (ARM, x86-64, MIPS, POWER, etc.) and easily compare the output of the compilers and their options. In addition, the tool makes it very easy to relate the source to the assembly.



Additional features, such as diff, LLVM IR (if supported by the selected compiler), and control flow graph, are also available. Compiler Explorer will be in my teaching toolbox. Check it out, and you may like it.



And just for fun, if you love retro computing, you can even target the venerable 6502. Enjoy!
