[TUHS] b remnants?

A. P. Garcia a.phillip.garcia at gmail.com
Sat Oct 15 13:57:37 AEST 2011

On Fri, Oct 14, 2011 at 9:52 AM, A. P. Garcia
<a.phillip.garcia at gmail.com> wrote:
> In memoriam, I read The Development of the C Language:
> http://cm.bell-labs.com/who/dmr/chist.html
> It talks a bit about how B was originally implemented somewhat like
> ETH Pascal (p-code). Are there any B interpreters or programs in the
> archive?

What intrigued me about this is that it's such an early example of an
abstract machine running as an interpreter. BCPL, roughly
contemporaneous, used ocode as an intermediate language, but it seems
this was intended to be further translated into assembly. While it's
possible to interpret ocode, in practice it seems this was rare, if it
was done at all. Almost everything I've read about abstract/vitual
machines traces its roots back to the following source:

James R. Bell. 1973. Threaded code. Commun. ACM 16, 6 (June 1973),
370-372. DOI=10.1145/362248.362270

Here's where dmr mentions implementing B using this technique:

The B compiler on the PDP-7 did not generate machine instructions, but
instead `threaded code' [Bell 72], an interpretive scheme in which the
compiler's output consists of a sequence of addresses of code
fragments that perform the elementary operations. The operations
typically—in particular for B—act on a simple stack machine.

Note he says it was published in 1972, when it actually appeared in
print in 1973 (same page numbers). Two paragraphs later he writes:

By 1970, the Unix project had shown enough promise that we were able
to acquire the new DEC PDP-11. The processor was among the first of
its line delivered by DEC, and three months passed before its disk
arrived. Making B programs run on it using the threaded technique
required only writing the code fragments for the operators, and a
simple assembler which I coded in B; ; soon, dc became the first
interesting program to be tested, before any operating system, on our
PDP-11. Almost as rapidly, still waiting for the disk, Thompson
recoded the Unix kernel and some basic commands in PDP-11 assembly
language. Of the 24K bytes of memory on the machine, the earliest
PDP-11 Unix system used 12K bytes for the operating system, a tiny
space for user programs, and the remainder as a RAM disk. This version
was only for testing, not for real work; the machine marked time by
enumerating closed knight's tours on chess boards of various sizes.
Once its disk appeared, we quickly migrated to it after
transliterating assembly-language commands to the PDP-11 dialect, and
porting those already in B.

The abstract machine is also mentioned in Thompson's "Users' Reference
to B", dated January 7, 1972. If the 1970 date is correct, they were
using this technique some three years before most of the computing
world knew about it!?

More information about the TUHS mailing list