home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / dsp / 3080 < prev    next >
Encoding:
Text File  |  1993-01-25  |  1.5 KB  |  49 lines

  1. Xref: sparky comp.dsp:3080 comp.lang.c:20149
  2. Newsgroups: comp.dsp,comp.lang.c
  3. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!cs.ucf.edu!tarpit!bilver!dandrews
  4. From: dandrews@bilver.uucp (Dave Andrews)
  5. Subject: Re: Is this a Legal Way to Access a Specific Address?
  6. Organization: W. J. Vermillion - Winter Park, FL
  7. Date: Sun, 24 Jan 1993 17:14:55 GMT
  8. Message-ID: <1993Jan24.171455.9451@bilver.uucp>
  9. Keywords: DSP, C, ANSI, Fixed RAM
  10. References: <1993Jan23.042626.991@verdix.com>
  11. Lines: 36
  12.  
  13. In article <1993Jan23.042626.991@verdix.com> scotty@verdix.com (Scott R. Chilcote) writes:
  14. >We're programming a device that has a RAM cache at address 809800H.
  15. >
  16. >Is it legal to address this memory in C as follows?
  17. >
  18. >#define ON_CHIP 0x809800
  19. >
  20. >int main(void)
  21. >{
  22. >
  23. >   float *oc_ptr = (float *) ON_CHIP;
  24.  
  25. SHORT ANSWER: I don't *know* if this is legal.
  26.  
  27. LONG ANSWER: if I were the king of the forest, I wouldn't define this
  28. as being legal.  While you can do limited integer arithmetic with
  29. pointers (incrementing or decrementing by a constant integer), the
  30. pointers themselves are manipulated by the integer times the sizeof
  31. the pointer type.
  32.  
  33. So to my mind, if you declared
  34.    float *oc_ptr = (float *) ON_CHIP;
  35. it seems to me that the pointer would actually point to the 0x809800'th
  36. float in memory starting at the lowest addressable location (not
  37. necessarily NULL, BTW).
  38.  
  39. So in order to do what you want to do "legally", you'd have to figure
  40. out what the ON_CHIP address would be in terms of a contiguous array
  41. of floats.
  42.  
  43. - David Andrews
  44.   dandrews@bilver.oau.org
  45.  
  46.  
  47.  
  48.