> On Feb 16, 2025, at 8:00 PM, ben via cctalk <cctalk@classiccmp.org> wrote:
> 
> ...
> I have trouble understanding the fine points of accessing a local variable in 
> Algol with a display. Books tend to spend more time
> on the evils of a dangling else, and gloss over the run time action of
> a display.

Displays are a solution to the problem of finding variables in an ancestor 
function block.  It doesn't appear in C since (standard) C doesn't have nested 
functions.

I'll use C notation here for simplicity, though.  Suppose you have:

        int f1(int i) {
          int j;
          int f2(int x) { int y; y = j*2; ... f1(x+1); }
          f2(...);
        }
        f1(42);

The local variables go into stack frames, one for each call of each function.  
So when recursive calls are made as in this example, there are multiple stack 
frames belonging to calls of f1 and of f2.  Each f1 frame has a j in it.  So 
how does the code for f2 find "the right f1 frame" to resolve the reference to 
j that I showed?

The answer is to have a display, which is a vector of pointers, indexed by 
"static scope", in other words by textual nesting level.  In this case that 
vector would have three entries: one for the program, f1, and f2.  When a call 
to f1 is made, the stack frame is created.  In the stack frame the previous 
value of the display entry for f1 is saved, and that entry is then set to the 
stack frame address.  On function return, the previous display entry is 
restored.

To resolve the reference to j in f2, the code would load the display entry for 
f1 (the second entry in the display vector), and add the offset to j in the 
stack frame.

On the X8 a reference to j through the display is a single instruction using a 
specialized addressing mode that does the whole job.  It assumes no more than 
63 statically nested blocks, but that's quite a reasonable limitation.

> Have a good example or reference book I can find free on line.
> Also is there a ENGLISH description of the EL-X8?

There's the article in Wikipedia.  Apart from that, find the "EWD archive" at 
UT Austin.  Many of the early EWD papers, up to number 150 or so, deal with the 
development of the THE operating system.  Some are in English, some in Dutch, 
for no obvious reason.  A number of the Dutch ones have been translated by 
volunteers working on that archive.  I think there are some useful summaries of 
the machine in there.

One thing you should not miss is the paper "The structure of the THE operating 
system".  It describes the design principles and why they were used; it lays 
the foundation for techniques that were used by many others afterwards.

        paul

Reply via email to