piclist 2001\02\26\151621a >
Thread: MPLAB-C porting
face BY : Mike Mansheim email (remove spam text)

from RS:
>> Why would this be?
>  unsigned int flashadd = 0x8000;
>  unsigned long far *frdaddr;
from RS:
>  frdaddr = (unsigned long*)flashadd;
from MM:
>  This will still result in frdaddr = 0.
>  Is that the intended result?

I'm getting lost in > symbols, so I've edited liberally!
I'm just saying that flashadd = 0, because it is defined as an int.  It
is actually incorrect to assign 0x8000 to an int, but the compiler will
accept this and assign the lower byte (0 in this case).
In the original post, the statement was:
           frdaddr = flashadd;
which will result in frdaddr = 0.
I incorrectly neglected the '*' in the RS modified frdaddr assignment
statement: I was reacting to:
           frdaddr = (unsigned long)flashadd;
which will still result in frdaddr = 0, since the original assignment of
0x8000 won't be "remembered" even if flashadd is later cast to a long.
The '*' changes things dramatically:
           frdaddr = (unsigned long*)flashadd;
This puts the value of what flashadd points to into frdaddr.  In this
case, flashadd = 0, so frdaddr will be assigned whatever is stored at
locations 0 & 1.  So, in that case, you are correct, frdaddr will not
necessarily be 0.
However, that doesn't look like the original intent, since the 0x8000 is
getting lost.  I can't be sure, because I don't understand how the
statements could have functioned properly before - this could be a good
sign that I'm not "getting it".
It looks to me as though he intended for frdaddr = 0x8000 ("addr" being
in the name is part of that reasoning).  Then, frdaddr would be used to
access the value at 0x8000:
            x = *frdaddr;
now x = whatever value is stored at 0x8000.  Perhaps then frdaddr is
decremented to step through memory; so flashadd was used to define the
starting point???

http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


See also: www.piclist.com/techref/microchip/ios.htm?key=port
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) MPLAB-C porting

month overview.

new search...