Arduino Due Assembly Language Listing of Compiled Sketch (Windows)

disassembled

1) Compile your sketch with verbose output turned on during compilation.

2) Find the ELF file – One of the last commands in the output window will be an “avr-objcopy” targetting the compiled (.elf) file of your sketch. Find and copy this entire command line in your output window. Example:

"C:\Users\James\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-objcopy" -O binary "C:\Users\James\AppData\Local\Temp\buildd61ea60940506cefcd14e1177e0613a0.tmp/Due_Blink_Inline.ino.elf" "C:\Users\James\AppData\Local\Temp\buildd61ea60940506cefcd14e1177e0613a0.tmp/Due_Blink_Inline.ino.bin"

due elf

3) Open a command prompt and paste the copied text.

4) Replace “avr-objcopy” with “avr-objdump”, and delete everything in quotes after the .elf file.

5) Replace the obj-dump options, “-O binary” with “–D –S”.

6) Add an output file. Example:

C:\Users\James>"C:\Users\James\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-objdump" -D –S "Due_Blink_Inline.ino.elf" >dump.txt

Changes made to the copied command line are highlighted in red:
due cmd

The disassembly of the simple “blink” example program produces a text file 1,967,968 bytes large! Here is the loop function:

00080150 <loop>:
80150:  b508        push  {r3, lr}
80152:  2101        movs  r1, #1
80154:  200d        movs  r0, #13
80156:  f000 fbbd   bl  808d4 <digitalWrite>
8015a:  f44f 707a   mov.w  r0, #1000
8015e:  f000 fb6f   bl  80840 <delay>
80162:  200d        movs  r0, #13
80164:  2100        movs  r1, #0
80166:  f000 fbb5   bl  808d4 <digitalWrite>
8016a:  e8bd 4008   ldmia.w  sp!, {r3, lr}
8016e:  f44f 707a   mov.w  r0, #1000
80172:  f000 bb65   b.w  80840 <delay>
80176:  4770        bx  lr

Adapted from the technique posted here.

Advertisements

About Jim Eli

µC experimenter
This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s