TMG – How to Understand TMG’s Assembly Code from Version 6 Unix

assemblycompilerhistorical-unix

Early versions of Unix included Doug McIlroy's tool tmg ("transmogrifier"), an early compiler-compiler. TMG was implemented in Dennis Ritchie's assembly language as well as in TMGL itself (the language that TMG translates into assembly).
Here is TMG's manual (1972). Here is the complete source code from Version 6 Unix.

Since I am trying to understand how McIlroy's implementation of TMG worked, I am reading the file tmgl.s, a translation of tmgl.t done by TMG. And I am baffled by the following excerpts:

.1=.
1
.2=.
2
.3=.

And:

goto;..2
..3:null
..2:

I read the PAL-11R and Unix Assembly manuals, but do not recall an explanation.

Particularly:

  • . means "location counter", but what is .3=.?
  • .. means "relocation counter", but what is ..3?

(To make things worse, this kind of syntax seems to be only encountered in TMG implementation, not any other source file of Unix V6. And, to exclude the possibility of a corrupt code or phased out syntax, TMG sources actually compile in a Python PDP-11 emulator running Unix V6.)

Best Answer

.1, ..1 have no special meaning. They're simple identifiers (labels, variables, etc). Unless declared with .globl, they will be local by default.

That was the case then and is still the case now. For instance, gcc is using . to prevent static variables from conflicting with symbols defined by the user.

what is .3=.?

It assigns to the local symbol named .3 the value of the location counter (the offset within the current segment).

Related Question