Assembly code listing

mkoch

Active member
Back in the days of 8051 programming (many years ago) I did write time-critical interrupt routines either in assemby code, or I did program them in C and then checked the code in the assembly listing. Often it was possible to iteratively change the C code until the fastest possible assembly code was produced.
Now I'd like to do the same with Teensy. How can I make an assembly code listing? Or does it already exist, hidden somewhere?

Thanks,
Michael
 
If you're using the Arduino IDE, using the Sketch->Export Compiled Binary menu option will generate a .lst file in the sketch directory containing both the C code and corresponding assembly.
 
I did try the Sketch->Export Compiled Binary option, but it did produce only a *.hex file.
 
Works here using IDE 2.1.0. Adds a folder "build" to the sketch folder which contains this:

Screenshot 2023-05-08 122801.jpg


For small snippets I like the compiler explorer, it life-generates the asm while you type your c++ code. Here an example: https://godbolt.org/z/K3K6x53WM

If you are using vsCode (e.g. PlatformIO or VisualTeensy) you can also include the compiler explorer into the editor. See here: https://www.youtube.com/watch?v=6S5EomO1Dy4 how that looks like in the editor.
 
First check which version of the software you have installed. If using Arduino 2.1.0, look in Boards Manager. If using Arduino 1.8.19, click Help > About. Version 1.58 and later (0.59.x are really 1.59 beta tests) generate a .lst file.

For 1.57 and earlier, we had .lst file disabled because it was very slow with certain large programs. Defragster made a test case where creating the .lst file would take about 1 minute even on a fast PC. Starting with 1.58 we updated the toolchain which seems to have fixed that issue.

The .lst file will be sitting in the hidden temporary folder where Arduino compiled your code. Easiest way to find it is turn on verbose output during compile in File > Preferences. Then Arduino will print all the compiler commands. Look for the temporary folder pathname.
 
First check which version of the software you have installed. If using Arduino 2.1.0, look in Boards Manager. If using Arduino 1.8.19, click Help > About. Version 1.58 and later (0.59.x are really 1.59 beta tests) generate a .lst file.

For 1.57 and earlier, we had .lst file disabled because it was very slow with certain large programs. Defragster made a test case where creating the .lst file would take about 1 minute even on a fast PC. Starting with 1.58 we updated the toolchain which seems to have fixed that issue.

The .lst file will be sitting in the hidden temporary folder where Arduino compiled your code. Easiest way to find it is turn on verbose output during compile in File > Preferences. Then Arduino will print all the compiler commands. Look for the temporary folder pathname.

I was using Arduino IDE 1.8.19 and Teensyduino 1.57. I just installed Arduino IDE 2.1.0 and now I can see the assembly listing. But now I have a new problem. The code doesn't upload to the Teensy. I get this error message:
Code:
Opening Teensy Loader...
Memory Usage on Teensy 4.0:
  FLASH: code:10952, data:4044, headers:8552   free for files:2008068
   RAM1: variables:14624, code:9224, padding:23544   free for local variables:476896
   RAM2: variables:12416  free for malloc/new:511872
Failed uploading: no upload port provided

The same project does still work without problems with the older IDE.
 
Back
Top