Code::Blocks Forums

User forums => Embedded development => Topic started by: halfboy on February 07, 2015, 08:29:29 pm

Title: How to generate asm files from c program ?
Post by: halfboy on February 07, 2015, 08:29:29 pm
Hello everyone !

I've been searching for solution but everything I tried - failed.

I've started programming Atmel's microcontrollers in C, but I'd also like to generate assembly code during compiling, as I'd like also to learn how compiler generates instructions for my microcontroller (I think it will be effective way to learn assembler too).

Could someone help me what should I do, maybe install extra plugins ?

I'm using Ubuntu 14.04.1 LTS

Greets !
Title: Re: How to generate asm files from c program ?
Post by: Alpha on February 07, 2015, 08:51:29 pm
I'm using Ubuntu 14.04.1 LTS
Makes me assume you are using GCC.  Assuming that is the case, you are probably looking for the -S command flag.  Use man pages/google/trial and error to figure out how GCC needs it specified (learning how to find information is an essential part of programming; it gets easier once you have some knowledge of what you are searching for).

You can technically hack the templates within advanced compiler options to make C::B generate this output, but in this situation, it would probably just be more efficient to execute that command line.
Title: Re: How to generate asm files from c program ?
Post by: halfboy on February 07, 2015, 09:11:20 pm
Thanks for help.

Yes, of course I'm still learning but I always ask google for help before write at forum. But I have big problems with that topic as I think I've tried many many solutions and nothing helped. I tried change in C::B compilator for GNU AVR GCC Compiler but nothing happen. Moreover I've tried to add -S flag in advanced compiler options but still nothing helped.

But I will still searching, hope to find solution...

P.S. Hope my english is understandeable 
Title: Re: How to generate asm files from c program ?
Post by: stahta01 on February 07, 2015, 11:33:13 pm
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)

Did you try -S in other compiler options?
Tab: Compiler Settings
Sub-Tab: Other Options

Tim S.
Title: Re: How to generate asm files from c program ?
Post by: halfboy on February 08, 2015, 12:05:49 am
I tried to add -S flag in advanced compiler options.


what exactlu should I write in 'other options' as there is a text box ?

greets
Title: Re: How to generate asm files from c program ?
Post by: scarphin on February 08, 2015, 01:30:47 am
As far as I know '-S' flag instructs the compiler to stop at the assembly step which makes the compilation a 2 step operation; 1st compile to assembly code, 2nd assembly to object file. I don't think generation of assembler code and compilation of a source file is possible in a single step operation. In that case you can use a prebuild step to generate your assembler files but be aware that they won't look like hand-written assembler. Consult your compiler documentation for the corresponding command to generate the assembler file. If I recall correctly, the command for avr-gcc should be something like:
Code
gcc -S source.c -o source.S
Title: Re: How to generate asm files from c program ?
Post by: BlueHazzard on February 08, 2015, 02:00:40 am
You can try the compiler option -save-temps or search with google for. Lss files and how to generate them with avr-gcc. Anyway this has both nothing to do with c::b....