探索 PDP-1 Lisp (1960年)
Exploring PDP-1 Lisp (1960)

原始链接: https://obsolescence.dev/pdp1-lisp-introduction.html

本指南旨在作为在历史悠久的 PDP-1 计算机上使用 Lisp 的实用入门手册。PDP-1 Lisp 由约翰·麦卡锡(John McCarthy)开发,由于它与现代编程环境存在显著差异,因此需要使用者了解其特定的操作特性。 **关键操作说明:** * **系统控制:** 请始终将地址开关设为 0004。如果系统因输入错误或故障而死机,请按“START”(启动),然后按“CONTINUE”(继续)进行重置。 * **输入:** 命令需以空格而非回车键结尾来执行。使用 `nil` 来确认系统是否处于活动状态。 * **数学运算:** 请注意 PDP-1 Lisp 使用八进制算术(例如 `4 + 4 = 10`)。 **代码管理:** 程序通常通过使用“感应开关 5”(SS5)的纸带进行加载。如需保存代码,请在使用 `pdef` 函数时将“感应开关 3”(SS3)设为将输出定向至纸带穿孔机。由于 PDP-1 使用非易失性磁芯存储器,程序在电源循环后仍会保留。 如需深入研究,请参阅原始的 PDP-1 和 Lisp 1.5 手册。您还可以利用所提供的文档文件,训练 AI 助手作为您 PDP-1 项目的编程辅助工具。

这篇 Hacker News 讨论帖探讨了 PDP-1 Lisp 的历史意义。该语言最初由彼得·多伊奇(Peter Deutsch)于 1960 年读高中时编写。用户们强调了它在极其有限的硬件(4K 18位字)上令人惊叹的可用性,以及它对现代编程(特别是 REPL 概念)的深远影响。 为了鼓励探索,作者邀请用户通过开源模拟器运行 PDP-1 Lisp 代码。讨论随后转向人工智能历史,将 20 世纪 60 年代的“伊莉莎”(Eliza)热潮、后来 MIT 人工智能实验室的 SHRDLU 的成功,与当代大语言模型(LLM)的炒作进行了对比。参与者反思了“人工智能寒暑交替”的周期性规律,指出尽管技术进步迅速,但人们的期望往往超出了现实。此外,有用户寻求关于 Lisp 历史的综合性书籍推荐,其他用户则建议查阅早期的学术资源。
相关文章

原文

WORK IN PROGRESS, THIS IS AMENDED AS I LEARN PDP-1 LISP MYSELF.
But hopefully, it will get you started. Feedback is very much solicited in the Google Group :-)

PDP-1 Lisp: Introduction
Lisp was developed in 1958 by John McCarthy at MIT. It pioneered a high-level, symbolic programming language designed for AI research. Early Lisp introduced key concepts such as recursion, symbolic expressions, and automatic storage management.


This page only gives quick-start instructions for PDP-1 Lisp. Knowledge of Lisp is not required, this only shows how Lisp works on the PDP-1. Useful as a start into the Lisp world - and still interesting even if you do not want to learn more about Lisp itself.

Two manuals will be essential once you delve into more details. The first is the PDP-1 Lisp manual (link) and the second, the original, full-featured Lisp 1.5 Programmer's manual (link) for the IBM 7090, that Deutsch used as his target. The IBM Lisp 1.5 manual gives a good overview of Lisp 1.5 in general, the PDP-1 Lisp manual explains how to use the PDP-1 version - practical operation and language differences.


PDP-1 Lisp is much more tempting than I initially thought... But first, let us do a quick overview of PDP-1 Lisp in practice.
Bringing up Lisp
You can now work in Basic Lisp for the PDP-1! Some things to know before you proceed:
  • Always set the Address Switches to 0004 at this point. Because after running a Lisp program you then just press START and CONTINUE to go back in to Lisp.
  • Also, typos and errors make Lisp come to a halt. That is normal. For instance, type 'nix[space]' instead of 'nil[space]'. In such situations, just press START, then CONTINUE. But make sure the Address switches point to the start location, 4, though.
  • Lines are not entered by hitting return, but by adding a closing space. So, to see what atomic symbols are defined, type oblist [Space].
  • Before you do any typing in, it is always useful to see if Lisp is still running! Enter 'nil', which you will always see typed out even if Lisp is not running. But Lisp should respond with a second 'nil' on a new line. If not: START, then CONTINUE. You will probably make a habit of quick 'nil' checks before you enter anything new in PDP-1 Lisp. It is also the best way to start on a new line...

