I have a project in xcode with one main.cpp file that executes a simple hello world print. If I want the .s file (the assembly code) how would I get that? I know how to see the assembly code using assistant editor but afterwards, I am not sure how to get the .s (or is it .asm in xcode?) file beyond copying the 20k lines of code, pasting into a text file and saving as .s
Asked
Active
Viewed 217 times
0
-
1It should be very similar to [How do you get assembler output from C/C++ source in gcc?](https://stackoverflow.com/questions/137038/how-do-you-get-assembler-output-from-c-c-source-in-gcc) with an extra helping of [How to remove “noise” from GCC/clang assembly output?](https://stackoverflow.com/questions/38552116/how-to-remove-noise-from-gcc-clang-assembly-output) – user4581301 Oct 02 '18 at 00:10
-
I guess I wasn't clear but i'm asking if xcode has the functionality within assistant editor possibly to return the .s file, not just display the assembly code (without adding commands) – mobcity zkore Oct 02 '18 at 00:26
-
The interesting part of a Hello World should be about 5 to 10 instructions and a couple lines of defining a string literal in `.rodata`. More instructions if you compile with optimization disabled. Most of the asm source lines will be directives that emit debug info, but even then 20k sounds excessive. Are you disassembling the entire binary including CRT start functions? (I thought CRT was dynamically linked on OS X though.) – Peter Cordes Oct 02 '18 at 01:25
-
There isn't a single unique "the .s", the asm depends on compiler options. What do you actually want to do? Look at the asm, or use it for something else? I'm not sure if clang has this option, but for gcc you can compile with `-save-temps` to save the `.i`, `.s`, and `.o` temporaries. Maybe add that to your compile options in XCode? I don't use xcode myself. – Peter Cordes Oct 02 '18 at 01:27
-
I think it's disassembling the entire binary. Is there a guide for how to use gcc? I honestly have no idea what that is. Is this a script or code you write in your cpp file itself? Or a program? I realize i'm coming across as ignorant, just started my basic machine structures class. All I wanted was the assembly file of my hello world code (as per our instructor: to see the complexity behind the higher level language) to show my TA as proof we took a look at the assembly code. – mobcity zkore Oct 02 '18 at 01:32