PDP-6 Emulator Shows Lisp Origins and Car/Cdr Mechanics

 13 min video

 4 min read

YouTube video ID: dXBmCIfb92k

Source: YouTube video by ComputerphileWatch original video

PDF

The PDP-6, an early computer from the 1960s, was a significant machine in the history of computing, particularly for its role in the development of Lisp. Only about 23 units of the PDP-6 were ever built, making physical machines rare. Enthusiasts, like the presenter, have resorted to creating software emulators and even planning physical replicas of its control panel to relive the experience of interacting with this historical computer.

The PDP-6 Emulator and Peripherals

The presenter showcases a working emulator of the PDP-6, complete with graphical representations of its peripherals. These include:

  • Four units of DECtape (micro tape): An early magnetic tape storage system, similar to a floppy disk, used for storing files.
  • Teletype: For text input and output.
  • Display: Capable of plotting points and displaying text using a character generator.
  • Paper tape reader and punch: Though not used in the demonstration.
  • Front panel: A virtual representation, as a physical replica is not yet available.

Design Goals of the PDP-6

The PDP-6 was designed with several key objectives:

  • Time-sharing system: To allow multiple users to share the machine's resources.
  • Scientific computation: It included floating-point instructions, a feature not present in earlier or smaller machines.
  • Efficient Lisp execution: This was a crucial design goal, establishing a close relationship between the PDP-6 and Lisp.

The Sibling Relationship Between PDP-6 and Lisp

Lisp and the PDP-6 share a unique "sibling" relationship. MIT hackers, while developing Lisp on blackboards, would frequently visit DEC (Digital Equipment Corporation) during the PDP-6's construction. They would test and debug their Lisp code on the unfinished PDP-6, fostering a symbiotic development process.

Running Lisp on the PDP-6 Emulator

The demonstration begins by loading the DECtape directory, which is then displayed on the screen. The presenter uses TECO, an early text editor, to view the Lisp code. The light pen, an input device that senses intensified spots on the display, is simulated with a mouse.

The Lisp code, written for PDP-6 Lisp, is shown. It includes two simple functions: factorial (a recursive function for demonstration) and greet (a function that prints "hello"). This version of Lisp, dating back to around 1966, was recovered from a binary DECtape image and its source code restored.

To load the Lisp code, the presenter exits TECO and uses MACDUMP to load files from tape. After loading Lisp itself, a simple plus operation is performed to confirm Lisp is running. Then, the UREAD function is used to load the demo file from DECtape unit four.

The greet function is called, demonstrating its output. When factorial is called with an argument like 6, the initial output appears unusual because the PDP-6 defaults to octal representation. By setting the base variable to 10 (decimal), the correct factorial value is displayed.

PDP-6 as a Lisp Machine: The Story of CAR and CDR

Lisp was originally developed on the IBM 704. The cryptic Lisp functions car and cdr have their roots in the IBM 704's instruction word structure. An IBM 704 instruction word was divided into four fields:

  • Prefix field: 3 bits
  • Decrement field: 15 bits
  • Tag field: 3 bits (for index register)
  • Address field: 15 bits

While car and cdr were not direct instructions on the 704, they were named after operations that dealt with these fields. car stood for "contents of the address part of register" and cdr for "contents of the decrement part of register." Here, "register" referred to a memory word, not a hardware register as understood today.

In Lisp, these operations were used to construct list structures. One part of a cons cell (a fundamental Lisp data structure) would be stored in the address part, and another in the decrement part, forming linked lists.

The PDP-6, also a 36-bit machine like the IBM 704, handles car and cdr in a similar but more streamlined way. It splits a 36-bit word into two 18-bit halves: the left half for car and the right half for cdr. These 18-bit halves correspond to the address size of the PDP-6 and later the PDP-10. The PDP-6 has specific instructions for manipulating these "half-words," making Lisp's list processing very efficient.

The presenter highlights the elegance of the PDP-6 assembly code for car and cdr operations, describing it as "poetry" due to its brevity and efficiency in handling the left and right halves of a word. Lisp allows combining car and cdr into chains (e.g., caddr, caaddr) to access elements deep within a list structure, up to four levels.

The demonstration concludes by showing how to use the get function to inspect the definition of the fact function and how car and cdr permutations can be used to extract specific parts of the list structure.

  Takeaways

  • The PDP-6, a rare 36‑bit computer from the 1960s, was built to support time‑sharing, scientific computing, and especially efficient execution of Lisp, linking its hardware design directly to the language’s early development.
  • Modern enthusiasts have created a full‑screen emulator that reproduces the machine’s DECtape storage, teletype, display, and a virtual front‑panel, allowing users to load historic Lisp code and interact with it as if on the original hardware.
  • Demonstrations on the emulator load a 1966 Lisp system from a DECtape image, run simple functions like `greet` and `factorial`, and reveal that the PDP‑6 defaults to octal output unless the `base` variable is set to decimal.
  • The classic Lisp primitives `car` and `cdr` derive from the IBM 704’s instruction word fields, and on the PDP‑6 they are implemented as 18‑bit half‑word operations, making list processing extremely compact and fast.
  • The presenter describes the PDP‑6’s assembly code for `car`/`cdr` as “poetry,” highlighting how the machine’s architecture enables elegant chaining of these operations (e.g., `caddr`) to navigate deep list structures.

Frequently Asked Questions

Why does the PDP-6 display numbers in octal by default?

The PDP‑6 prints numbers in octal because its 36‑bit word size was traditionally expressed in base‑8, matching the machine’s hardware conventions and early software tools. Consequently, when Lisp runs on the emulator, results appear in octal until the user sets the `base` variable to 10, which switches output to decimal.

What is the historical origin of the Lisp functions car and cdr?

The names `car` and `cdr` come from the IBM 704’s instruction word layout, where the address and decrement fields stored parts of a word; `car` stands for 'contents of the address part of register' and `cdr` for 'contents of the decrement part of register'.

Who is Computerphile on YouTube?

Computerphile is a YouTube channel that publishes videos on a range of topics. Browse more summaries from this channel below.

Does this page include the full transcript of the video?

Yes, the full transcript for this video is available on this page. Click 'Show transcript' in the sidebar to read it.

Helpful resources related to this video

If you want to practice or explore the concepts discussed in the video, these commonly used tools may help.

Links may be affiliate links. We only include resources that are genuinely relevant to the topic.

Full transcript is not shown on this page

This page focuses on the summary and original notes. For full verification, refer to the original YouTube video.

PDF