help! (rather long)

B Reytblat brt at pyuxvv.UUCP
Wed Mar 21 01:05:12 AEST 1984


$$$$$$$$$	<- bribe to the line-eater

This is a rather long submission consisting of questions, theories
and examples:

	1. I'm running C programs in a STAND-ALONE environment.
	Problem:
		How does one bind an INITIALIZED variable to a specific
	address? What I want to do is some thing like this:

		struct FOO{ ... } name;
		(struct FOO *)0x80 = &name

	Needless to say, cc barfs on the 0x80 part.

	2. I have attempted to do this by splitting the program in two
	source files:

	file1:
		extern struct FOO name;
		struct FOO *p_name = &name;

	file2:
		static struct FOO name;
		extern struct FOO *p_name;

	and then binding the .data section of  file1 to the address in
	question using an allocation tool similar to ld(1). As you can see,
	p_name must be accessible inside file2. Also, in physical memory, 
	p_name is surrounded by other things, so I can't put name and p_name
	into the same source file (or else they will go into the same
	.data section, and end up in contiguous memory locations.) 

	Unfortunately, that didn't work either. It seems (and this is pure
	speculation based on a few hours of hacking different versions of
	this) that cc(1) understands (&name) to be a compile-time constant
	rather than a reference to a variable.  I haven't looked at the
	code to see if this is really true (and if I did, I wouldn't know
	where to look :-).

	3. I'm sure some of you have run into this sort of thing before.
	Am I completely off base? What have I missed? Are there any 
	"nice" solutions to the original problem of bindidng an
	initialized variable explicitly? Or is this another one
	of those things that C cannot do?

			Thanks for help in advance,
			B.Reytblat
			...!pyuxvv!brt
			(201)-981-2044 (office)

"... I'm a hacker,
	she's a hacker,
	   he's a hacker,
		Wouldn't you like to be a hacker too?
     Be a hacker,
	Try a little hackin'
     Be a hacker,
	Try a little hackin' ..."



More information about the Comp.lang.c mailing list