Convert C - C++ Code To Assembly Language
Convert C - C++ Code To Assembly Language
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:
Syntax:
$ gcc -S filename.c
This will cause gcc to run the compiler, generating an assembly le. Suppose we write a C code and store it in a le name “geeks.c” .
$ gcc -S geeks.c
This will cause gcc to run the compiler, generating an assembly le geeks.s, and go no further. (Normally it would then invoke the
assembler to generate an object- code le.)
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.