Hacking usim – A MIT-CADR Lisp Machine emulator

Brad Parker’s usim is a nice C-language emulator for the first Lisp Machine first broadly produced, the MIT-CADR. It’s said that by 1978 upwards of 25 were produced at MIT, pretty much making it the first ‘production’ Lisp Machine. The subsequent commercial Lisp machines much of their origins from the CADR, so it’s very interesting to see where most of the ideas started.

I’ve been developing a variation of Brad’s usim emulator that fixes a few bugs and repairs problems with the keyboard mapping for X11. My slightly kluged version can be found here; it’s not tested to work on anything but Ubuntu Linux 18.04. Your mileage may vary!

Nevertheless, this version is pretty easy to build and run without fiddling with the Makefile:

$ tar -zxf usim-20200810.tgzUnpack code
$ (cd usim/chaos; make)Compile chaosnet daemon
cd usim; makeCompile usim emulator
chaos/chaosd &Run chaosnet daemon in background
./usimRun the emulator!

Shortly we’ll see the CADR emulator running. Here I overlaid the terminal window output to get an idea of what you should see there:

MIT-CADR initial windows
Brad Parker’s CADR Emulator – The original red pill

Type in the current time and date. We should note that this version of the MIT code isn’t yet Y2K compliant, so it won’t properly display the year in date/time fields.

MIT-CADR ready to rock
MIT-CADR – Hacks await!

Let’s look at the code pre-installed on the disk image:

(login ‘bowb)Tell the CADR who we are
F2-eSystem-E – run Zmacs
Meta-XInvoke Zmacs Extended command
diredRun ‘dired’ subprogram
local:>*.*.*In Dired, match all files at the root on the ‘local’ filesystem

DireD and Lisp Machine demos

Dired commands are pretty similar to those in LambdaDelta, though ‘E’ doesn’t work, so browsing is a bit more of a hassle. Let’s browse to the demonstrations and see what we can find:

Meta-X diredcreate another dired window
local:>lmdemo>*.*.*match all files in subdirectory LMDEMO
MIT-CADR Demos
MIT-CADR – Demonstration Programs

So let’s load the worm demo into the buffer and compile. Just like the version of Zmacs on the Lambda, click on WORM.LISP to select, or use the spacebar to push the selection cursor down to that line. Then press ‘E’ to edit. Note that this emulator requires a bit of a hold of the left-mouse button to get the selection block to move.

MIT-CADR Worm demo code
MIT-CADR – Worm Demo code in Zmacs

We can compile the whole file using Zmacs:

Meta-X Compile FileCompile File extended command
<return>Use default buffer (local:>lmdemo>worm.lisp)
F2-lFlip back into Lisp listener
(hacks:worm)Run ‘worm’ demo from the ‘hacks’ namespace
qquit ‘worm’
MIT-CADR Fractal worm demo!
MIT-CADR – Fractal Worm, 1980-style!

Usim will get flaky (particularly the chaosnet daemon) after a while, so it’s a good idea to periodically restart everything. I’m sure there’s a way to fix it, but I’ll admit I’m less interested in debugging C-code than Lisp. That being said, let’s next demo the chaosnet file server and read some stuff into the CADR.

Loading a file from Linux into the emulator

When your usim is stopped, copy the file promh.9 into /tmp, then restart usim:

(login ‘bowb)Identify ourselves to CADR
(si:set-sys-host “server” ‘:unix 0404 “//”)Associate name ‘server’ with a
unix machine at chaosnet address 0404
with the base of the shared hierarchy
at “//”
F2-eStart Zmacs
Ctrl-X Ctrl-FFind File
server:/tmp/promh.9Path in unix for promh.9 on fileserver ‘server’
<return>CADR will demand a password; just use
empty string.
MIT-CADR Prom Microcode loaded from the Linux side
MIT-CADR – Editing microcode source

I haven’t yet been able to ‘complete the circle’ and recompile all the source code using Brad’s instruction, but I think we’re at a good stopping point for me, and a good launching point for your own MIT-CADR Lisp machine!

Happy hacking!