Book contents
- Frontmatter
- Contents
- Foreword
- Preface
- Figures
- 1 Introduction
- I Formalisms for Computation: Register Machines, Exponential Diophantine Equations, & Pure LISP
- 2 The Arithmetization of Register Machines
- 3 A Version of Pure LISP
- 4 The LISP Interpreter EVAL
- II Program Size, Halting Probabilities, Randomness, & Metamathematics
- A Implementation Notes
- B The Number of S-expressions of Size N
- Bibliography
4 - The LISP Interpreter EVAL
Published online by Cambridge University Press: 23 November 2009
- Frontmatter
- Contents
- Foreword
- Preface
- Figures
- 1 Introduction
- I Formalisms for Computation: Register Machines, Exponential Diophantine Equations, & Pure LISP
- 2 The Arithmetization of Register Machines
- 3 A Version of Pure LISP
- 4 The LISP Interpreter EVAL
- II Program Size, Halting Probabilities, Randomness, & Metamathematics
- A Implementation Notes
- B The Number of S-expressions of Size N
- Bibliography
Summary
In this chapter we convert the definition of LISP in LISP given in Section 3.6 into a register machine program. Then we compile this register machine program into an exponential diophantine equation.
Register Machine Pseudo–Instructions
The first step to program an interpreter for our version of pure LISP is to write subroutines for breaking S-expressions apart (SPLIT) and for putting them back together again (JOIN). The next step is to use SPLIT and JOIN to write routines that push and pop the interpreter stack. Then we can raise the level of discourse by defining register machine pseudo-instructions which are expanded by the assembler into calls to these routines; i.e., we extend register machine language with pseudo-machine instructions which expand into several real machine instructions. Thus we have four “microcode” subroutines: SPLIT, JOIN, PUSH, and POP. SPLIT and JOIN are leaf routines, and PUSH and POP call SPLIT and JOIN.
Figure 9 is a table giving the twelve register machine pseudo-instructions.
Now a few words about register usage; there are only 19 registers! First of all, the S-expression to be evaluated is input in EXPRESSION, and the value of this S-expression is output in VALUE. There are three large permanent data structures used by the interpreter:
the association list ALIST which contains all variable bindings,
the interpreter STACK used for saving and restoring information when the interpreter calls itself, and
the current remaining DEPTH limit on evaluations.
All other registers are either temporary scratch registers used by the interpreter (FUNCTION, ARGUMENTS, VARIABLES, X, and Y), or hidden registers used by the microcode rather than directly by the interpreter.
- Type
- Chapter
- Information
- Algorithmic Information Theory , pp. 69 - 90Publisher: Cambridge University PressPrint publication year: 1987