Saturday, February 24, 2018

Steps to output the Assembly Language code of any C program

Dear friends ,

Here are the steps to see/print the assembly code of any C program on your Windows
console /terminal/ command prompt :

1. Write a C program in a C code editor like codeblocks and save it with an extention .c
2. Compile and run it.
3. Once run successfully, go to the folder where you have installed your gcc compiler and give the
    following command to get a ' .s ' file of the ' .c' file
   C:\ gcc> gcc -S <complete path of the C file>  <enter>
 An example command ( as in my case)
   C:\gcc> gcc  -S D:\Aa_C_Certified\alternate_letters.c
  // give the -S gcc command line option to get the ' .s ' file
 // C:\gcc> as -v ENTER
// will give the version of your GNU assembler


     This outputs a ' .s' file of the original  ' .c' file
4 . After this , give the following command
   C;\gcc> cpp filename.s <enter>
// cpp is the C Pre-Processor

   Example command ( as in my case)
   C;\gcc> cpp alternate_letters.s  <enter>
This will print/output the entire Assembly language code of your C program.

Following are screen shots of the output of above commands

To see the version of your gcc compiler give following command
C:\ gcc> gcc -v ENTER



 Thanks
Happy Computing !

No comments:

Post a Comment

इश्क में ग़ैरत-ए-जज़्बात ने रोने ना दिया - सुदर्शन फ़ाकिर

 इश्क में ग़ैरत-ए-जज़्बात ने रोने ना दिया वरना क्या बात थी किस बात ने रोने ना दिया आप कहते थे कि रोने से ना बदलेंगे नसीब उमर भर आप की इस बात...