Go Down

Topic: Teaching students what's under the hood (bonnet, if UK) (Read 1 time) previous topic - next topic

cedric61

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

CrossRoads

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.
http://www.ladyada.net/learn/avr/avrdude.html
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Nick Gammon

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:

Code: [Select]

#!/bin/bash

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


The -z makes it include "zero" bytes (eg. NOP instructions).
http://www.gammon.com.au/electronics

Go Up