🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #549

Re: two's complement and Flags (Re: arithmetic and endian history)

#549
From: Anton Ertl
Date: Fri, 06 Nov 2026 06:24
41 lines
3045 bytes
John Levine <johnl@taugh.com> writes:
[PDP-4]
>They
>added two's complement arithmetic because the users wanted to do
>multiple precision and floating point arithmetic with more than 18
>bits which is a lot easier to do in two's complement. It also added a
>"link" bit to hold the carry out of the accumulator, and instructions
>to test it so you could do something like this for a two word addition
>
>  CLA A / low part
>  TAD B / carry is in the link bit
>  DAC C
>
>  CLA A+1 / high part
>  SZL / skip on zero link
>   IAC / add 1 to AC if there was a carry
>  TAD B+1
>  DAC C+1

That's good enough for double-precision integer arithmetic, but for
multiple-precision integers, an add with carry-in and carry-out is
needed.  The first sequence only does carry-out, the second only
carry-in; the second produces a carry, but it does not reflect a
possible carry-out of the IAC.

I am sure that one can do an addition with carry-in and carry-out on
the PDP-4, but the sequence is even longer than the five-instruction
sequence of MIPS, Alpha, and RISC-V.  This is an interesting contrast
to the 6502, where the only addition available is an addition with
carry-in and carry-out (likewise for subtraction), and if you do not
want the carry-in, you ensure that the carry-bit is clear before the
ADC instructon (e.g., with the CLC instruction).  If the main reason
for the TAD instruction in the PDP-4 is double-precision or
multiple-precision integer arithmetics, it probably would have been
better to go for a TADC (two's-complement addition with carry-in and
carry-out) instead.

- anton
-- 
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
  Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID: <2026Nov6.072410@mips.complang.tuwien.ac.at>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <10uks4f$1dqo$1@gal.iecc.com> <11cai8f$32ue7$1@dont-email.me> <11caljv$jeo$1@gal.iecc.com> <6ae8eec0.35320218@news.eternal-september.org> <11cjh58$1flq$4@gal.iecc.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: two's complement and Flags (Re: arithmetic and endian history)
Date: Fri, 06 Nov 2026 06:24:10 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 41
Message-ID: <2026Nov6.072410@mips.complang.tuwien.ac.at>
References: <10uks4f$1dqo$1@gal.iecc.com> <11cai8f$32ue7$1@dont-email.me> <11caljv$jeo$1@gal.iecc.com> <6ae8eec0.35320218@news.eternal-september.org> <11cjh58$1flq$4@gal.iecc.com>
Injection-Date: Fri, 06 Nov 2026 06:47:32 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2404209"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+SehT1C16aj4CLxOIeCmKz"; posting-host="bc90cb9d5a3c358a3a306caf3ca0415d"
Cancel-Lock: sha1:g37SWZXs5OmPp0+sbPuqSgD2+l0= sha256:fGJVgNEEYsvVwC0rQjbCvQpu27y/sFT6VYomL/e3H4Q=
	sha1:hQ1HXr6G7jLyZhP6YjHy4cbqr2Q= sha256:WW/OQ2b5qBrBOPdPcfLDvG+jUY8aSjXhW/36rRUGtZA=
X-newsreader: xrn 10.11