Author Topic: How to generate asm files from c program ?  (Read 15731 times)

Offline halfboy

  • Single posting newcomer
  • *
  • Posts: 6
How to generate asm files from c program ?
« 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 !

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: How to generate asm files from c program ?
« Reply #1 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.

Offline halfboy

  • Single posting newcomer
  • *
  • Posts: 6
Re: How to generate asm files from c program ?
« Reply #2 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 

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: How to generate asm files from c program ?
« Reply #3 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

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

Tim S.
« Last Edit: February 07, 2015, 11:35:15 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline halfboy

  • Single posting newcomer
  • *
  • Posts: 6
Re: How to generate asm files from c program ?
« Reply #4 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

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: How to generate asm files from c program ?
« Reply #5 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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: How to generate asm files from c program ?
« Reply #6 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....