[Icc-avr] Pointer issue

John Baraclough j_baraclough at zetnet.co.uk
Wed Nov 14 10:34:56 PST 2007


This works fine for me.

  unsigned int uiTemp;
  const int *p;

  p = (const int *)0x40;

  uiTemp = *p;

Listing:

(0038)  unsigned int uiTemp;
(0039)  const int *p;
(0040)
(0041)  p = (const int *)0x40;
       3F E440      LDI  R20,0x40
       40 E050      LDI  R21,0
(0042)
(0043)  uiTemp = *p;
       41 01FA      MOVW R30,R20
       42 90C5      LPM  R12,Z+
       43 90D4      LPM  R13,0(Z)
(0044)

John
At 17:15 14/11/2007, you wrote:
>Hi people
>
>I'm trying to use the expression *(const word*)0x40 to read from a 
>flash location,
>but the result seem to be that the compiler reads I/O-locations 
>0x20, 0x21 instead.
>
>When using a variable as address the result is correct.
>
>; void TestCase()
>; {
>.dbline 139
>;  word i = 0x0040;
>ldi R24,64
>ldi R25,0
>movw R10,R24
>.dbline 140
>;  SendDebug(*(const word*)i);
>movw R30,R24
>lpm R16,Z+
>lpm R17,Z
>xcall _SendDebug
>.dbline 141
>;  SendDebug(*(const word*)0x0040);
>in R16,0x20
>in R17,0x21
>xcall _SendDebug
>.dbline -2
>L16:
>.dbline 0 ; func end
>ld R11,y+
>ld R10,y+
>ret
>
>
>_______________________________________________
>Icc-avr mailing list
>Icc-avr at imagecraft.com
>http://dragonsgate.net/mailman/listinfo/icc-avr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dragonsgate.net/pipermail/icc-avr/attachments/20071114/c3c43c5b/attachment.html


More information about the Icc-avr mailing list