Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get an assembly language listing of my Arduino Sketches on Windows?

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.

like image 598
Matthew Murdoch Avatar asked May 28 '09 08:05

Matthew Murdoch


People also ask

How do I find Arduino sketches?

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).

What assembly language does Arduino use?

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.

Can you write assembly for Arduino?

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.

What is the extension of the assembly program code in Arduino?

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.


2 Answers

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>
like image 66
Greg Hewgill Avatar answered Oct 13 '22 11:10

Greg Hewgill


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.

like image 40
Magnus Hoff Avatar answered Oct 13 '22 13:10

Magnus Hoff