Vault · archived work, not current thinking

The Rest of the Notebook

1989

A handwritten notebook page reading 'Enter all fractions as a list.' followed by 'Ex: two thirds times four fifths', then the two fractions written as the lists { 2 3 } and { 4 5 }, then the word MULT.

Twenty-five photocopied pages came back from 1989. Four of the programs on them have entries here already — Space Chase, Doodle, the Telephone Directory and the Checkbook. These are the other five.

They are smaller and they are not lesser. Three of them are named in the paper that came out of the course — “The class produced programs for scrolling, drawing, polar graphing, and directory handling. It also produced SPACE CHASE, an action game.” Drawing is Doodle. Scrolling, polar graphing and directory handling are here, and the paper credits them to the three of us. Fractions and the beep switch appear in no paper at all; they are just what else was in the notebook.

Directory Handling

Five programs that copy or delete a whole directory tree, however deep it goes.

CPYDR and DELDR call themselves. That is the whole answer to “however deep it goes” — a directory of unknown shape gets walked by recursion, on a machine with thirty-two kilobytes holding the programs, the data and the stack at the same time. There is no depth limit written anywhere in the code, which means the limit is memory, and the program will find it for you.

DELDR also carries a query, inked on the page: ? XTRA DELDR, with an arrow pointing at a struck-out repetition. Somebody read their own code back, found a call they could not account for, and left the question on the page rather than the answer.

Scrolling

Two programs that turn a four-line display into something you can read a document on.

WRAP breaks a string into 24-character lines on word boundaries. Disp shows four of them and moves through the rest on the UP and DOWN keys. The entire manual is one handwritten sentence under the listings: “For WRAP, all that needs to be on the stack is a string. Same thing for Disp!”

Selden’s paper prints three programs here — WRAP, Disp and MVS. The notebook has only two, because MVS has been folded into Disp. So on this page the notebook is the later draft, which is the reverse of Space Chase, where the paper holds the newer version. The notebook was not written once and set down.

Fractions

Seven programs for exact rational arithmetic, on a calculator that would otherwise hand you 0.6666666667.

A fraction is a two-element list — { 2 3 } is two thirds — so the calculator’s own list type carries the numerator and the denominator and nothing new had to be invented to hold them.

GCD is Euclid’s algorithm in seven tokens:

« WHILE DUP REPEAT SWAP OVER MOD END DROP »

That same loop turns up two pages later inside DG→RD, reducing a fraction of π. Whoever wrote the second one had the first one open.

Complex Variables

Polar and rectangular conversion, and the only programs in the notebook that never reached a printer.

Everything else in the notebook was printed on the infrared printer and photocopied. These four pages are pen, with the stack convention sketched in the margin beside each program and no manual anywhere. POLR displays a complex number both ways at once: as a + bi, then its length, then its angle expressed as a fraction of π rather than a decimal — which is why it needs a GCD.

DG→RD runs off the bottom of page 24 and picks up at the top of page 25 under DG→RD cont…. An earlier pass at transcribing these stopped at the page break and recorded the program as unfinished. Joined up, it is complete.

Beep Control

One program, one flag.

System flag 51 is the 28S’s beep-suppress flag. BPSET tests it, flips it, and puts * * BEEP ON * * on the screen for two tenths of a second. That is the whole program.

Beside it on the same page, in pen, is a second version called beep that throws away the display code and hands the string straight to a ROM entry point at #1BB44h. It is four lines shorter and it does not tell you what it did. Something immediately before the address is struck out, so the address took at least two attempts to find.

That pair is the notebook in miniature: the printed version that works, and the handwritten one beside it going after the same thing with fewer instructions.


All five are transcribed from the notebook and checked for structure; the scans are contrast-corrected here and the untouched captures are in the repository. Same machine, same year and same notebook as Space Chase, Doodle, the Telephone Directory and the Checkbook; the paper is The HP-28S, Calculus, and Programming.

← Back to tools