home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Is this a Legal Way to Access a Specific Address?
- Message-ID: <1993Jan23.194116.16063@taumet.com>
- Keywords: DSP, C, ANSI, Fixed RAM
- Organization: TauMetric Corporation
- References: <1993Jan23.042626.991@verdix.com> <C1AzpG.4xy@cmie.ernet.in>
- Date: Sat, 23 Jan 1993 19:41:16 GMT
- Lines: 29
-
- rs@cmie.ernet.in (Rajappa Iyer) writes:
-
- >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;
-
- >It is definitely legal C.
-
- It is syntactically legal C, but the results of using the code are
- undefined by any standard. That is to say, you can't predict
- a priori whether the code will do what you want.
-
- Compilers typically have ways of allowing absolute machine addresses to
- be assigned to pointers, but the method depends on the machine and the
- compiler. You have to check the compiler manual.
-
- If parts of the code are machine-specific, as this clearly is, it is
- usually a good idea to isolate such code in separate modules. That
- code is then tailored for the machine and compiler. The remainder
- of the code (assumed to be portable) can be left alone when you change
- compilers or machines.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-