Go Down

Topic: Get Compiler to Output Assembly (Read 3333 times) previous topic - next topic


How can I tell the compiler to output a assembly file?
Freelance engineer, consultant, contractor. Graduated from UW in 2013.


What I do to look at assembler is use "objdump" on the elf file.  Just connect to the temporary directory that arduino uses for builds (/tmp/build* on my mac) and do something like:
Code: [Select]
MacOSX<1105> cd /tmp/build25808.tmp/
MacOSX<1106> /Downloads/arduino-0008/tools/avr/bin/avr-objdump -S hptime.elf

In theory, there's a -S switch for the compiler as well, but I worry about getting all the right switches and preprocessing done (automatically provided by audino environment), and using the .elf avoids this, and objdump produces a pretty nice mixed source/assembly listing:
Code: [Select]
       Serial.print("millis = ");
12a:   60 e0           ldi     r22, 0x00       ; 0
12c:   71 e0           ldi     r23, 0x01       ; 1
12e:   86 e2           ldi     r24, 0x26       ; 38
130:   91 e0           ldi     r25, 0x01       ; 1
132:   0e 94 ec 00     call    0x1d8 <_ZN14HardwareSerial5printEPKc>
136:   b8 01           movw    r22, r16
138:   a7 01           movw    r20, r14
13a:   86 e2           ldi     r24, 0x26       ; 38
13c:   91 e0           ldi     r25, 0x01       ; 1
13e:   0e 94 2a 01     call    0x254 <_ZN14HardwareSerial5printEm>
       Serial.print(",  high precision time = ");
142:   6a e0           ldi     r22, 0x0A       ; 10
144:   71 e0           ldi     r23, 0x01       ; 1
146:   86 e2           ldi     r24, 0x26       ; 38
148:   91 e0           ldi     r25, 0x01       ; 1
14a:   0e 94 ec 00     call    0x1d8 <_ZN14HardwareSerial5printEPKc>
14e:   dc 2c           mov     r13, r12
150:   cb 2c           mov     r12, r11
152:   ba 2c           mov     r11, r10
154:   aa 24           eor     r10, r10


can someone please .. repost the steps to have the compiler or the sketch invoriment   output the writen C code in assembly .. which the atmel chips understand ..

in an  ( idiot proff way please for the arudino 0017 enviorment

am running windows vista

I am running the Arduino 18 software on Mac OS X, and I don't see any way to get the object code.  I even tried editing Library/Arduino/preferences.txt to change

That did not produce any new files that I could see when I compiled.  Even if it did, the Arduino 18 download does not contain any of the utilities described for looking at the output.  Do I have to get the Arduino source code and build the whole thing from scratch to get the utility files?

Normally C would be fine for me, but I was doing some timing of interrupt routines, and found that accessing a memory location was taking 15 cycles, while the hardware datasheet indicates that it should be taking 2 cycles.  I want to know what code the compiler is generating (I'll replace it with asm code if it is too ridiculous).


Aug 17, 2010, 10:19 am Last Edit: Aug 17, 2010, 10:19 am by mpeuser Reason: 1
Press the SHIFT key when Compiling your code. You then will see in the message window where the system hides it. In Windows, its something like:

documents..\user\local settings...\temp\another temp

Also handy for getting the hex files.

Thanks.  The tools were hidden in
and the intermediate files in

The tools I should have been able to find, despite being hidden from the Finder (I had not dived deep enough into the Arduino.app directory), but the temporary directory was a complete mystery.

Now I can finally find out why the code is taking almost twice as long as I think it should for memory accesses!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131