Teaching students what's under the hood (bonnet, if UK)

I'd like to be able to see the assembly source code (LDI, ADC...) that gets generated by the Arduino IDE. I've been trying to do this, quite unsuccessfully, with AtmelStudio. My goal is to show a group of students how, for example, a digitalWrite affects the various registers.

Is there a way to read these files from within the Arduino IDE? If not, has anyone had success using AtmelStudio as a teaching tool for this purpose?

Many thanks, in advance.

Cedric in New Orleans

Not from within the IDE.
I think there are settings or flags you can use with avrdude commands to create/save the assembler commamds, and then use Notepad++ to look at the file.

  1. Turn on verbose compiling and then click on the "verify" button (LH one) to compile your sketch in verbose mode.

  2. Note the name of the .elf file of your sketch (usually the second-last line).

  3. In a terminal/command/console window do something like:

avr-objdump -S filename.cpp.elf

(where filename.cpp.elf is from step 2).

I do that so often I made a small "bash" script:


avr-objdump -S -z $1 > ~/nick.txt

The -z makes it include "zero" bytes (eg. NOP instructions).