section of code to asm

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Anyone know of a tool to convert a C file or section of code to asm?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVR Studio have an disassembler option.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's what a compiler does. At least, many compilers can be told to emit assembly code.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many compilers creating from C source code .asm files also.These files have the code in C commented and show how each command in C is implemented in assembler code.
The .asm file generating from a compiler have some sections of code that is impossible for a human to understand and manipulate-i think.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I believe you use GCC so if you use an Mfile generated makefile for foo.c just "make foo.s" and you will have the code in Asm.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well I figured I could do it in the ide ( AVR-Studio in my case) just didnt know how. So I can use a make file to do this then?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

So I can use a make file to do this then?

Cliff wrote:

if you use an Mfile generated makefile for foo.c just "make foo.s" and you will have the code in Asm.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well I dont yet know how to run a command out side of the IDE. But yes Cliff did answer my question. I'm sure I can figure it out, thx.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, assuming you have WinAVR installed:

1. Start the MFile utility. It's in your Start menu, under WinAVR.

2. In MFile you change things by making menu selections, and filling in dialogue boxes:
2a. Set MCU type.
2b. Add your source file to the list of files.
2c. Save the makefile in the directory where your source file is.

3. Drop to a command prompt and CD to that directory.

4. Issue the command make filename.s

If you're curious enough you might start looking into the makefile, and learn how GNU Make works. You can then reveal the Make rule for building a .s file from a .c file. I'm not on a system with an up to date MFile utility right now, or I would have looked it up.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This may be why I'm so lost.

1) My star menu does not have mFile.
2) I use an external make file already( I didnt create it )
3) I search my drive for make, can not find it.

I see my make file has the necessary command to build the .s even says right at the tope make filename.s under command line options. But I can not figure out how to run the make program.

update
-------------
Ok I found mFile but I dont think I need it, my make file should do the trick. Just need to find make or setup the environment path.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
1) My star menu does not have mFile.
If you installed avr-gcc through WinAVR, it should be there in the WinAVR menu.
Quote:
3) I search my drive for make, can not find it.
You don't need to know where it is, the operating system knows.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, if you use Studio then forget Mfile and just edit the build options for the Project and add the option "--save-temps".

Then rebuild the project. Then from the project directory look in the sub-directory called "default" and for every .c file you should find you have a file.i and a file.s, the .i files are the CPP'd files and the .s files are the Asm generated by the C compiler.

An option I also like to use is -fverbose-asm which adds far more detail into the .s files.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Like it Cliff, thx.