Page:AIM-443.djvu/4

 implemented in many languages.

Let us consider the execution of a call on the LISP function :

calls  on ,   on  , and then   on the two results, returning the result of calling.

For concreteness, we will express the compiled code in a modified form of PDP-10 machine language, using these instructions:

The code for  might look something like this:

We have introduced the labels,  ,   to aid the exposition. Note that there are no instructions between the  and the  ; we shall justify this below.

On arrival at, the arguments   and   are presumably in registers or some other appropriate place, and a return address (say  ) is on the stack. After we execute the, the stack will look like this:

may call other functions, and the stack will go up and down, but eventually it will put a value in the result register and do a, returning to. This leaves the stack like this:

In a similar manner, the  will push   on the stack, and   will eventually pop it when it exits. The same is true of the  and. When  returns to   with a value in the result register, the   at   is performed, returning to. Since  was to return the result of calling , the correct value is in the result register for.

Notice that during the execution of  the stack looked like this: