Compiled Assembly Output

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

This may be a noobish question, but I can't seem to find any documentation (or not searching for the correct terms) for how to compile a basic program into assembly so I can see how many clock cycles some of my commands take up for One-Wire integration.

I have looked through all the make files and the closest I have found was the '.lss' listing output though does seem quite different to what standard assembly should represent.

Searching thus far has only shown light on the fact that I should use a '-S' compile flag which is the standard for most compilers to generate a '.s' file. However, since there is no documentation on it for the compiler options in atmel studio documents:
http://www.atmel.no/webdoc/avrto...
I have no idea where to proceed from here.

Note: I randomly just added the '-S' flag onto the compiler options under miscellaneous flags after "-std=gnu99".
Though my program didn't compile because of a syntax error, most likely this flag does not exist on Atmel Studio.

This topic has a solution.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Run it in the simulator. In the processor view, modify the CPU clock number to match what you really have. Then, ( think in the same view) there is a "stopwatch" function that will tell you the elapsed CPU time from one break to the preceding one. Just put breaks at the beginning of the section and at the end, and note the elapsed time.

Jim

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

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the response Jim!

I just had a crack at doing the debug solution trying to get my first or roughly 8 values of 44us is rather tough.

However, as I am trying to get these values as accurate as I can without producing a lookup table for around 8 values through a tedious stopwatch, was there any other method that I could use?

I have been using:
http://teslabs.com/openplayer/do...
as a guide thus far. Using the code on page 5 in the section specifically looking at timing notes that I should be able to look at the assembly output to count the cycles the commands use and that the generated code is based on the compiler:

inline __attribute__ ((gnu_inline)) void therm_delay(uint16_t delay)
{
	while (delay--) asm volatile ("nop");
}

//call function eg therm_delay(23)

Any other suggestions? I'm really looking forward to be able to run through my output code in assembly, or should I try another program for this?

EDIT: I ended up using winavr to create the .s file using the cmd line:

avr-gcc -S -mcall-prologues -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -mmcu=atmega324pa -Wall -Wstrict-prototypes -Os basic.c -o basic.s

Thanks for the Help!

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

Just add -save-temps to the compiler flags and after building for every file.c the build directory will contain a file.i which is the source after preprocessing and a file.s which is the Asm the compiler generated and that was passed to avr-as to build the code. Unlike the. lss (which is a source annotated disassembly of the final binary) the file.s is not source annotated but is pure asm. If you visit spaces.atmel.com I have a project there called avr-source which is a PC utility that will add source annotation as long as the files were built with -g (which Debug build files are).

For a fun life also add -fverbose-asm to the compiler flags which makes the file.s contents even more "interesting".