avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] I do not understand the parameters to strcpy_P in .LSS Fi


From: Bob Paddock
Subject: [avr-gcc-list] I do not understand the parameters to strcpy_P in .LSS File?
Date: Fri, 20 Jul 2007 12:54:11 -0400
User-agent: Opera Mail/9.10 (Win32)


I have this program:

/* Start Example */
#include <avr/pgmspace.h> /* strcpy_P() */

unsigned char buffer[256];

int main( void )
{
  (void) strcpy_P( (char *) buffer, "Clock Not Set" );
}
/* End Example */

That is producing the .lss and .hex files below.

I do not understand why r23/r22 is being loaded with
the value of 0x0100, rather than the value of 0x00F4,
which is the location of the string "Clock Not Set"
in Flash, that I expect to see?

The .HEX file and the .LSS file do match,
 "00D2 60E071E08EE091E00E947200",
so I don't see this as a case of the disassembler doing
something goofy.  What am I not understanding here?

This is with
avr-gcc (GCC) 4.1.2 (WinAVR 20070525rc2)
for AT90CAN64.

...
000000ce <__bad_interrupt>:
  ce:   0c 94 00 00     jmp     0       ; 0x0 <__vectors>

000000d2 <main>:

unsigned char buffer[256];

int main( void )
{
  d2:   60 e0           ldi     r22, 0x00       ; 0 [Loaded to 'Z' for lpm 
instruction.]
  d4:   71 e0           ldi     r23, 0x01       ; 1
  d6:   8e e0           ldi     r24, 0x0E       ; 14 [Loaded to 'X' for lpm 
instruction.]
  d8:   91 e0           ldi     r25, 0x01       ; 1
  da:   0e 94 72 00     call    0xe4    ; 0xe4 <strcpy_P>
  (void) strcpy_P( (char *) buffer, "Clock Not Set" );
}
  de:   80 e0           ldi     r24, 0x00       ; 0
  e0:   90 e0           ldi     r25, 0x00       ; 0
  e2:   08 95           ret

000000e4 <strcpy_P>:
  e4:   fb 01           movw    r30, r22
  e6:   dc 01           movw    r26, r24
  e8:   05 90           lpm     r0, Z+
  ea:   0d 92           st      X+, r0
  ec:   00 20           and     r0, r0
  ee:   e1 f7           brne    .-8             ; 0xe8 <strcpy_P+0x4>
  f0:   08 95           ret

000000f2 <_exit>:
  f2:   ff cf           rjmp    .-2             ; 0xf2 <_exit>

[From the .LST & .HEX file:]
  f4: 436C 6F63                 .string "Clock Not Set"
  f8: 6B20 4E6F
  FC  7420 5365
 100: 7400

main.hex:
...
:100080000C9467000C9467000C9467000C94670054
:100090000C94670011241FBECFEFD0E1DEBFCDBFAF
:1000A00011E0A0E0B1E0E4EFF0E002C005900D92B5
:1000B000AE30B107D9F712E0AEE0B1E001C01D9259
:1000C000AE30B107E1F70E9469000C9479000C94FE
:1000D000000060E071E08EE091E00E94720080E03C  [<- Code in question]
:1000E00090E00895FB01DC0105900D920020E1F7FE  [<-strcpy_P()]
:0400F0000895FFCFA1 [<-<_exit>]
:0E00F400 43 6C 6F 63 6B 20 4E 6F 74 20 53 65 74 00 75 ["Clock Not Set\NULL"]
:00000001FF






reply via email to

[Prev in Thread] Current Thread [Next in Thread]