Article View: comp.dsp
Article #2104Re: Is this a Legal Way to Access a Specific Address?
From: Dave Andrews
Date: Sun, 24 Jan 1993 17:14
Date: Sun, 24 Jan 1993 17:14
33 lines
1560 bytes
1560 bytes
In article <1993Jan23.042626.991@verdix.com> scotty@verdix.com (Scott R. Chilcote) writes:
>
>We're programming a device that has a RAM cache at address 809800H.
>
>Is it legal to address this memory in C as follows?
>
>#define ON_CHIP 0x809800
>
>int main(void)
>{
>
> float *oc_ptr = (float *) ON_CHIP;
SHORT ANSWER: I don't *know* if this is legal.
LONG ANSWER: if I were the king of the forest, I wouldn't define this
as being legal. While you can do limited integer arithmetic with
pointers (incrementing or decrementing by a constant integer), the
pointers themselves are manipulated by the integer times the sizeof
the pointer type.
So to my mind, if you declared
float *oc_ptr = (float *) ON_CHIP;
it seems to me that the pointer would actually point to the 0x809800'th
float in memory starting at the lowest addressable location (not
necessarily NULL, BTW).
So in order to do what you want to do "legally", you'd have to figure
out what the ON_CHIP address would be in terms of a contiguous array
of floats.
- David Andrews
dandrews@bilver.oau.org
Technical Details
Message-ID:
<1993Jan24.171455.9451@bilver.uucp>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!cs.ucf.edu!tarpit!bilver!dandrewsReferences:
<1993Jan23.042626.991@verdix.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.dsp,comp.lang.c Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!cs.ucf.edu!tarpit!bilver!dandrews From: dandrews@bilver.uucp (Dave Andrews) Subject: Re: Is this a Legal Way to Access a Specific Address? Organization: W. J. Vermillion - Winter Park, FL Date: Sun, 24 Jan 1993 17:14:55 GMT Message-ID: <1993Jan24.171455.9451@bilver.uucp> Keywords: DSP, C, ANSI, Fixed RAM References: <1993Jan23.042626.991@verdix.com> Lines: 36