We use g++ compiler to turn provided C code into assembly language. To see the assembly code generated by the C compiler, we can use the “-S” option on the command line:
$ gcc -S filename.c
This will cause gcc to run the compiler, generating an assembly file. Suppose we write a C code and store it in a file name “geeks.c” .
Running the command:
$ gcc -S geeks.c
This will cause gcc to run the compiler, generating an assembly file geeks.s, and go no further. (Normally it would then invoke the assembler to generate an object- code file.)
The assembly-code file contains various declarations including the set of lines:
Each indented line in the above code corresponds to a single machine instruction. For example, the pushq instruction indicates that the contents of register %rbp should be pushed onto the program stack. All information about local variable names or data types has been stripped away. We still see a reference to the global
variable s= “GeeksforGeeks”, since the compiler has not yet determined where in memory this variable will be stored.
This article is contributed by Sahil Rajput. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Assembly language program to find the range of bytes
- Assembly language program to find largest number in an array
- 8085 code to convert binary number to ASCII code
- 8085 program to convert ASCII code into HEX code
- Convert C/C++ program to Preprocessor code
- 8086 program to convert binary to Grey code
- 8085 program to convert 8 bit BCD number into ASCII Code
- 8086 program to convert 8 bit BCD number into ASCII Code
- 8085 program to convert a hexadecimal number into ASCII code
- Assembly program to transfer the status of switches
- Difference Between C Language and LISP Language
- Signals in C language
- fgets() and gets() in C language
- kbhit in C language
- Difference between while(1) and while(0) in C language
- C Language Introduction
- Stopwatch using C language
- chdir() in C language with Examples
- Difference between Java and C language
- lvalue and rvalue in C language