>On Thu, 25 Sep 2003, Don wrote:
I cant't do MyArray[2048] = {0x00} @ 0xFFFF1199 :-(
I am using the gnu compiler.
In article <Pi************ *************** ***@drj.pf>
Darrell Grainger <da*****@NOMORE SPAMcs.utoronto .ca.com> writes:... If you have to have it as an array then check with a newsgroup that deals
with your compiler. You can sometimes define a section of data to a linker
section name (.text, .bss. data, etc.) and then instruct the linker to put
that section at a specific memory location. This is highly dependent on
your linker and completely off topic for comp.lang.c.
Assuming he is using the GNU binutils linker as well as the GNU
compiler suite, there is indeed a way to do it. The C code
portion can consist entirely of:
extern char MyArray[2048];
with linker directives to put the known name at the chosen address
and (if needed, and if the target link format is capable) to fill
the chosen address with 2048 zero-bytes. Since the binutils linker
directives are not C, you will have to go somewhere else for that
part. :-)
(For more complex cases, one can also use gcc's __attribute__
extension to assign linker sections, as noted above, but beware:
this is buggy in various versions of gcc.)
In general, it is probably better to access specific regions of
memory or memory-mapped I/O via "volatile unsigned char *" pointers
and the like. But on specific architectures, absolute addressing
modes sometimes generated via the "extern char A[]" method may be
desirable in certain cases. (As you might surmise from the amount
of weasel-wording here, this can get quite dicey. Not only do you
need to know everything about the target CPU and hardware, you also
need to know precisely what comes out of the compiler under each
of its different optimization and code-generation models. With
gcc, for instance, using -fpic or -fPIC could really wreck things.)
--
In-Real-Life: Chris Torek, Wind River Systems (BSD engineering)
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it
http://67.40.109.61/torek/index.html (for the moment)
Reading email is like searching for food in the garbage, thanks to spammers.