[TUHS] Software written in B

segaloco via TUHS tuhs at tuhs.org
Thu Jun 8 12:10:08 AEST 2023

> Of course, B was a "transition" language, that did not have a continued
use as soon as it evolved into C. so if any software remains, it will be
quite hard to find.

There is a bit of binary code from that transition period that may hold some answers.  In my disassembly of the s2-bits binaries (V2-ish), I've come across the following that bear a particular signature I can't identify otherwise:

echo, exit, glob, goto, if, mail, skip, stty, su

This "signature" I refer to being a few properties of the a.out files and initial flow of the entry compared with other binaries of known source code origin.  First, these are all magic number 405(8) binaries, so V1 era a.out.  Second, in each case, the initial branch is to a jump vector which then performs a r5-relative subroutine call followed by a halt in the case of fallthrough.  In other words:

    br  _start  / 405(8)
    jmp innerstart    / some faraway place
    jsr r5,main    / always 004567 000042
    inc somevalue   / always 005267 000136 or 005267 000140

Finally, these all appear to have the four characters "Init" strewn in there with a bunch of binary data.  It is consistently in all of the above binaries exhibiting these other two patterns.  I don't have any confirmed B code/binaries to compare against, so I can't say that this is a signature of B, but it is a signature of *something*.  Whatever it is these all share it.

This can be compared with disassembly of programs like:

    - ln, a "naked" binary in that it has no a.out header that immediately calls break
    - chown, a V1 a.out (magic number 405(8)) that jumps immediately into the assembly routine
    - find, a V2 a.out (magic number 407(8)) that does the same
    - fc, a V2 a.out compiled from C that branches into a crt0 startup that then jumps to main, this crt0 startup matches the crt0.o file in s2-bits

Something of note too with the above programs is that the earliest preserved versions of each are all in C.  That being exit, glob, goto, and if from the s1-bits tape (V3-ish) as well as echo, mail, stty, and su in V5 (not sure what skip is/was).  This is all pretty compelling, but conjecture nonetheless.  Perhaps it will draw hard proof closer.

- Matt G.

P.S., these are the other s2-bits binaries by "signature":

    - naked - cal, chmod, dsw, ln, rm
    - V1 asm - :, ar, bas, cat, chball, check, chown, cmp, cp, date, db, dc, df, du, ed, form, getty, init, login, ls, mesg, mkdir, msh, mv, od, pr, rew, rmdir, roff, sh, sort, stat, sum, tap, tm, tty, wc, who, write
    - V2 asm - as, as2, ds, find, ld, maki, nm, strip, un
    - V2 C - cc, fc, size

More information about the TUHS mailing list