Inspired by another thread, what I did in the Windows XP command prompt, after having verified a sketch:
>CD %TEMP%\build2041587001917497488.tmp
>C:\Temp\arduino-1.0.4\hardware\tools\avr\avr\bin\objdump.exe -x -d -S keyboard.cpp.o >keyboard.asm
The output is only showing some hints but not actual source code snippets. Am I missing something?
keyboard.asm: (trimmed to stay in message size limits)
keyboard.cpp.o: file format elf32-avr
keyboard.cpp.o
architecture: avr:5, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .debug_abbrev 000001c8 00000000 00000000 00000034 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_info 0000034c 00000000 00000000 000001fc 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
5 .debug_line 0000023c 00000000 00000000 00000548 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
6 .text._GLOBAL__I_keys 000001d2 00000000 00000000 00000784 2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
7 .ctors 00000002 00000000 00000000 00000956 2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
8 .text.loop 000000a2 00000000 00000000 00000958 2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
9 .text.setup 0000001a 00000000 00000000 000009fa 2**0
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
10 .bss.keys 00000060 00000000 00000000 00000a14 2**0
ALLOC
11 .debug_frame 00000040 00000000 00000000 00000a14 2**2
CONTENTS, RELOC, READONLY, DEBUGGING
12 .debug_loc 00000056 00000000 00000000 00000a54 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
13 .debug_pubnames 0000002e 00000000 00000000 00000aaa 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
14 .debug_aranges 00000030 00000000 00000000 00000ad8 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
15 .debug_ranges 00000058 00000000 00000000 00000b08 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
16 .debug_str 00000209 00000000 00000000 00000b60 2**0
CONTENTS, READONLY, DEBUGGING
SYMBOL TABLE:
00000000 l df *ABS* 00000000 keyboard.cpp
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
0000003f l *ABS* 00000000 __SREG__
0000003e l *ABS* 00000000 __SP_H__
0000003d l *ABS* 00000000 __SP_L__
00000034 l *ABS* 00000000 __CCP__
00000000 l *ABS* 00000000 __tmp_reg__
00000001 l *ABS* 00000000 __zero_reg__
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .text._GLOBAL__I_keys 00000000 .text._GLOBAL__I_keys
00000000 l F .text._GLOBAL__I_keys 000001d2 _GLOBAL__I_keys
00000000 l d .ctors 00000000 .ctors
00000000 l d .text.loop 00000000 .text.loop
00000000 l d .text.setup 00000000 .text.setup
00000000 l d .bss.keys 00000000 .bss.keys
00000000 l d .debug_frame 00000000 .debug_frame
00000000 l d .debug_loc 00000000 .debug_loc
00000000 l d .debug_pubnames 00000000 .debug_pubnames
00000000 l d .debug_aranges 00000000 .debug_aranges
00000000 l d .debug_ranges 00000000 .debug_ranges
00000000 l d .debug_str 00000000 .debug_str
00000000 *UND* 00000000 __do_copy_data
00000000 *UND* 00000000 __do_clear_bss
00000000 g O .bss.keys 00000060 keys
00000000 *UND* 00000000 __do_global_ctors
00000000 g F .text.loop 000000a2 loop
00000000 *UND* 00000000 digitalWrite
00000000 *UND* 00000000 Keyboard
00000000 *UND* 00000000 _ZN9Keyboard_5pressEh
00000000 *UND* 00000000 _ZN9Keyboard_7releaseEh
00000000 g F .text.setup 0000001a setup
00000000 *UND* 00000000 pinMode
00000000 *UND* 00000000 _ZN9Keyboard_5beginEv
Disassembly of section .text._GLOBAL__I_keys:
00000000 <_GLOBAL__I_keys>:
[...]
Disassembly of section .text.loop:
[...]
Disassembly of section .text.setup:
00000000 <setup>:
0: 8d e0 ldi r24, 0x0D ; 13
2: 61 e0 ldi r22, 0x01 ; 1
4: 0e 94 00 00 call 0 ; 0x0 <setup>
4: R_AVR_CALL pinMode
8: 8c e0 ldi r24, 0x0C ; 12
a: 61 e0 ldi r22, 0x01 ; 1
c: 0e 94 00 00 call 0 ; 0x0 <setup>
c: R_AVR_CALL pinMode
10: 80 e0 ldi r24, 0x00 ; 0
10: R_AVR_LO8_LDI Keyboard
12: 90 e0 ldi r25, 0x00 ; 0
12: R_AVR_HI8_LDI Keyboard
14: 0e 94 00 00 call 0 ; 0x0 <setup>
14: R_AVR_CALL _ZN9Keyboard_5beginEv
18: 08 95 ret
keyboard.cpp: (trimmed)
[...]
inline void processKey(bool keyIsDown, struct key_s &key) {
if (keyIsDown) {
if (!key.isPressed) {
Keyboard.press(key.code);
key.isPressed = true;
} // else: no change
} else { // key is up
if (key.isPressed) {
Keyboard.release(key.code);
key.isPressed = false;
} // else: no change
}
}
inline void processRow(char pinStates, struct key_s *key_p) {
pinStates >>= 2; // first two pins not used for columns
while (pinStates) {
processKey(pinStates & 1, *key_p);
pinStates >>= 1;
key_p++;
}
}
void setup() {
pinMode(decadeCounterClockPin, OUTPUT);
pinMode(decadeCounterResetPin, OUTPUT);
Keyboard.begin();
}
void loop(){
resetDecadeCounter();
for (struct key_s *key_p = keys; key_p < keys + 8 * 6; key_p += 6) {
char pinStates = PIND;
processRow(pinStates, key_p);
incrementDecadeCounter();
}
}