9

The PDP-1 is a ones' complement machine, and does some checks to make sure you (almost) never get negative zero. I'm struggling to think why anyone would want ones' complement arithmetic, but it was more popular in the past. Then the PDP-4 came along, (and the similar -7, -9 and -15). The -4 was meant to be cheaper than the PDP-1, and many features were dropped. The machine encoding was very much simplified, and many instructions were dropped altogether. The I/O system was pruned right back as well, becoming much more similar to the PDP-8's.

So my question is, if they were pruning so much out of the architecture, and also adding two's complement (the correct way, as everyone knows), why leave ones' complement in?

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Chenmunka
    Mar 29 at 17:56
7

Looking at the PDP-7 maintenance manual, pages 3-19 and 3-20, the one's complement add (ADD) and the two's complement add (TAD) are implemented by a parallel half-add step (described as "xor") followed by a serial carry-propagation step.

The only difference is in the second step, where you need to preserve the sign and do a carry-around for one's complement add, while there's no carry-around, but propagation into the link for the two's complement add.

This means the additional one's complement add is comparatively cheap: all you have to do is to add some additional carry propagation lines, and enable or disable some of those lines depending on which version of the add you do.

All the remaining complexity of the PDP-1, that is, adjust of -0 to +0 in ADD, SUB, MUL, DIV, IDX, ISP, is gone. (To be fair, most of those instructions are gone, too).

With this, we can speculate about the "why" (because unless someone can interview someone at DEC who was involved in this decision, we'll probably never know for sure): One major concern on the business side for every change is backwards compatibility. "But we do have lots of PDP-1 programs that use one's complement representation, will we be able to do that on the PDP-7?" "Don't worry, the PDP-7 has a one's complement add operation".

Of course, that ignores the fine detail that all the other concerns with one's complement like the two zero representations have now to be dealt with manually using more complicated skips, and requiring major effort when porting the programs. (But the business side, who makes the decision to buy a PDP-7, doesn't understand those details.)

So there you have it: A relatively cheap extension that can be a selling point to customers who are concerned about backward compatibility. (But as I wrote, all we can do is speculate).


To see some examples of real-world code, the PDP-7 Handbook recommends the following code snippets:

Two's complement of memory location Y:

LAC Y                                                                                                                                                                                     
CMA                                                                                                                                                                                       
DAC Y                                                                                                                                                                                     
ISZ Y                                                                                                                                                                                     
NOP                                                                                                                                                                                       

One's complement subtraction A - B:

LAC B                                                                                                                                                                                     
CMA                                                                                                                                                                                       
ADD A

Two's complement subtraction A - B (using constant):

ONE, 0001

LAC B
CMA
TAD ONE
TAD A

Note that the two's complement subtraction is more complex than the one's complement one (as the operate instruction doesn't include an increment, as e.g. on the PDP-8, though with the carry-propagation circuitry in place, it wouldn't have been hard to do).

I have not found a recommended "compare to -0 or +0", but I think you could do it (destructively) by shifting out the sign:

CLL RAL
SZA/SNA
...

Given that skips are executed before the rest of the operate instruction, I don't think it can be done in one instruction.

2

One's complement was essentially a NOT function, logical rather than arithmetic. Two's complement involved incrementing the AC, so that arithmetic was correct. One's complement stuff left you with two zeros, one having all zero bits, the other having all one bits, which required a pretty complex set of instructions to ascertain if you had a zero. Information International jiggered the PDP-9/PDP-15 into the III-15, which had a TCA (two's complement AC) instruction that was essentially CMA!IAC, which put paid to one's complement arithmetic on that machine. But you still needed on occasion to complement the AC, for logical operations.

2
  • Is TCA just an assembler shorthand for CMA IAC then?
    – OmarL
    Aug 11 at 7:34
  • 2
    The question is not about performing a one's complement; the question is about the complexity of the PDP-1's adjustments (adjust -0 to +0 in ADD, SUB, MUL, DIV, IDX, ISP), which was dropped in the PDP-7 etc., while keeping a one's complement add (ADD) with carry-around and a two's complement add (TAD) without carry-around.
    – dirkt
    Aug 13 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.