4 ms·
People suppose this, but that's not quite how it happened. C came from B, and B had ++ also. But B came before the PDP-11. The PDP-7 had hardware that suppor
by mturmon 11y ago
People suppose this, but that's not quite how it happened. C came from B, and B had ++ also. But B came before the PDP-11. The PDP-7 had hardware that supported auto-increment-by-one, and Ritchie suggests that's where ++ came from.
The PDP-7 assembler manual is at http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/pdp7/PDP-7_AsmMan.pdf http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/pdp7/PD..., but I can't see any reference to this auto-increment hardware, or to an assembler directive using it. What I'm getting at is that there appears not to have been an assembly language construct for auto-increment on the PDP-7 at all, even though its hardware supported it.
The hardware "auto-indexing" is described at page 3-12 of the PDP-7 architecture document, http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/pdp7/F-75P_PDP7prelimUM_Dec64.pdf http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/pdp7/F-... . It is enabled only for about 8 special memory addresses in each 8K of address space, so it is weird and handicapped by comparison with the PDP-11.
See Ritchie's history (http://www.bell-labs.com/usr/dmr/www/chist.html http://www.bell-labs.com/usr/dmr/www/chist.html) --
"Thompson went a step further by inventing the ++ and -- operators, which increment or decrement; their prefix or postfix position determines whether the alteration occurs before or after noting the value of the operand. They were not in the earliest versions of B, but appeared along the way. People often guess that they were created to use the auto-increment and auto-decrement address modes provided by the DEC PDP-11 on which C and Unix first became popular. This is historically impossible, since there was no PDP-11 when B was developed.
"The PDP-7, however, did have a few `auto-increment' memory cells, with the property that an indirect memory reference through them incremented the cell. This feature probably suggested such operators to Thompson; the generalization to make them both prefix and postfix was his own. Indeed, the auto-increment cells were not used directly in implementation of the operators, and a stronger motivation for the innovation was probably his observation that the translation of ++x was smaller than that of x=x+1."
- dboreham 11y agoVery interesting. I have supposed this since using PDP-11 assembler and reading Dennis' compiler in the late 70's. There were machines with auto increment modes long before the PDP-11 though, e.g. "http://ed-thelen.org/comp-hist/GE-635.html#Indirect http://ed-thelen.org/comp-hist/GE-635.html#Indirect Then Tally (IT) Modification"
- mturmon 11y agoI hear you. I learned assembler on the PDP-11 -- a delightful memory -- and had the same misconception until I read Ritchie's piece.