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.
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.
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.
The following (hacky) steps will provide assembly language listings of Arduino sketches and associated libraries on Windows:
.pde
file)-S
to the abuild_gcc_opts
variable in abuild.bat
(line 158)abuild -r -c <pde_filename>
Expect to get the following warnings and errors, which you can ignore:
... warning: #warning "This file has been moved to <util/delay.h>."
.\obj\<pde_filename>.cpp.o: file format not recognized: treating as linker script
.\obj\<pde_filename>.cpp.o:1: syntax error
The assembly language listings can be found in the .o
files in the created obj
directory. For example the listing for the sketch itself is in obj\<pde_filename>.cpp.o
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>