Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have a number of PDP11's (that escaped nuclear obliteration) and have the skills to keep your nuclear plant running until 2050 [0]. The instruction set is really worth studying to this day, and the fact it has both pre and post-increment/decrement surely informed the design of C (and its predecessors). So orthogonal a single instruction could replicate itself through memory:-

MOV (-PC),(-PC)

As the instruction counter (PC, AKA R7) auto-incremented on each instruction, that instruction first decrements the PC (so it points back to the current instruction) and then copies the contents of the memory location (i.e. the current instruction) to the next lower memory address. And since the PC has now been decremented twice, the operation can repeat until it hits somewhere without any physical RAM (as PDP-11's have a bus signal to tell them whether the addressed memory exists or not).

Also easy to program in octal; knowing that MOV is 01MRMR, addressing mode M is 4 for pre-decrement and R is the register number, no-one even needed an assembler to write that instruction as:-

014747

The ultra-regular ISA made it easy to learn and remember bootstraps, it'd just take a few passes along the toggle switches to key in a loader. It became rather easier with boot ROMs and serial terminals, e.g. on the LSI-11 just typing '173000G' was enough to bring up the system (back then I got to code a boot loader for 5" disk drives, 2 different 8" disk driver and a user interface with a prompt into 256 words of ROM).

Those were the days, my friend.

Funnily enough I booted one of the PDP's a few days ago and it wasn't even hard to remember op-codes learnt 40+ years ago.

[0] https://news.ycombinator.com/item?id=5904191



from the stackoverflow topic titled:

"What are the historical reasons C languages have pre-increments and post-increments?":

https://stackoverflow.com/questions/30429753/what-are-the-hi...

A quote from that topic:

>'Ritchie, The Development of the C Language:

"People often guess that they [ED. the increment and decrement operators] 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 seems to have some features that might have played a role, albeit I don't think it's entirely clear from the document that they were the main reason for the existence of both prefix and postfix ++'<


That's interesting, as I'd assumed the BCPL/B/C progression happened alongside the PDP-7 to PDP-11 progression with the PDP-11 being the design that regularised things.

The full set of addressing modes uses 3 bits, thus 8 addressing modes. Using these addressing modes on the program counter (R7) gave a lot of flexibility and was how constants and memory were loaded and stored. It might sound complex but in practice was incredibly easy:-

    mov #141,@#177566   ; Output 'a' to the terminal
That's a "MOV (PC)++,@(PC)++" instruction that loads the next word from memory (octal 141) and increments the PC and stores in the address given by the next word (after the constant, as the PC has just been auto-incremented) and finally autoincrements the PC again to leave it pointing to the next instruction. The layout in memory would thus be:-

  12737  # Instruction: MOV (PC)++,@(PC)++
  00141  # ASCII 'a'
  177566 # Address of terminal outer buffer
Given these games using the PC to address data and memory, PDP-11 programmers had little difficulty when it came to understanding C pointers.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: