Disassembly without debugging ?

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

As far as I can tell, there is no way of going to the disassembly unless your code is
a) Debugging/simulated
and
b) Paused

Is this truly the case? because I see no reason for the restriction, and would really like to be able to check my resulting ASM code without waiting 60sec+ to upload my code and pause every single time, or endlessly switching back and forth from the JTAGICE to the simulator.

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

Just read the LSS file in the editor.

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

Are you talking about C generated by avr-gcc? You should find that there is a .lss in the output files with a full interleaved C+Asm listing. For example:

#include 

uint8_t mask;

int main(void) {
	DDRB = 0xFF;
	mask = 1;
	while (1) {
		PORTB = mask;
		mask <<= 1;
		if (!mask) {
			mask = 1;
		}
	}
} 
00000094 
: #include uint8_t mask; int main(void) { DDRB = 0xFF; 94: 8f ef ldi r24, 0xFF ; 255 96: 87 bb out 0x17, r24 ; 23 mask = 1; 98: 81 e0 ldi r24, 0x01 ; 1 9a: 80 93 60 00 sts 0x0060, r24 while (1) { PORTB = mask; mask <<= 1; if (!mask) { mask = 1; 9e: 91 e0 ldi r25, 0x01 ; 1 int main(void) { DDRB = 0xFF; mask = 1; while (1) { PORTB = mask; a0: 80 91 60 00 lds r24, 0x0060 a4: 88 bb out 0x18, r24 ; 24 mask <<= 1; a6: 88 0f add r24, r24 a8: 80 93 60 00 sts 0x0060, r24 if (!mask) { ac: 88 23 and r24, r24 ae: c1 f7 brne .-16 ; 0xa0 mask = 1; b0: 90 93 60 00 sts 0x0060, r25 b4: f5 cf rjmp .-22 ; 0xa0

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

Opening the .lss sort of solves the problem, Thanks. :)

I would rather have the proper disassembly window with coloring, source filename referencing, and go to disassembly/source code, but it'll do the job.

Still confused as to the restriction being there in the first place, but maybe that's MS Visual Studio legacy? :?

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

Quote:

Still confused as to the restriction being there in the first place

What restriction? There are two completely separate programs operating under the hood of AS6. Atmel like to try and fool you into thinking it's their editor/debugger on top of their C compiler. It isn't. As such there are two different disassemblers involved here.

The "binutils" for avr-gcc contains a disassembler.

Atmel also have their own disassembler that is part of the Studio 4 legacy now imported into AS6.

In fact avr-gcc also has another form of Asm that can be made visible. The assembler source code geenrated by the C compiler and then fed into the avr-as assembler within the binutils. You can see this by adding --save-temps to the compiler invocation then for each foo.c that's compiled you'll get a foo.i (preprocessed) and foo.s (Asm source generated) available. The Asm source can be more verbose if -fverbose-asm is also used.

After the intermediate .s files have been assembled .o files containing ELF/DWARF2 are produced. You can get a disassembly of those too if you "avr-objdump -S foo.o" but what you'll see will be unlinked so external refeernces aren't fixed up (lots of CALL 0x0000 in place of the final call destinations).

After the .o files are fed into the linker they are combined into a final project.elf file which is also in ELF/SWRAF2 format only this time the inter-module links have been fixed up. Like before this can be used to generate a disassembly with "avr-objdump -S project.elf" and, in fact, this is EXACTLY what the .lss file is - just the captured output of that command. You even see it being generated in the build output:

		"C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\3.4.0.65\AVRToolchain\bin\avr-objdump.exe" -h -S "GccApplication1.elf" > "GccApplication1.lss"

Once you have a .elf file you can start debugging/simulating. This is where you leave the GNU tools behind and switch to using Atmel tools. Atmel's debugger/simulator has the ability to read in ELF/DWARF2 files which it then feeds the binary into its own disassembler which also uses the links to source files/lines given in the .elf to annotate with lines read from the original source files. I guess this is the view you are most familiar with. But it only comes into play when the Atmel debugger/simulator has been invoked and the ELF file is loaded.

You did say that "waiting 60sec+ to upload my code " if you select "simulator" rather than "JTAGICE debugger" as the target the process should be an awful lot quicker than 60s as no download into real AVR hardware is involved and you get to run the Atmel debugger/disassembler quicker.

Personally I much prefer the GNU listing (both the .s before assembly and the .lss after) but I guess it's a question of personal preference. A decent editor such as Notepad++ could probably even be persuaded to colour code the opcodes in a .lss file if you asked it nicely.

EDIT: the AS6 IDE in the "Miscellaneous" section under "AVR/GNU C Compiler" has a tick box for "Do not delete temporary files (-save-temps)". Sadly no box there for "-fverbose-asm" so you have to enter that one manually.

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

Thanks for your insight.

I meant the restriction of not being able to show the (atmel) debugger view (of the elf file, if I'm getting this right) unless I'm actively debugging/simulating, _and_ actually paused rather than running.

It does make some sense considering that AS6 brings together a collection of separate tools, rather than assimilating them.

Indeed, Notepad++ can probably do the coloring for me just fine; I was just hoping that AS6 would have assimilated that capability.

Thanks again for your explanations. :)

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

Quote:

I was just hoping that AS6 would have assimilated that capability.

Well actually the MS editor isn't too shabby either. It's configurable in many ways (unlike AS4!) and maybe "language parsing syntax coloring" is one of these? If so you could create a new language parser then set .lss files as being of that language type.

EDIT: OK maybe not. There are options for syntax coloring under VA Assist - Options but it's not like Notepad++ with individual language parsers.