I would like to be able to see an assembly language listing of my Arduino sketches. How can I achieve this?
Update: I am running the Arduino Software on a Windows machine.
You can see the sketches in the Sketchbook folder by going to File > Sketchbook. The default name of the Sketchbook folder is “Arduino” and the default location of the Sketchbook folder is in the “My Documents” folder (or just “Documents” for Mac users).
The Arduino language is a subset of C/C++, where you can also use assembly for ultra-low level code. When saying “programming on Arduino”, in fact you don't program the Arduino board itself, but the microcontroller inside the board.
It's certainly possible to program the AVR in assembly language, but you'll have to do a little extra legwork. The compiler used by the development kit is AVR-GCC, which supports assembly language as an input, but this isn't directly an option from the GUI.
Then you can put your assembly code alongside this empty file, in files of their own ending with the “. S” extension. These files will be preprocessed before being assembled, so you can #include <avr/io.
One way to do this is to use avr-objdump
on the .elf
file created by the build. For example, on OS X I can do this:
$ cd ~/arduino-0015/examples/Digital/Blink/applet $ avr-objdump -d Blink.elf
(Your path on Windows may be different, obviously.) This produces a disassembly of the code, part of which will look something like this:
0000013a <main>: 13a: 0e 94 3e 01 call 0x27c <init> 13e: 0e 94 97 00 call 0x12e <setup> 142: 0e 94 80 00 call 0x100 <loop> 146: fd cf rjmp .-6 ; 0x142 <main+0x8>
If you are using Linux, you can follow this tutorial on how to compile for the Arduino without the IDE.
Once you do that, you can get an assembly listing by running gcc with the -s flag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With