The objective is to understand a basic disassembled C program which is machine translated into assembly language. The assembly code is to be commented on how the written C program relates to the assembly language and how a simple C programming instruction is written in assembly language.
The C code is disassembled using the disassemble feature in code warrior, where the entire code is translated into assembly language by the software itself. The self-disassembled C code to assembly language is not very efficient, when it comes to using the memory stack and the use of registers, where the program uses a lot of stack memory. This is where assembly language written by an individual is more important and efficient rather than of a self-generated assembly code translated with a help of a software.
To create a disassemble file follow steps given below:
1. Right-click the source file A context menu appears.
2. From the context menu, select Disassemble option. The Disassemble Job window appears.
The disassembling file provides a way to show the results of object code produced from a C/C++ source file in the Editor. Once the Disassemble command is executed, it will proceed to compile, disassemble the file and show the resulting disassembled file in a new editor window, titled sourcefilenameXXXXX.lst , where XXXXX represent random numbers.
After disassemble, you will find yourself with a code like shown on the left column below. The annotation of the code is explained in the right column adjacent to the code.
What really goes on in the registers:
The stack frame after the swap function:
R7 is used as token to keep in track of the register location.