Quite often I need to view the assembly language source code emitted by GCC in order to provide some examples in the book. For Pi and Pico code, it's easy enough to modify the GCC command line and add an "-S" command-line option to tell GCC to stop processing after producing a Gas assembly language output file (from the compilation). With Arduino-based development (Arduino and Teensy SBCs) this is a lot more difficult because the Arduino IDE automates the compilation process and doesn't readily give you access to the command line. There is, however, a way to brute force your way through this.
To produce the assembly language output of a C compilation, hold down the Alt key when clicking on the "syntax check" option in the IDE. This displays all the commands the Arduino emits in the output window in the Arduino IDE. At one point in the (massive amount of) output, you'll see a line that says "Compiling sketch..." The next line is the command the IDE uses to run GCC to compile the code. For example, when compiling a "due.ino" sketch (for the Arduino Cortex-M3-based Due, I get the following:
Code: Select all
/Users/rhyde/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10607 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/system/libsam -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/system/CMSIS/CMSIS/Include/ -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/system/CMSIS/Device/ATMEL/ -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/variants/arduino_due_x /private/var/folders/13/fqsfj5688xl6n0006s6cl2vh0000gr/T/arduino/sketches/CB081C3733319369A9E70242F8A10B79/sketch/due.ino.cpp -o /private/var/folders/13/fqsfj5688xl6n0006s6cl2vh0000gr/T/arduino/sketches/CB081C3733319369A9E70242F8A10B79/sketch/due.ino.cpp.o
Code: Select all
/Users/rhyde/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -S -g -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions
-MMD -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10607 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/system/libsam -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/system/CMSIS/CMSIS/Include/ -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/system/CMSIS/Device/ATMEL/ -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino -I/Users/rhyde/Library/Arduino15/packages/arduino/hardware/sam/1.6.12/variants/arduino_due_x /private/var/folders/13/fqsfj5688xl6n0006s6cl2vh0000gr/T/arduino/sketches/CB081C3733319369A9E70242F8A10B79/sketch/due.ino.cpp
Cheers,
Randy Hyde