ARDUINO - HOW TO DISASSEMBLE A SKETCH

In this post, I am going to give the steps required to get the assembly code of your Arduino sketch. you may need the assembly code of your Arduino sketch to analyze and improve your Arduino program. 

STEPS TO OBTAIN THE ASSEMBLY CODE

To obtain the assembly code of the Arduino sketch, first, you have to find the temporary build folder of your sketch. To find that folder first open your Arduino IDE, open preferences in the file menu. In preferences, windows make sure that the "show verbose output during " checkbox is checked for the compilation option.



Now if you compile your Arduino sketch you will get some messages in that black section.


You can find a  line like the one I marked above which ends with your sketch name.ino.elf. This is the file that is required for the disassembly. That build folder is a temporary folder. So first you have to copy that file to somewhere else as it will be deleted soon. 

Now open cmd with the folder where you saved the .elf file as the working directory. if you look at the line marked in the above image, the first part is in quotes "F:\\installed\\.........avr-size".

In cmd enter that line with some changes. First replace the "F:\\installed" part with your installation directory path. 

Replace all  '\\' (double) with '\' (single). 

Replace all  '/' with '\' and change that "avr-size" with "avr-objdump". then append it with  "-d", the filename of .elf file and '>' name.txt, where the name can be any valid filename.


example (in context to above image)

Now if you check the folder you will find a new text file with disassembled code.

tony

No comments:

Post a Comment