Enter (plus 1 2) outputs 3. Note 'plus' rather than '+'! (times 4 4) correctly outputs 20. Because 20 octal is 16 decimal...
Now, let's enter a little program (use [Return] and [tab] keys when entering the program):


(prog (a b)
	(setq a 4)
	(setq b 4)
	(plus a b)
	(return (plus a b))) 

...and close with a [space]. This will return 10. Because, indeed, 4+4=10 in octal :-)

Loading and saving
Paper Tape Input
Because the Lisp function to actually save your newly created code to paper tape is not built in to Basic Lisp, you will first need to load such a function from paper tape. This is also just the regular way of loading any code in Lisp:
  • Mount the alphanumeric tape lisp-defs.pt
  • Set SS5 to down, and straight away the tape gets read in
  • You will see the newly loaded functions come by in the typewriter output:
    
    zerop 
    pdef 
    count
    
  • Set SS5 to up again for typewriter input
  • Press START, then CONTINUE. And make sure the Address switches are indeed set to 4.

This is how loading any Lisp code will work. Mount the alphanumeric tape with your functions, set SS5, and see them loaded in.

Make a test tape to read in your own functions
First, prepare a little test tape. Paste this in a file called test.lisp on your laptop:


(rplacd (quote tt)  (quote
	(expr (lambda ()
	(prog ()
	(print (quote hello))
	(terpri)
	(return 5))))))
[space] 

Make sure the last line of code has a space at the end of it to terminate the function.
Now make a paper tape image out of this text file, to read in to the PDP-1: encode_fiodec test.lisp test.pt
  • Mount the alphanumeric tape test.pt
  • Set SS5 to down, the tape gets read in
  • You will see the output:
    tt 
    
    hello
    
    5
    
  • Set SS5 to up again, to revert to typewriter input
  • Press START, then CONTINUE. And make sure the Address switches are indeed set to 4.

Now, to see the program that was just loaded: (print (cdr (quote tt)))

Contents of the lisp-defs paper tape:

(rplacd (quote zerop) (quote (expr (lambda (n) (eq n 0)))))

(rplacd (quote pdef) (quote (fexpr (lambda (x a) (list (quote r placd) (list (quote quote) (car x)) (list (quote quote) (cdr (ca r x))))))))

(rplacd (quote count) (quote (expr (lambda (n) (prog (u) (setq u n) (cond ((zerop u) (return nil))) (print u) (setq u (plus u ( minus 1))) (go a))))))

Paper Tape Output
(print (cdr (quote tt))) shows the body of the program, but it does not output the function definition! In other words, (rplacd (quote tt) (quote is not printed out. But you want to save the actual program definition on paper tape, so you can load it next time, punching (print (cdr (quote tt))) is not enough.

The solution is the function pdef that we loaded from the lisp-pdefs tape.

  • Turn up Sense Switch 3 to send output to the punch instead of the typewriter
  • Type (pdef tt), end with the trailing space character as always, and you see your function punched out to tape.
  • Turn down Sense Switch 3 to return to typewriter output, and save the paper tape for future use

Closing remark...
Of course, a PDP-1 uses core memory, and core memory is non-volatile. So if you shut down the P(i)DP-1, next time you power up, everything is still in memory. No need to bring up Lisp agin from paper tape. Just set the address switches to 4 and press START, then CONTINUE.

Footnote: a more extensive lispFunctions file is https://bitsavers.org/bits/DEC/pdp1/papertapeImages/20031216/lisp/lispFunctions.bin . As yet untested, many useful functions.

Loading DDT & mixing assembly in Lisp programs
For this, please refer to the PDP-1 Lisp manual (link). By setting a lower top address for Lisp, there is room at the top for DDT to live in. And you can jump from Lisp to DDT using the front panel START switch.

An AI tutor for PDP-1 Lisp
We have created some .md text files that you can literally paste into ChatGPT, Claude Code or any other AI, telling the AI to learn about PDP-1 Lisp and to become your programming aide. Try this! It gives you a very smart side-kick, even if it is not perfect. Just paste one or more of the .md files into the AI, let it process the information, then start asking questions or giving tasks.
  • PDP1.md: the text you want to paste into your AI as the base PDP-1 expertise.
  • lisp.md: teach the AI about PDP-1 Lisp
  • lisp1_5.md: teach the AI about the Lisp 1.5 Programmer's manual

联系我们 contact @ memedata.com