LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   To have gcc compile to assembler codes too (https://www.linuxquestions.org/questions/programming-9/to-have-gcc-compile-to-assembler-codes-too-4175717334/)

BudiKusasi 09-30-2022 11:16 PM

To have gcc compile to assembler codes too
 
How do we have gcc compile to assembler codes too in addition to .obj while i used to do
Code:

    g++ -S -o m.asm  m.cpp
output to assembly only ?

Please explain every gcc cli correct steps

NevemTeve 10-01-2022 01:15 AM

Google found this: https://www.systutorials.com/generat...ing-using-gcc/

rtmistler 10-01-2022 09:55 AM

Quote:

Originally Posted by BudiKusasi (Post 6383719)
How do we have gcc compile to assembler codes too in addition to .obj while i used to do
Code:

    g++ -S -o m.asm  m.cpp
output to assembly only ?

I'm not sure I understand your full question. Did you try that and not get assembly output?
Quote:

Originally Posted by BudiKusasi (Post 6383719)
Please explain every gcc cli correct steps

This is an extremely broad request, please search for the gcc documentation and search within it to address specific questions, and if you have further questions, please be more specific.

astrogeek 10-01-2022 01:22 PM

Your question is not really clear to me, but if I interpret it to mean this:

Quote:

How do I have gcc save intermediate files when compiling an executable?
See man gcc and look at the -save-temps option.

Further, your example specifically names the assembler file using the -o option, but -o names the primary output file only, so if continuing to object and linker phases the earlier intermediate files will be named based on that but you may not be able to name them explicitly (but see the -dumpbase option for more possibilities).

Quote:

Originally Posted by BudiKusasi (Post 6383719)
Please explain every gcc cli correct steps

That is asking too much and would deprive you of the learning experience!

dugan 10-03-2022 11:08 AM

If the program is small and you just want to see the generated assembler, you can paste it here:

https://godbolt.org/


All times are GMT -5. The time now is 04:31 AM.