See your uBITx sketch in Assembly or Hex

Jack W8TEE notes how easy it is to find where Hex files and Assembly files for a compile of an Arduino sketch are placed on your computer, along with some other compile-time information.

First, go to your Preferences dialog (File –> Preferences) and check the compilation check box for the “Show verbose output during:”

Second, compile your program. Do not click the compile/upload icon, only the check mark for compile only. You will see a lot of stuff scroll by just below the IDE’s Source Code Window.

Third, look towards the end of that list of output for YourProgramName.hex. For example, Jack’s test program was:
C:\Users\econjack\AppData\Local\Temp\arduino_build_160543/TestProgram.ino.hex

Fourth, go to the directory and look at the output files. You will see file types:

elf — executable-linkable file, used for a debugger
hex — the flash output file
eep — th eEEPROM outout file
sym — symbol table information
lst — assembler output

The first file is very interesting to look at, as it shows the C code mixed in with its associated assembler output. (You can load the file into any text editor.) For example, which is more efficient: a cascading series of if statements or a switch/case? Write a short test program using both constructs and then look at the assembler output. You find that the switch/case produces a jump table, which is very efficient in terms of speed, but may be less efficient in terms of memory. Even if you don’t know assembler, you’ll get a feel for the answer. Use whichever fits the situation.

If you want to directly load a hex file into an Arduino, you could use an AVR programmer, or XLoader (http://www.hobbytronics.co.uk/arduino-xloader).

Leave a Reply

Your email address will not be published. Required fields are marked *