C/C++ vs Assembly

By reaching this section of the manual, you should have gained a strong theoretical base regarding Assembly particularities. However, when writing your first Assembly code, a lot of "Why?" and "How?" questions will be raised.

Understanding the relation between Assembly and a higher programming language can represent the first step in writing your first program in Assembly. In order to emphasize the relation between different Assembly chunks of code and higher language elements, we provide the following example showcasing the same program written in C++, C and Assembly.

C++ -> C -> Assembly

No matter the way you look at this example (either from C to Assembly or from Assembly to C) there are aspects you should pay attention to before addressing more complex examples.

  • follow the flow of the program and understand the placement of the prologue and epilogue;

  • understand stack alignment;

  • find for each C line of code the corresponding Assembly block and think about how that block can be written differently (if possible) in order to have the same outcome.

Once you mark those checkpoints on this example, you are ready for more complex Assembly code.

Last updated