Hi,
I compiled the simple test program:
unsigned long main( void ) { unsigned long i; unsigned char j; i = (unsigned long) 32767; for (j=0; j<10 ; j++) { i += (unsigned long) i; } return i; }
using both the IAR "kickstart" embedded workbench and also the WinAVR (avr-gcc) tools. When I load the resultant code into AVR studio for the IAR code I get a disassembly showing:
@00000002: main ---- c:\documents and settings\clawson\my documents\iar embedded workbench\main.c ----------------- 7: i = (unsigned long) 32767; +00000002: EF0F SER R16 Set Register +00000003: E71F LDI R17,0x7F Load immediate +00000004: E020 LDI R18,0x00 Load immediate +00000005: E030 LDI R19,0x00 Load immediate 9: for (j=0; j<10 ; j++) { +00000006: E040 LDI R20,0x00 Load immediate 9: for (j=0; j<10 ; j++) { +00000007: 304A CPI R20,0x0A Compare with immediate +00000008: F430 BRCC PC+0x07 Branch if carry cleared 10: i += (unsigned long) i; +00000009: 0F00 LSL R16 Logical Shift Left +0000000A: 1F11 ROL R17 Rotate Left Through Carry +0000000B: 1F22 ROL R18 Rotate Left Through Carry +0000000C: 1F33 ROL R19 Rotate Left Through Carry 9: for (j=0; j<10 ; j++) { +0000000D: 9543 INC R20 Increment +0000000E: CFF8 RJMP PC-0x0007 Relative jump 13: return i; +0000000F: 9508 RET Subroutine return
whereas when I load the .elf output of WinAVR the disassembly shows:
@00000051: main ---- c:\winavr\pn\source\test.c ------------------------------------------------------------------- 2: { +00000051: EFCF SER R28 Set Register ---- No Source ------------------------------------------------------------------------------------ +00000052: E0D4 LDI R29,0x04 Load immediate +00000053: BFDE OUT 0x3E,R29 Out to I/O location +00000054: BFCD OUT 0x3D,R28 Out to I/O location ---- c:\winavr\pn\source\test.c ------------------------------------------------------------------- 6: i = (unsigned long) 32767; +00000055: EF8F SER R24 Set Register ---- No Source ------------------------------------------------------------------------------------ +00000056: E79F LDI R25,0x7F Load immediate +00000057: E0A0 LDI R26,0x00 Load immediate +00000058: E0B0 LDI R27,0x00 Load immediate +00000059: E029 LDI R18,0x09 Load immediate ---- c:\winavr\pn\source\test.c ------------------------------------------------------------------- 9: i += (unsigned long) i; +0000005A: 0F88 LSL R24 Logical Shift Left ---- No Source ------------------------------------------------------------------------------------ +0000005B: 1F99 ROL R25 Rotate Left Through Carry +0000005C: 1FAA ROL R26 Rotate Left Through Carry +0000005D: 1FBB ROL R27 Rotate Left Through Carry ---- c:\winavr\pn\source\test.c ------------------------------------------------------------------- 8: for (j=0; j<10 ; j++) { +0000005E: 5021 SUBI R18,0x01 Subtract immediate ---- No Source ------------------------------------------------------------------------------------ +0000005F: FF27 SBRS R18,7 Skip if bit in register set +00000060: CFF9 RJMP PC-0x0006 Relative jump +00000061: 940C0063 JMP 0x00000063 Jump +00000063: CFFF RJMP PC-0x0000 Relative jump
In both I can see source and assembler interleaved but the WinAVR generated one has loads of "---- No Source ---..." lines intermingled even though the source clearly IS there.
Does anyone know what I've done wrong to cause this?
It's not a big problem and I can live with it (I like FREE software!) but it makes the mixed source/diassembly more difficult to read than it needs to be.
Cliff