Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.arch
Subject: Re: two's complement and Flags (Re: arithmetic and endian history)
Date: Tue, 06 Oct 2026 03:20:26 -0700
Organization: A noiseless patient Spider
Lines: 81
Message-ID: <865wzfm8ph.fsf@linuxsc.com>
References: <10uks4f$1dqo$1@gal.iecc.com> <6abf7d77.41149906@news.eternal-september.org> <119ovig$15mk$2@gal.iecc.com> <2026Oct3.191827@mips.complang.tuwien.ac.at> <119rmhv$c5k$1@gal.iecc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 06 Oct 2026 10:20:27 +0000 (UTC)
Injection-Info: dont-email.me; logging-data="1888870"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WLAnZeSdL5kL0jrUbhf5OFuZlJiHs+LU="; posting-host="0b1fc18b52208379029243b7b311a32b"
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:EPV6W2+MdX9Y4cdeIJTkbrcTAAE= sha1:J5Fv62Orn4SRG63MKvZXVDGirQ4= sha256:AHM8jGtGsh/t7yT5ELygtpjoBjPatAY275uD3egsLSQ= sha1:i2qYK0pcLEriaMjbWL/oyOOw+bU= sha256:u4sTRNu1cis7e+7M+lIYCu7510lnhuTBrpQ+CrNoT1k=
Xref: csiph.com comp.arch:118494
John Levine writes:
> According to Anton Ertl :
>
>> John Levine writes:
>>
>>> Even though the 704's regualar arithmetic was sign-magnitude, its
>>> index arithmetic was two's complement subtraction. People
>>> certainly knew about two's complement, dunno why they stuck with
>>> one's comp so long.
>>
>> My current theory is that 2's complement was known as a technique
>> for subtracting unsigned numbers (and earlier using 10's complement
>> for mechanical computing machines), and that was used just for
>> unsigned numbers for quite a while on many computers, e.g., on the
>> IBM 704 or the PDP-4.
>
> That's not it, it it were just unsigned numbers, they'd have
> called it unsigned.
>
> The 704 reference manual in the introduction to the instruction
> set (p. 17) says this. They absolutely understood how two's
> complement worked:
>
> 4. The negative of a number is the number with
> its sign reversed.
>
> 5. The magnitude of a number is the number
> with its sign made positive (a 0 in position S
> corresponds to a positive sign).
>
> 6. The complement of a binary number is de-
> fined as the number derived by replacing all
> I's with O's and all O's with I's. Therefore, all
> binary bits are inverted to produce the com-
> plement of a number.
>
> 7. The 2's complement of a binary number is
> 1 plus the complement of the number.
>
> On page 10 where it talks about indexing, it says an
> instruction is:
>
> executed as if its address field had contained its stated
> address *minus* the contents of the specified index
> register.
>
> (minus in italics in the original)
>
> The description of the TSX subroutine call says
>
> This instruction places the 2's com-
> plement of the location of this instruction in the
> specified index register. The calculator takes the next
> instruction from location Y and proceeds from there.
> The 2's complement is used in this instruction be-
> cause indexing is a subtractive process on the 704
> and subtracting the 2's complement of a number is
> equivalent to adding the number.
>
> There's more but you get the idea. I still do not understand why
> they subtracted rather than adding the index registers, but they
> definitely did a two's complement subtraction.
I offer a possible (plausible?) explanation. The decision to use
subtraction was made in conjunction with how looping worked. If
we want to go through an array in ascending order, by basing
indexed accesses on the end of an array, effective addresses are
ascending while the index value is decreasing. Doing that lets
the end-of-loop test be a comparison against zero rather than a
comparison to some (non-zero) upper bound.
I think this proposed explanation is consistent with the example
given on page 10 (which doesn't talk about looping) and with the
description of the "Transfer on Index" instruction give on page 25
(which clearly is meant to be used with looping). The comparison
in the TIX instruction is not against zero but with a small known
constant, which would mean just a small (fixed) adjustment in the
accessing instructions.
Somewhat reminiscent of the AOBJN instruction on the PDP-10...