|pointed pointer questions firstname.lastname@example.org (1988-07-15)|
|From:||email@example.com (Dave Jones)|
|Keywords:||pointer Pascal compiler|
|Date:||15 Jul 88 03:06:30 GMT|
|Organization:||Megatest Corporation, San Jose, Ca|
Let us speak of pointers and alignment. Here's your chance to
show off your knowledge of machine architectures and
compiler theory. Impress your friends. Win new followers....
The purpose of the exercise is to define a virtual machine compatible
on the one side with Pascal, and on the other with any reasonable
hardware. The traditional P-machine comes up a little short when
it comes to pointer arithmetic. As you probably know, there are
some machines that store pointers to integers in 13 1/2 bit
interleaved nybbles, and pointers to functions in Best Foods Mayonaise
jars -- at least it seems that bizzarre.
(What kind of punishment is appropriate for the designers
of such systems is another subject intirely.)
So question number one is, to be safe, how many kinds of pointers
should the virtual machine have? If you define them according to
the Pascal types, you get TEN of them for Pete's sake!
/* pointers to Pascal primitive types */
/* pointers to Pascal constructed types */
/* pointers to functions and procedures */
/* (For procedure-valued parameters) */
Which of these can safely be folded together? How many do I *really*
need, and what are they?
It is possible (at least in BSD-derived Pascals) to pass components of
records as var-parameters.
This means that the virtual machine must have a way to convert
a structure-pointer and a field-displacement into any kind of
pointer. To convert to the first nine of the pointer-types listed above,
the op-codes proliferate in a sickening fashion:
FIELD_REAL, /* returns pointer to real */
FIELD_INT, /* returns pointer to int, etc.. */
FIELD_PTR_ENUM, /* returns pointer to pointer enum */
FIELD_REAL_PTR, /* etc. */
I am tempted to boot the whole idea, and just say there is one
kind of pointer: a thirty-two bit word. And we will burn all
the the computers that don't behave that way.
Another idea is to have a mapping between Pascal-pointer types
and machine-pointer types that can be redefined for different kinds
of hardware. The question then is, "What set of machine-pointer
types is sufficient to keep the most berzerk system designer appeased?"
[From firstname.lastname@example.org (Dave Jones)]
Return to the
Search the comp.compilers archives again.