PDP-11 data and function address spaces (was External ptrs and arrays)

Martin Minow minow at mountn.dec.com
Sat Nov 11 01:46:22 AEST 1989


In article <20642 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
>In article <11567 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>>By the way, the PDP-11 is the main example of a system where data and
>>function address spaces are distinct ....
>
>Before anyone jumps in and `corrects' Doug with stories of 11s in their
>college days ...

Hmmph, in my college days, computers used these funny-looking glass bottles
called tubes.
>
>This is reflected in C in that
>
>	char *p;
>	int fn();
>
>	p = (char *)fn;
>
>is non-portable, and hence, even after such an assignment, the result of
>
>	(*(int (*)())p)();
>
>is at best non-standard.

However, it should work, since the only thing that distinguished an
"instruction" reference from a "data" reference was the instruction
(actually, the register address) used to reference it.  What you
couldn't do (easily), however, was
	short function[] = {
	    012700,		/* Move value to R0		*/
	    012345,		/* Random value			*/
	    000207,		/* Return			*/
	};
	int	(*fn)();	/* Address of a function	*/
	...
	    fn = &function[0];
	    result = (*fn)();
The problem here is that the value you assign to "fn" is a virtual
address in data space, but the same virtual address in instruction
space may be a completely different physical address.

Martin Minow
minow at thundr.enet.dec.com



More information about the Comp.lang.c mailing list