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: Mon, 12 Oct 2026 01:46:52 -0700 Organization: A noiseless patient Spider Lines: 28 Message-ID: <86qzhvi9vn.fsf@linuxsc.com> References: <10uks4f$1dqo$1@gal.iecc.com> <2026Oct3.191827@mips.complang.tuwien.ac.at> <119rmhv$c5k$1@gal.iecc.com> <865wzfm8ph.fsf@linuxsc.com> <11a3at4$17uu$1@gal.iecc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Mon, 12 Oct 2026 08:46:53 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3592157"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2XhEgV8PzhDdrlYrclqTyYUhe2/xQmyw="; posting-host="1f2789f15d316c232bd9e49999d71d7c" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:JV+NTdlz0ePraDqMLtKE8ivAoN0= sha1:kABK3iBhha8oPoGQapM0ePudPDU= sha256:gtpDljhrSJH74JepcVI+cyS7v3SHmRMjsakgVkvi0yE= sha1:NSQL+YnWNssQHTJRQqjM2RyuBS0= sha256:oLF1sHWU/VmkOzuIU0/YqyMVhDhXsAdnHQ423PD9fJM= Xref: csiph.com comp.arch:118554 John Levine writes: > According to Tim Rentsch : > >>> There's more but you get the idea. I still do not understand why >>> [the 704] 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). ... > > That's certainly one of the more common guesses people have made. > On the other hand, the TIX instruction adds its decrement field > to an index register, but since the decrement is the same size as > the index, if you want to count down you just make the decrement > two's comp -1. [...] Did you misread the description of the TIX instruction?