How to see .asm generated from .c files in AVR studio?

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

Hi All,
I have just started to play a bit with AVR studio; writing small programs and running them in the simluator, such using a timer, etc.
However, I see that when I build the C source file, I can't see any .asm or .o or .hex files being generated along with it. Am I missing something here, or AVR studio does not generate those files at all (for me to see and use, that is)? I just thought that if I ever wanted to see the asm code of my C program, or wanted to save the asm or .hex files separately, how would I do do?
Please guide.

Thanks in advance,
Aashish.

-Aashish.
If you don't see it coming, you'll never know what hit you...

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

Oops! I should've done some homework first... :-)
The .hex and .o are present in the directory called default.
I opened the .lss file with notepad and could see the asm code too! :-) Problem solved!

-Aashish.
If you don't see it coming, you'll never know what hit you...

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

Looks like the files you are after are in a folder called default, under the project folder.

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

If you right-click the project in AVR studio and select "Edit configuration options", you get a dialog where you can check "Create hex file", "Generate map file" and "Generate list file".

/Jakob Selbing

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

Thanks guys! You are all quick to come to help, and I appreciate it. :-)

-Aashish.
If you don't see it coming, you'll never know what hit you...

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

Project > Configuration Options > Custom Options: type -save-temps and press Add.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

Quote:

Project > Configuration Options > Custom Options: type -save-temps and press Add.

I was going to suggest that too so I'll just add that the effect of doing this is that for every source . file the ./default/ directory will now contain filename.i and filename.s

The .i file is the .c file after it has been processed by the C pre-processor.

The .s file is the output of the compiler that is then passed to the assembler to generate the .o file - unlike the .lss it does not mix the C source code, however if you also add the option -fverbose-asm you will find that it gets filled with tons of additional info that should help you to see how it relates to the source.

As this question is really about the use of avr-gcc (well OK maybe about Studio 4?) I'll move thisthread to the GCC Forum before the Bob monster catches us.

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

thanks to everyone! This really helped. :-)

-Aashish.
If you don't see it coming, you'll never know what hit you...

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

Does anyone know how to configure Atmel Studio 7 generate the .asm file?  Having a hard time figuring this out.

 

 

 

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

I don't think it has a "tick box" as such but under the compilation options for the project there is a section called something like "additional commands" with a free text box. Just put "-save-temps" in there.

 

Of course Studio already produces a .lss file each time you build (unless you deliberately disabled that option) and 99 times out of 100 that's enough to see the generated Asm. The only real reason for -save-temps is when you want to catch the .s file and then use it as the basis of your own hand-crafted Asm.

 

[shameless self promotion]If you are going to use .s files from -save-temps this may be useful:  https://spaces.atmel.com/gf/proj... [/shameless self promotion]

 

EDIT: OK, I was wrong. The user manual:

 

http://www.atmel.com/webdoc/GUID...

 

says that under "compilation options - miscellaneous" there is a tick box for -save-temps. So tick that!

Last Edited: Fri. Feb 10, 2017 - 04:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, yes both ways work. I first added -save-temps. Then I noticed you had edited the post and sure enough, the tick box was right in front of my face. But I was not expecting the .s file to be so cryptic. Thought it would look more like the disassembly window that pops up when I run the debugger. I'll have to read up more on things. The link you provided mentions something about objdump. That might provide more of what I was looking for. What got me started is that after compiling my C code, I notice that address 0 contains a jump instruction to an area past the interrupt vectors. At this location, the .lss files shows "11 24   eor   r1, r1". I don't know why, but I was incorrectly thinking the XOR did not guarantee R1 to be clear. Then I looked at the disassembly window and it shows "11.24   CLR R1   Clear Register". This is not the same instruction. Just kind of odd. I guess it's the compiler or assembler doing things behind the scene. So my intention was not looking to make hand crafted Asm but rather to resolve a bug I'm fighting with at the moment. Anyway, thanks for the answer. It certainly helped.

 

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

analogman wrote:
At this location, the .lss files shows "11 24 eor r1, r1". I don't know why, but I was incorrectly thinking the XOR did not guarantee R1 to be clear. Then I looked at the disassembly window and it shows "11.24 CLR R1 Clear Register". This is not the same instruction.

A lot packed in what I quoted.

 

First, start with boolean logic.  What does EOR/XOR do?  The short answer here is that if you exclusive OR something with itself, the result is always zero.

 

Next, pull up an AVR datasheet:

 

131, eh?  ;)  Discussed thoroughly here of and on over the years.  I think there are really about 80 unique op codes.  The rest of the "powerful instructions" are roses by another name, but still smell sweet.

 

Do you have the AVR Instruction Set document handy?  http://www.atmel.com/images/Atme...

 

Now, let's look at that "different instructions" comment...

 

 

Looks the same to me...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

One thread with list(s) and link to prior list(s):  https://www.avrfreaks.net/comment...

Ditto: https://www.avrfreaks.net/forum/b...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Yes, this stuff has been discussed extensively. On the other hand, even those of us with a bit of experience often forget some of these less often used details. I sure do and I appreciate the "course review". Many of these things are even a bit challenging to figure out WHERE to find in the documentation. Or, even that they exist!

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

clawson wrote:
[shameless self promotion]If you are going to use .s files from -save-temps this may be useful:  https://spaces.atmel.com/gf/proj... [/shameless self promotion]
Firefox complains about an expired certificate.

Iluvatar is the better part of Valar.

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

The short answer here is that if you exclusive OR something with itself, the result is always zero.​

​Yes, I did figured that out. I just had a brain dead moment as I have been away from this stuff for too long. It looks to me like the compiler created the EOR instruction and the disassembler interpreted it as a CLR. But we're getting off topic now so I'll end here. Thanks to all who contributed.

 

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

As theutch pointed out, CLR is just an alias for XOR with the specified register and itself. Nothing got magically changed because it IS an XOR!

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

analogman wrote:
It looks to me like the compiler created the EOR instruction and the disassembler interpreted it as a CLR.

Did you actually bother to use the links I dug out, where all this was discussed?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.