Once you’ve decided to take the path of security, sooner or later you’ll have to come into contact with Assembly. I know this is a very difficult language to understand, even for readers who understand binary strings. So, in this article, I will introduce you to the website Compiler Explorer, helps you to view your code as Assembly. Especially this website can see each line and highlight for you.
|Join the channel Telegram belong to AnonyViet ???? Link ????|
What is Compiler Explorer?
Compiler Explorer is a free and open source website that allows you to write, compile, and analyze source code to Assembly code, all in one browser tab. You can paste any C or C++ code (or one of 30 other supported languages), choose a compiler, run the program and see the Assembly code that corresponds to each line of code. You can also choose a lot of different compilers for each language you want.
Here you can view the warnings, errors, and Assembly code generated by the compiler, as well as view the output of the program.
What about interpreted languages like Python? Python source code can be compiled into bytecode to run on Python Virtual Machine .
You can see a C++ function compiled to Assembly code x86-64 in the image below.
Here is the Python code compiled into Python bytecode.
One of the features I like most about this site is that it can generate a link to your existing code. For example, when accessing this link, you will still see the lines of code that you code, the assembly code, and the output of the program. You can use this feature to share the code you want to your friends.
Why you should use Compiler Explorer
You can see what your source code is compiled to. Although any compiler can do that, Compiler Explorer will tell you exactly how each line of your code is converted to Assembly code.
One of the main uses of Compiler Explorer is to study low-level performance optimization. By knowing how your computer executes each line of code, you can analyze how those lines of code affect execution speed.
Compare compilers and architectures
You can analyze the different optimizations by seeing how the compiler affects the generated binary. The image below shows a compiled C++ function without optimization (
The image below also uses the same C++ function as above, but it is compiled using optimizations
As you can see, the compiler
gcc will create another binary file. You can also choose a different system architecture. As shown below, I choose ARMv7-a architecture.
Compiler Explorer is extremely flexible and convenient because it allows you to do many compiler related things in a single browser tab.
Compiler Explorer has helped me a lot in self-studying Assembly and understanding how compiler works. I think this site is also for those of you who are studying code optimization.