Sometimes for learning or debuging, I need to view the assembly code of the program. This is very convenient in many GUI IDEs. For example, in Xcode, just click “Product”-“Perform Action”-“Assemble File Name”, as follows:
How to implement it in the terminal?
First create a C file test.c
. The content is as follows:
#include <stdio.h>
int main() {
printf("hello world!\n");
return 0;
}
Then use the following command:
$ cc -S test.c
it will generate a file named as test.s
, which contains assembly language, as follows:
I hope these will help someone in need~