Thread View: comp.arch
52 messages
52 total messages
Page 1 of 2
Started by Stephen Fuld
Mon, 02 Nov 2026 17:45
Page 1 of 2 ⢠52 total messages
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Stephen Fuld
Date: Mon, 02 Nov 2026 17:45
Date: Mon, 02 Nov 2026 17:45
67 lines
4974 bytes
4974 bytes
On 10/3/2026 4:49 PM, MitchAlsup wrote: > > anton@mips.complang.tuwien.ac.at (Anton Ertl) posted: > >> John Levine <johnl@taugh.com> 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. >> >> The idea of interpreting numbers with set MSB as negative numbers by >> subtracting 2^n from their unsigned value, and relying on the >> properties of modular arithmetic to make this work with the same >> addition, subtraction, multiplication, and shift-left operations that >> were also used for unsigned arithmetic was apparently only becoming >> widespread in the early 1960s. It's not an obvious idea. >> >> Once that idea was widespread, people designed their new product lines >> with 2s-complement representation of signed numbers. >> >> However, ones-complement is not obvious, either. How did that become >> widespread? > > When an integer adder was spread over several plug in logic boards, > the end-around carry of 1s-complement was no hinderance to ADD perf > (as it became when the whole data path was in one die). > > 1s-complment had MUL & DIV 2^n for free, and symmetrical ± ranges. I remembered someone telling me that, in the technology of the day (individual transistors on plug in logic cards) that for the Univac 1107, ones complement was faster, but I couldn't find a reference for that. I was talking about this with another Univac "old timer", and he sent me a paper copy of a talk given at the 25th anniversary USE conference (the Univac user's group) titled "Why it is the way it is", by Ron Q Smith, then a long time and well respected Univac employee. It goes through the requirement by the military for 36 bit words, due to needing eight digits of floating point precision, rather than the 6 digits that 32 bits would provide and mentions that other computers of the day such as the IBM 7090 and 7094, GE systems and PDP 10 that used 36 bits. It then goes on to make an argument that I hadn't heard before. "Scientists and engineers demanded both precision and mathematical consistency." The result was both the 36 bit word and the use of mathematical representation that provided complete symmetry of positive and negative numbers. All of these machines used a numeric representation that had an equal number of positive and negative numbers and had both plus and minus zeros. These requirements are still present today in the form of the IEEE floating point standard. The IBM , GE and DEC machines used a signed-magnitude representation in which the sign bit was just that/ The Sperry Rand Univac systems used a ones-complement representation because it permitted faster addition and subtraction with less hardware. A complement cycle was not needed for most operations." Of course, the paper doesn't explain why the requirement for symmetry seemed to go away and two's complement became acceptable. -- - Stephen Fuld (e-mail address disguised to prevent spam)
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Stephen Fuld
Date: Mon, 02 Nov 2026 18:12
Date: Mon, 02 Nov 2026 18:12
49 lines
3812 bytes
3812 bytes
On 11/2/2026 9:45 AM, Stephen Fuld wrote: > On 10/3/2026 4:49 PM, MitchAlsup wrote: >> >> anton@mips.complang.tuwien.ac.at (Anton Ertl) posted: >> >>> John Levine <johnl@taugh.com> 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. >>> >>> The idea of interpreting numbers with set MSB as negative numbers by >>> subtracting 2^n from their unsigned value, and relying on the >>> properties of modular arithmetic to make this work with the same >>> addition, subtraction, multiplication, and shift-left operations that >>> were also used for unsigned arithmetic was apparently only becoming >>> widespread in the early 1960s. It's not an obvious idea. >>> >>> Once that idea was widespread, people designed their new product lines >>> with 2s-complement representation of signed numbers. >>> >>> However, ones-complement is not obvious, either. How did that become >>> widespread? >> >> When an integer adder was spread over several plug in logic boards, >> the end-around carry of 1s-complement was no hinderance to ADD perf >> (as it became when the whole data path was in one die). >> >> 1s-complment had MUL & DIV 2^n for free, and symmetrical ± ranges. > I remembered someone telling me that, in the technology of the day > (individual transistors on plug in logic cards) that for the Univac > 1107, ones complement was faster, but I couldn't find a reference for > that. I was talking about this with another Univac "old timer", and he > sent me a paper copy of a talk given at the 25th anniversary USE > conference (the Univac user's group) Again, I apologize for the self follow-up, but it was the 35th (not 25th) anniversary conference Nov 5-9 1990. -- - Stephen Fuld (e-mail address disguised to prevent spam)
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Levine
Date: Mon, 02 Nov 2026 18:43
Date: Mon, 02 Nov 2026 18:43
32 lines
2955 bytes
2955 bytes
According to Stephen Fuld <sfuld@alumni.cmu.edu.invalid>: >"Scientists and engineers demanded both precision and mathematical >consistency." The result was both the 36 bit word and the use of >mathematical representation that provided complete symmetry of positive >and negative numbers. All of these machines used a numeric >representation that had an equal number of positive and negative numbers >and had both plus and minus zeros. These requirements are still present >today in the form of the IEEE floating point standard. The IBM , GE and >DEC machines used a signed-magnitude representation in which the sign >bit was just that/ The Sperry Rand Univac systems used a >ones-complement representation because it permitted faster addition and >subtraction with less hardware. A complement cycle was not needed for >most operations." The DEC PDP-10 had two's complement floating point but otherwise yes. That last sentence is true compared to sign-magnitude but it did need end-around carry. >Of course, the paper doesn't explain why the requirement for symmetry >seemed to go away and two's complement became acceptable. IEEE floating point is still sign-magnitude since among other things that enables the hidden bit so you get more precision almost for free. My guess is that for fixed point arithmetic, experience told people that having to account for two versions of zero was a pain, while the fact that the largest negative number had no positive representation didn't matter. -- Regards, John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Anton Ertl
Date: Mon, 02 Nov 2026 19:14
Date: Mon, 02 Nov 2026 19:14
44 lines
3610 bytes
3610 bytes
Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes: >a talk given at the 25th anniversary USE >conference (the Univac user's group) titled "Why it is the way it is", >by Ron Q Smith, then a long time and well respected Univac employee. It >goes through the requirement by the military for 36 bit words, due to >needing eight digits of floating point precision, rather than the 6 >digits that 32 bits would provide The story I have read is that the requirement was 10 digits of fixed-point numbers, although 34 bits plus sign bit would have been enough for that. That is supported by the fact that the IBM 701 has 36-bit words, but no floating-point. Also, von Neumann was an advocate agains floating point, and I expect that he had quite a bit of influence on such requirements at the time. >"Scientists and engineers demanded both precision and mathematical >consistency." The result was both the 36 bit word and the use of >mathematical representation that provided complete symmetry of positive >and negative numbers. All of these machines used a numeric >representation that had an equal number of positive and negative numbers >and had both plus and minus zeros. One interesting aspect is that the more mathematical types usually prefer floored or Euclidean division over symmetric (aka truncated) division, especially when it comes to the remainder that comes with it. See <https://en.wikipedia.org/wiki/Modulo_operation>. But there may be exceptions that prove the rule. But if the US military specified symmetry in their requirements in the 1950s, that would explain why the US computers went for sign-magnitude or ones-complement during that time, while the british computers were already using twos-complement. >Of course, the paper doesn't explain why the requirement for symmetry >seemed to go away and two's complement became acceptable. The usual way, probably: by promotion, retirement, or death of the person who wrote this requirement. I don't know if it was von Neumann, but he died in 1957. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: MitchAlsup
Date: Mon, 02 Nov 2026 20:00
Date: Mon, 02 Nov 2026 20:00
36 lines
2752 bytes
2752 bytes
John Levine <johnl@taugh.com> posted:
> According to Stephen Fuld <sfuld@alumni.cmu.edu.invalid>:
> >"Scientists and engineers demanded both precision and mathematical
> >consistency." The result was both the 36 bit word and the use of
> >mathematical representation that provided complete symmetry of positive
> >and negative numbers. All of these machines used a numeric
> >representation that had an equal number of positive and negative numbers
> >and had both plus and minus zeros. These requirements are still present
> >today in the form of the IEEE floating point standard. The IBM , GE and
> >DEC machines used a signed-magnitude representation in which the sign
> >bit was just that/ The Sperry Rand Univac systems used a
> >ones-complement representation because it permitted faster addition and
> >subtraction with less hardware. A complement cycle was not needed for
> >most operations."
>
> The DEC PDP-10 had two's complement floating point but otherwise yes.
> That last sentence is true compared to sign-magnitude but it did need
> end-around carry.
>
> >Of course, the paper doesn't explain why the requirement for symmetry
> >seemed to go away and two's complement became acceptable.
>
> IEEE floating point is still sign-magnitude since among other things that
> enables the hidden bit so you get more precision almost for free.
>
> My guess is that for fixed point arithmetic, experience told people
> that having to account for two versions of zero was a pain, while the
> fact that the largest negative number had no positive representation
> didn't matter.
But is does matter:: when i == NEGMAX:: i == -i ?!?!?
In what kind of arithmetic world does -i == i ???
{maybe not enough though}
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Savard
Date: Mon, 02 Nov 2026 20:25
Date: Mon, 02 Nov 2026 20:25
61 lines
4034 bytes
4034 bytes
On Mon, 2 Nov 2026 18:43:11 -0000 (UTC), John Levine <johnl@taugh.com> wrote: >According to Stephen Fuld <sfuld@alumni.cmu.edu.invalid>: >>Of course, the paper doesn't explain why the requirement for symmetry >>seemed to go away and two's complement became acceptable. >My guess is that for fixed point arithmetic, experience told people >that having to account for two versions of zero was a pain, while the >fact that the largest negative number had no positive representation >didn't matter. I think that's certainly _part_ of it. DEC made the LINC, which was a one's complement machine... or, rather, it made kits with which researchers could make their own LINC computers. Later on, they made the PDP-5, largely for process control, which was two's complement. Later, this caused some extra complexity when they made the LINC-8 and its successor the PDP-12, which combined their PDP-8 (almost compatible with the PDP-5) and the LINC in one box. They also made an 18-bit computer, the PDP-4 (which had compatible successors in the PDP-9 and PDP-15) which had a set of one's complement instructions and an additional set of two's complement instructions. I guess that let those machines act as bridges between hardware which was either one way or the other. That case illustrates what a mess this was for a while. Most other makers chose to go either one way or the other. IBM went with sign-magnitude on the IBM 704 and its successors. Although the index registers, which presumably didn't matter as much, were two's complement. The IBM System/360, though, was sign-magnitude for floating point (like nearly everyone else) but two's complement for binary integers. (Decimal integers were sign-magnitude still.) In my opinion, it was the decision by IBM to make the switch which legitimized sign-magnitude. Just as DEC switched from making 18-bit, 36-bit, and 12-bit computers to the 16-bit PDP-11 after the System/360 (and the PDP-11 also had general registers) IBM, being the biggest computer company, was hugely influential. People designing computers tended to copy whatever IBM did. After the IBM 704, computers from a whole bunch of manufacturers looked like the IBM 704 in many ways. Some of those ways aren't just IBM influence; using six-bit characters because only upper-case printing was needed for a computer was just a result of the technology of the day. As costs came down, and as IBM went to the eight-bit byte mostly because packed decimal four-bit digits fit in it efficiently, people started considering letting computers use lower-case. So once IBM used two's complement, and the roof didn't fall in, people woke up and realized that one's complement was a waste of time. John Savard
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Savard
Date: Mon, 02 Nov 2026 20:28
Date: Mon, 02 Nov 2026 20:28
15 lines
1901 bytes
1901 bytes
On Mon, 02 Nov 2026 20:00:28 GMT, MitchAlsup <user5857@newsgrouper.org.invalid> wrote: >In what kind of arithmetic world does -i == i ??? Unless i=0, -i never equals i, that's true. On the other hand, if you use that letter in it's usual meaning as a constant, while i doesn't _equal_ -i, i is _isomorphic_ to -i... and to j, -j, k, and -k, if you want to include Hamilton's quaternions. Except for some specific functions that explicitly use i in their definitions, just about everything in mathematics would be the same if you consistently swapped i and -i everywhere they were used. John Savard
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Savard
Date: Mon, 02 Nov 2026 20:37
Date: Mon, 02 Nov 2026 20:37
31 lines
2889 bytes
2889 bytes
On Mon, 02 Nov 2026 19:14:49 GMT, anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: >The story I have read is that the requirement was 10 digits of >fixed-point numbers, although 34 bits plus sign bit would have been >enough for that. That is supported by the fact that the IBM 701 has >36-bit words, but no floating-point. The IBM 701 could do 36-bit arithmetic, but it was an 18-bit machine. >Also, von Neumann was an >advocate agains floating point, and I expect that he had quite a bit >of influence on such requirements at the time. Hardware floating-point required quite a few logic gates to implement. So recommending that programmers work a little harder instead of the computer trying to do their work for them... made perfect sense back then, when computers were made out of *vacuum tubes*. Later, IBM made the IBM 704, which was much larger and more complex than the IBM 701. It had core memory instead of Williams tubes - both forms of memory were genuinely random-access, but core memory was much more reliable. It also had hardware floating-point; this was a bold move at the time, but it turned out to contribute to the machine's success. And, of course, the IBM 704 was also the machine for which the first FORTRAN compiler was written. FORTRAN wasn't the first higher-level language, but because its compiler performed optimization, it overcame a lot of the previous opposition to higher-level languages as wasteful. John Savard
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: MitchAlsup
Date: Tue, 03 Nov 2026 01:34
Date: Tue, 03 Nov 2026 01:34
29 lines
1945 bytes
1945 bytes
quadibloc@invalid.com (John Savard) posted: > On Mon, 02 Nov 2026 20:00:28 GMT, MitchAlsup > <user5857@newsgrouper.org.invalid> wrote: > > >In what kind of arithmetic world does -i == i ??? > > Unless i=0, -i never equals i, that's true. > > On the other hand, if you use that letter in it's usual meaning as a > constant, while i doesn't _equal_ -i, i is _isomorphic_ to -i... and > to j, -j, k, and -k, if you want to include Hamilton's quaternions. I is just an integer. signed char i = 0xFF; signed char j = -i; if( i == j ) // WTF NEGMAX == -NEGMAX in 2-s complement. I submit this is a lot stranger than having 2 zeros. > Except for some specific functions that explicitly use i in their > definitions, just about everything in mathematics would be the same if > you consistently swapped i and -i everywhere they were used. > > John Savard
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: MitchAlsup
Date: Tue, 03 Nov 2026 01:36
Date: Tue, 03 Nov 2026 01:36
36 lines
2862 bytes
2862 bytes
quadibloc@invalid.com (John Savard) posted: > On Mon, 02 Nov 2026 19:14:49 GMT, anton@mips.complang.tuwien.ac.at > (Anton Ertl) wrote: > > >The story I have read is that the requirement was 10 digits of > >fixed-point numbers, although 34 bits plus sign bit would have been > >enough for that. That is supported by the fact that the IBM 701 has > >36-bit words, but no floating-point. > > The IBM 701 could do 36-bit arithmetic, but it was an 18-bit machine. PDP-8 could do floating point arithmetic but had no FP instructions nor FP registers. > >Also, von Neumann was an > >advocate agains floating point, and I expect that he had quite a bit > >of influence on such requirements at the time. > > Hardware floating-point required quite a few logic gates to implement. > So recommending that programmers work a little harder instead of the > computer trying to do their work for them... made perfect sense back > then, when computers were made out of *vacuum tubes*. > > Later, IBM made the IBM 704, which was much larger and more complex > than the IBM 701. It had core memory instead of Williams tubes - both > forms of memory were genuinely random-access, but core memory was much > more reliable. It also had hardware floating-point; this was a bold > move at the time, but it turned out to contribute to the machine's > success. And, of course, the IBM 704 was also the machine for which > the first FORTRAN compiler was written. FORTRAN wasn't the first > higher-level language, but because its compiler performed > optimization, it overcame a lot of the previous opposition to > higher-level languages as wasteful. > > John Savard
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Lawrence DāOliveiro
Date: Tue, 03 Nov 2026 02:39
Date: Tue, 03 Nov 2026 02:39
12 lines
2014 bytes
2014 bytes
On Mon, 2 Nov 2026 09:45:51 -0800, Stephen Fuld wrote: > "Scientists and engineers demanded both precision and mathematical > consistency." The result was both the 36 bit word and the use of > mathematical representation that provided complete symmetry of > positive and negative numbers. ..." > > Of course, the paper doesn't explain why the requirement for > symmetry seemed to go away and two's complement became acceptable. The scientists and engineers didnāt care so much about integers, they would have been mainly concerned with floats.
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Thomas Koenig
Date: Tue, 03 Nov 2026 06:59
Date: Tue, 03 Nov 2026 06:59
37 lines
3011 bytes
3011 bytes
John Savard <quadibloc@invalid.com> schrieb: > On Mon, 02 Nov 2026 19:14:49 GMT, anton@mips.complang.tuwien.ac.at > (Anton Ertl) wrote: > >>The story I have read is that the requirement was 10 digits of >>fixed-point numbers, although 34 bits plus sign bit would have been >>enough for that. That is supported by the fact that the IBM 701 has >>36-bit words, but no floating-point. > > The IBM 701 could do 36-bit arithmetic, but it was an 18-bit machine. > >>Also, von Neumann was an >>advocate agains floating point, and I expect that he had quite a bit >>of influence on such requirements at the time. Von Neumann was also opposed to assemblers, he considered them a waste of valuable computer time, and wanted people to program in machine code. > Hardware floating-point required quite a few logic gates to implement. > So recommending that programmers work a little harder instead of the > computer trying to do their work for them... made perfect sense back > then, when computers were made out of *vacuum tubes*. Not really. Before FORTRAN, Backus implemented "Speedcoding", which was an interpeter for a sort of assembly language which did floating point. Despite its name, it was very slow, but the savings in overall time often made the total time to solution faster, and it was apparently pleasant enough to use so people did it. -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: David Brown
Date: Tue, 03 Nov 2026 07:35
Date: Tue, 03 Nov 2026 07:35
48 lines
3168 bytes
3168 bytes
On 03/11/2026 02:34, MitchAlsup wrote: > quadibloc@invalid.com (John Savard) posted: > >> On Mon, 02 Nov 2026 20:00:28 GMT, MitchAlsup >> <user5857@newsgrouper.org.invalid> wrote: >> >>> In what kind of arithmetic world does -i == i ??? >> >> Unless i=0, -i never equals i, that's true. >> >> On the other hand, if you use that letter in it's usual meaning as a >> constant, while i doesn't _equal_ -i, i is _isomorphic_ to -i... and >> to j, -j, k, and -k, if you want to include Hamilton's quaternions. > > I is just an integer. > > signed char i = 0xFF; It is better to write "int8_t i = 0xff;" here, since you are talking about a signed 8-bit integer, not whatever "char" might be on a particular system. And you mean "int8_t i = 0x80;" anyway. 0xff is -1 on an 8-bit two's complement machine - and then its negative is 1. > signed char j = -i; > > if( i == j ) // WTF > > NEGMAX == -NEGMAX in 2-s complement. > > I submit this is a lot stranger than having 2 zeros. > And that is why signed integer overflow is undefined behaviour in C. When you have overflows, there are no correct answers - no answers that make mathematical sense. Once you say that signed integer overflow is UB, and your code does not execute UB (or does not care what happens if it does), then signed integer types in C obey nice mathematical laws like "-i != i" except for when "i" is 0, and "a + b > a" if "b > 0". Two's complement wrapping is wonderful for tasks such as implementing multi-word arithmetic, and for efficient hardware implementations - but not at a higher level.
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Scott Lurndal
Date: Tue, 03 Nov 2026 15:09
Date: Tue, 03 Nov 2026 15:09
20 lines
1967 bytes
1967 bytes
MitchAlsup <user5857@newsgrouper.org.invalid> writes: >quadibloc@invalid.com (John Savard) posted: > >> On Mon, 02 Nov 2026 19:14:49 GMT, anton@mips.complang.tuwien.ac.at >> (Anton Ertl) wrote: >> >> >The story I have read is that the requirement was 10 digits of >> >fixed-point numbers, although 34 bits plus sign bit would have been >> >enough for that. That is supported by the fact that the IBM 701 has >> >36-bit words, but no floating-point. >> >> The IBM 701 could do 36-bit arithmetic, but it was an 18-bit machine. > >PDP-8 could do floating point arithmetic but had no FP instructions >nor FP registers. And the multiplication/division (EAE) unit was optional, yet the PDP-8 could do division and multiplication even without the unit.
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Waldek Hebisch
Date: Wed, 04 Nov 2026 03:01
Date: Wed, 04 Nov 2026 03:01
43 lines
3166 bytes
3166 bytes
Thomas Koenig <tkoenig@netcologne.de> wrote:
> John Savard <quadibloc@invalid.com> schrieb:
>> On Mon, 02 Nov 2026 19:14:49 GMT, anton@mips.complang.tuwien.ac.at
>> (Anton Ertl) wrote:
>>
>>>The story I have read is that the requirement was 10 digits of
>>>fixed-point numbers, although 34 bits plus sign bit would have been
>>>enough for that. That is supported by the fact that the IBM 701 has
>>>36-bit words, but no floating-point.
>>
>> The IBM 701 could do 36-bit arithmetic, but it was an 18-bit machine.
>>
>>>Also, von Neumann was an
>>>advocate agains floating point, and I expect that he had quite a bit
>>>of influence on such requirements at the time.
>
> Von Neumann was also opposed to assemblers, he considered them a
> waste of valuable computer time, and wanted people to program in
> machine code.
>
>> Hardware floating-point required quite a few logic gates to implement.
>> So recommending that programmers work a little harder instead of the
>> computer trying to do their work for them... made perfect sense back
>> then, when computers were made out of *vacuum tubes*.
>
> Not really.
>
> Before FORTRAN, Backus implemented "Speedcoding", which was an
> interpeter for a sort of assembly language which did floating point.
>
> Despite its name, it was very slow, but the savings in overall time
> often made the total time to solution faster, and it was apparently
> pleasant enough to use so people did it.
IIUC big motivation for FORTRAN was hardware floating point.
Namely, with software floating point actual arithmetic dominated
run time and overhead of interpretation was acceptable. But
with hardware floating point arithmetic was faster and relative
role of overhead was much larger. That is why FORTRAN team
worked hard to produce efficient code.
--
Waldek Hebisch
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Levine
Date: Wed, 04 Nov 2026 03:36
Date: Wed, 04 Nov 2026 03:36
25 lines
2647 bytes
2647 bytes
According to Waldek Hebisch <antispam@fricas.org>: >IIUC big motivation for FORTRAN was hardware floating point. >Namely, with software floating point actual arithmetic dominated >run time and overhead of interpretation was acceptable. But >with hardware floating point arithmetic was faster and relative >role of overhead was much larger. That is why FORTRAN team >worked hard to produce efficient code. At that time there was a widespread belief that compilers could never generate code as good as human programmers did, so if performance were important, which on the computers of that era it always was, you'd never use a compiler to write your code. But FORTRAN producd code which even by modern standards was very good, and got grudging respect after a few years. People also realized that for programs you were only going to run a few times, the time savings from writing and debugging FORTRAN rather than the much larger assembler equivalent often meant that the actual computer time used for debugging and final production runs was still less even if the code wasn't that great. At some point they added a flag to produce less optimized code but compile faster, and everyone used it. -- Regards, John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Thomas Koenig
Date: Wed, 04 Nov 2026 18:06
Date: Wed, 04 Nov 2026 18:06
51 lines
4047 bytes
4047 bytes
Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: > I remembered someone telling me that, in the technology of the day > (individual transistors on plug in logic cards) that for the Univac > 1107, ones complement was faster, but I couldn't find a reference for > that. I have also read the claim, but I think it bogus. An end-around-carry takes time. That may not matter when your adder is made of vacuum tubes and your memory is made of cores, which are much slower, so you have time for two ripple-carry round trips in one cycle. This, I believe, was the case for the IBM 704 (I found literature for the 701). A couple of decades later: I found a mention on Wikipedia that the SuperNova SC, which ran at semiconductor memory speeds, was the fastest mini for some time. The adders must have been fast enough. >I was talking about this with another Univac "old timer", and he > sent me a paper copy of a talk given at the 25th anniversary USE > conference (the Univac user's group) titled "Why it is the way it is", > by Ron Q Smith, then a long time and well respected Univac employee. It > goes through the requirement by the military for 36 bit words, due to > needing eight digits of floating point precision, rather than the 6 > digits that 32 bits would provide and mentions that other computers of > the day such as the IBM 7090 and 7094, GE systems and PDP 10 that used > 36 bits. It then goes on to make an argument that I hadn't heard before. > > "Scientists and engineers demanded both precision and mathematical > consistency." The result was both the 36 bit word and the use of > mathematical representation that provided complete symmetry of positive > and negative numbers. All of these machines used a numeric > representation that had an equal number of positive and negative numbers > and had both plus and minus zeros. These requirements are still present > today in the form of the IEEE floating point standard. The IBM , GE and > DEC machines used a signed-magnitude representation in which the sign > bit was just that/ The Sperry Rand Univac systems used a > ones-complement representation because it permitted faster addition and > subtraction with less hardware. A complement cycle was not needed for > most operations." > > Of course, the paper doesn't explain why the requirement for symmetry > seemed to go away and two's complement became acceptable. The IBM 704 compared -0 as smaller than +0... -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Levine
Date: Wed, 04 Nov 2026 18:20
Date: Wed, 04 Nov 2026 18:20
17 lines
1999 bytes
1999 bytes
According to Thomas Koenig <tkoenig@netcologne.de>: >> Of course, the paper doesn't explain why the requirement for symmetry >> seemed to go away and two's complement became acceptable. > >The IBM 704 compared -0 as smaller than +0... Te CAS compared the AC to storage and skipped 0, 1, or 2, instructions if the storage was less, equal, or greater than the AC, and it says +0 was greater than -0. On the other hand, if you subtracted and then did a TZE or TNZ transfer on zero/nonzero instruction it ignored the sign. I have not looked at enough 70x code to know what programmers really did. -- Regards, John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: MitchAlsup
Date: Wed, 04 Nov 2026 21:53
Date: Wed, 04 Nov 2026 21:53
70 lines
4657 bytes
4657 bytes
Thomas Koenig <tkoenig@netcologne.de> posted:
> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>
> > I remembered someone telling me that, in the technology of the day
> > (individual transistors on plug in logic cards) that for the Univac
> > 1107, ones complement was faster, but I couldn't find a reference for
> > that.
>
> I have also read the claim, but I think it bogus. An end-around-carry
> takes time.
The gate delay count of 1s-complement and 2s-complement are identical.
It was only when the end-around carry came out of the data-path at the
top and went in at the bottom that 1s-complement was seen to be slower
than 2s-complement. With "a couple of bits per logic board" and the
ability to place the boards anywhere <within reason> end-around-carry
was no slower than 2s-complement. So, prior to VLSI, the 2 adders were
essentially identical in gate count, speed, and power.
> That may not matter when your adder is made of vacuum tubes and
> your memory is made of cores, which are much slower, so you have
> time for two ripple-carry round trips in one cycle.
Literally, the gate-count and gate-delay latency are identical.
> This, I believe,
> was the case for the IBM 704 (I found literature for the 701).
>
> A couple of decades later: I found a mention on Wikipedia that the
> SuperNova SC, which ran at semiconductor memory speeds, was the
> fastest mini for some time. The adders must have been fast enough.
>
> >I was talking about this with another Univac "old timer", and he
> > sent me a paper copy of a talk given at the 25th anniversary USE
> > conference (the Univac user's group) titled "Why it is the way it is",
> > by Ron Q Smith, then a long time and well respected Univac employee. It
> > goes through the requirement by the military for 36 bit words, due to
> > needing eight digits of floating point precision, rather than the 6
> > digits that 32 bits would provide
4-bits is only 1.3 decimal digits--not 2.0
> and mentions that other computers of
> > the day such as the IBM 7090 and 7094, GE systems and PDP 10 that used
> > 36 bits. It then goes on to make an argument that I hadn't heard before.
> >
> > "Scientists and engineers demanded both precision and mathematical
> > consistency." The result was both the 36 bit word and the use of
> > mathematical representation that provided complete symmetry of positive
> > and negative numbers. All of these machines used a numeric
> > representation that had an equal number of positive and negative numbers
> > and had both plus and minus zeros. These requirements are still present
> > today in the form of the IEEE floating point standard. The IBM , GE and
> > DEC machines used a signed-magnitude representation in which the sign
> > bit was just that/ The Sperry Rand Univac systems used a
> > ones-complement representation because it permitted faster addition and
> > subtraction with less hardware. A complement cycle was not needed for
> > most operations."
For the record, S.E.L machines {32/65, 32/67, and 32/87} all used 2s-
complement FP in <otherwise> IBM Hex exponent and normalization.
> > Of course, the paper doesn't explain why the requirement for symmetry
> > seemed to go away and two's complement became acceptable.
>
> The IBM 704 compared -0 as smaller than +0...
So, does IEEE total_order( -0, +0 );
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Terje Mathisen
Date: Wed, 04 Nov 2026 22:08
Date: Wed, 04 Nov 2026 22:08
85 lines
5672 bytes
5672 bytes
MitchAlsup wrote:
> Thomas Koenig <tkoenig@netcologne.de> posted:
>
>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
>>
>>> I remembered someone telling me that, in the technology of the day
>>> (individual transistors on plug in logic cards) that for the Univac
>>> 1107, ones complement was faster, but I couldn't find a reference for
>>> that.
>>
>> I have also read the claim, but I think it bogus. An end-around-carry
>> takes time.
>
> The gate delay count of 1s-complement and 2s-complement are identical.
>
> It was only when the end-around carry came out of the data-path at the
> top and went in at the bottom that 1s-complement was seen to be slower
> than 2s-complement. With "a couple of bits per logic board" and the
> ability to place the boards anywhere <within reason> end-around-carry
> was no slower than 2s-complement. So, prior to VLSI, the 2 adders were
> essentially identical in gate count, speed, and power.
>
>> That may not matter when your adder is made of vacuum tubes and
>> your memory is made of cores, which are much slower, so you have
>> time for two ripple-carry round trips in one cycle.
>
> Literally, the gate-count and gate-delay latency are identical.
>
>> This, I believe,
>> was the case for the IBM 704 (I found literature for the 701).
>>
>> A couple of decades later: I found a mention on Wikipedia that the
>> SuperNova SC, which ran at semiconductor memory speeds, was the
>> fastest mini for some time. The adders must have been fast enough.
>>
>>> I was talking about this with another Univac "old timer", and he
>>> sent me a paper copy of a talk given at the 25th anniversary USE
>>> conference (the Univac user's group) titled "Why it is the way it is",
>>> by Ron Q Smith, then a long time and well respected Univac employee. It
>>> goes through the requirement by the military for 36 bit words, due to
>>> needing eight digits of floating point precision, rather than the 6
>>> digits that 32 bits would provide
>
> 4-bits is only 1.3 decimal digits--not 2.0
>
>> and mentions that other computers of
>>> the day such as the IBM 7090 and 7094, GE systems and PDP 10 that used
>>> 36 bits. It then goes on to make an argument that I hadn't heard before.
>>>
>>> "Scientists and engineers demanded both precision and mathematical
>>> consistency." The result was both the 36 bit word and the use of
>>> mathematical representation that provided complete symmetry of positive
>>> and negative numbers. All of these machines used a numeric
>>> representation that had an equal number of positive and negative numbers
>>> and had both plus and minus zeros. These requirements are still present
>>> today in the form of the IEEE floating point standard. The IBM , GE and
>>> DEC machines used a signed-magnitude representation in which the sign
>>> bit was just that/ The Sperry Rand Univac systems used a
>>> ones-complement representation because it permitted faster addition and
>>> subtraction with less hardware. A complement cycle was not needed for
>>> most operations."
>
> For the record, S.E.L machines {32/65, 32/67, and 32/87} all used 2s-
> complement FP in <otherwise> IBM Hex exponent and normalization.
>
>>> Of course, the paper doesn't explain why the requirement for symmetry
>>> seemed to go away and two's complement became acceptable.
>>
>> The IBM 704 compared -0 as smaller than +0...
>
> So, does IEEE total_order( -0, +0 );
>
That is in fact a key part of ieee754, that all numbers from -Inf to
+Inf can be ordered like that, using a comparator which is very similar
to an integer compare.
NaNs do not have a sign, but a NaN with a sign bit will order below
-Inf, just like you step from +Inf into the unsigned NaN range.
Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Stephen Fuld
Date: Thu, 05 Nov 2026 16:14
Date: Thu, 05 Nov 2026 16:14
54 lines
4062 bytes
4062 bytes
On 11/4/2026 1:53 PM, MitchAlsup wrote: > Thomas Koenig <tkoenig@netcologne.de> posted: > >> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb: >> >>> I remembered someone telling me that, in the technology of the day >>> (individual transistors on plug in logic cards) that for the Univac >>> 1107, ones complement was faster, but I couldn't find a reference for >>> that. >> >> I have also read the claim, but I think it bogus. An end-around-carry >> takes time. > > The gate delay count of 1s-complement and 2s-complement are identical. > > It was only when the end-around carry came out of the data-path at the > top and went in at the bottom that 1s-complement was seen to be slower > than 2s-complement. With "a couple of bits per logic board" and the > ability to place the boards anywhere <within reason> end-around-carry > was no slower than 2s-complement. So, prior to VLSI, the 2 adders were > essentially identical in gate count, speed, and power. > >> That may not matter when your adder is made of vacuum tubes and >> your memory is made of cores, which are much slower, so you have >> time for two ripple-carry round trips in one cycle. > > Literally, the gate-count and gate-delay latency are identical. > >> This, I believe, >> was the case for the IBM 704 (I found literature for the 701). >> >> A couple of decades later: I found a mention on Wikipedia that the >> SuperNova SC, which ran at semiconductor memory speeds, was the >> fastest mini for some time. The adders must have been fast enough. >> >>> I was talking about this with another Univac "old timer", and he >>> sent me a paper copy of a talk given at the 25th anniversary USE >>> conference (the Univac user's group) titled "Why it is the way it is", >>> by Ron Q Smith, then a long time and well respected Univac employee. It >>> goes through the requirement by the military for 36 bit words, due to >>> needing eight digits of floating point precision, rather than the 6 >>> digits that 32 bits would provide > > 4-bits is only 1.3 decimal digits--not 2.0 Yes. It looks like the paper erred in that 32 bits, with its 24 bits of mantissa provides seven digits of precision, not six. But Univac's 36 bit single precision, with its 27 bits of mantissa does provide eight digits of precision. -- - Stephen Fuld (e-mail address disguised to prevent spam)
Re: bad floating point, two's complement and Flags (Re: arithmetic and endian history)
Author: John Levine
Date: Thu, 05 Nov 2026 17:26
Date: Thu, 05 Nov 2026 17:26
22 lines
2336 bytes
2336 bytes
According to Stephen Fuld <sfuld@alumni.cmu.edu.invalid>: >> 4-bits is only 1.3 decimal digits--not 2.0 > >Yes. It looks like the paper erred in that 32 bits, with its 24 bits of >mantissa provides seven digits of precision, not six. But Univac's 36 >bit single precision, with its 27 bits of mantissa does provide eight >digits of precision. Depends whose 32 bit floating point. The design mistakes in the 360's hex floating point lost three bits of precision on each operation relative to a well designed 32 but format, so 6 seems about right. To review: they wrongly assumed that leading digits are uniformly distributed while in fact they're geometrically distributed, so the leading hex digit on average has two leading zeros rather than the 1 they estimated. Also they truncated rather than rounding, losing another bit. And hex can't do the binary hidden bit trick, losing the third bit. -- Regards, John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Savard
Date: Thu, 05 Nov 2026 23:36
Date: Thu, 05 Nov 2026 23:36
14 lines
1893 bytes
1893 bytes
On Mon, 02 Nov 2026 20:25:11 GMT, quadibloc@invalid.com (John Savard) wrote: >They also made an 18-bit computer, the PDP-4 (which had compatible >successors in the PDP-9 and PDP-15) which had a set of one's >complement instructions and an additional set of two's complement >instructions. I guess that let those machines act as bridges between >hardware which was either one way or the other. Their earlier 18-bit machine, the PDP-1, despite having a five-bit opcode field (unlike the four-bit opcode field of the PDP-4 and its successors) was one's complement only. John Savard
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Levine
Date: Fri, 06 Nov 2026 03:22
Date: Fri, 06 Nov 2026 03:22
31 lines
2503 bytes
2503 bytes
According to John Savard <quadibloc@invalid.com>: >They also made an 18-bit computer, the PDP-4 (which had compatible >successors in the PDP-9 and PDP-15) which had a set of one's >complement instructions and an additional set of two's complement >instructions. I guess that let those machines act as bridges between >hardware which was either one way or the other. The DEC Computer Engineering book says that the PDP-4 was designd to be a lower cost PDP-1, 5/8 of the performance for half the cost. 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 The PDP-5 and -8 also had a link bit. -- Regards, John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Anton Ertl
Date: Fri, 06 Nov 2026 06:24
Date: Fri, 06 Nov 2026 06:24
41 lines
3045 bytes
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>
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Terje Mathisen
Date: Fri, 06 Nov 2026 11:08
Date: Fri, 06 Nov 2026 11:08
57 lines
3908 bytes
3908 bytes
Anton Ertl wrote: > 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. On Alpha you needed to play tricks with predicated instructions, afair you had two forms of ADD, one that just added two registers and one that did the same plus an extra increment which represented an incoming carry. Even on x86/x64 you get into similar situations when you need to add multiple parts together, it is easy to get stuck with long manual carry chains. Possibly the best primitive is MAA (Mul Add Add) representing (sumlo, sumhi) = muladdadd(f1, f2, a1, a2); since this can never overflow the two-element result? Terje -- - <Terje.Mathisen at tmsw.no> "almost all programming can be viewed as an exercise in caching"
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Anton Ertl
Date: Fri, 06 Nov 2026 15:08
Date: Fri, 06 Nov 2026 15:08
102 lines
5109 bytes
5109 bytes
Terje Mathisen <terje.mathisen@tmsw.no> writes: [add with carry-in and carry-out] >On Alpha you needed to play tricks with predicated instructions, afair >you had two forms of ADD, one that just added two registers and one that >did the same plus an extra increment which represented an incoming carry. No, Alpha is just like MIPS and RISC-V. For RISC-V: add tmp1, carry, summand1 sltu carry1, tmp1, summand1 add sum, tmp1, summand2 sltu carry2, sum, tmp1 add carry, carry2, carry1 Alpha has no predicated instructions apart from a conditional move and no addition with an extra increment. What you describe reminds me of IA-64; it certeinly selects between a+b and a+b+1 with predication, but I don't remember how it gets the carry-out into a flag. >Even on x86/x64 you get into similar situations when you need to add >multiple parts together, it is easy to get stuck with long manual carry >chains. Not sure what you mean here. If you do it the conventional way, you certainly have a carry chain of n-1 carries if you add two n*64-bit numbers; so you have n dependent adds involved. If you want more parallelism, Michael S has presented a technique here that allows breaking such a chain into pieces, but it increases the number of instructions to execute, so you probably want to have a chain of a few such dependencies before you break one. Alexander Yee has implemented Kogge-Stone addition in AVX-512, but found that the variant that uses mask operations it is slower on Skylake X than the conventional way. On AMD processors with AVX-512, it looks better. He also has a longer sequence that avoids the mask instructions and is faster on Skylake X. If you want to have more addition chains at the same time, as in m1+m2+m3, or m1*m2 (which needs two addition chains in a conventional implementation), AMD64 gives you two carry chains with ADX (which, interestingly, is not included in x64-64-v4, even though ADX is included in all processors that have all of the features of x64-64-v4). Once you need three carry chains, you are out of luck with AMD64. >Possibly the best primitive is MAA (Mul Add Add) representing > > (sumlo, sumhi) = muladdadd(f1, f2, a1, a2); > >since this can never overflow the two-element result? It is useful for m1*m2, but not for addition. With one carry flag (e.g., ARM A64), a primitive (lo, hi) = muladd(f1,f2,a1) or alternatively (li, hi) = muladd_carry(f1,f2,a1) would already be helpful and would be a little closer to the usual instruction formats. A disadvantage of implementing all these primitives for multiplication as instruction is that in any usual implementation of such instructions it adds the latency of the multiplication on the whole chain, whereas you can avoid that if the addition is separate. BTW, the Alpha/RISC-V approach is not as bad for implementing muladdadd as it is for add with carry-in and carry-out; e.g., if you want to minimize the latency from a1 to hi (because hi will become the a1 in the next limb): mulhu hi, f1, f2 mul lo, f1, f2 add lo, lo, a2 sltu carry, lo, a2 add hi, hi, carry add lo, lo, a1 sltu carry, lo, a1 add hi, hi, carry That's three cycles of latency. Of course, AMD with ADX is better: # a1co = a1-C-O # f1 is in rdx; AT&T operand order mulx f2, lo, hico adcx a2, hico adox a1, hico # hi = hico+C+O The addition of C and O happens in the next limb. So here we have a latency of one cycle from one limb to the next (if C and O are independent, as in Intel P-cores). - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Scott Lurndal
Date: Fri, 06 Nov 2026 15:28
Date: Fri, 06 Nov 2026 15:28
23 lines
2044 bytes
2044 bytes
John Levine <johnl@taugh.com> writes: >According to John Savard <quadibloc@invalid.com>: >>They also made an 18-bit computer, the PDP-4 (which had compatible >>successors in the PDP-9 and PDP-15) which had a set of one's >>complement instructions and an additional set of two's complement >>instructions. I guess that let those machines act as bridges between >>hardware which was either one way or the other. > >The DEC Computer Engineering book says that the PDP-4 was designd to >be a lower cost PDP-1, 5/8 of the performance for half the cost. 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 Was this mnemonic really DAC? For the PDP-8, it was DCA (Deposit and Clear Accumulator).
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Jeroen Belleman
Date: Fri, 06 Nov 2026 15:50
Date: Fri, 06 Nov 2026 15:50
39 lines
2855 bytes
2855 bytes
On 11/6/26 07:24, Anton Ertl wrote: > 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. > [...] > > - anton There should be no problem. It's just a flip-flop. The carry out becomes the new carry in after the next clock. There is no problem at all to propagate this over as many additions as you want As far as I know, all machines these days have an ADD with carry as a single instruction. Jeroen Belleman
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Stephen Fuld
Date: Fri, 06 Nov 2026 18:51
Date: Fri, 06 Nov 2026 18:51
49 lines
3951 bytes
3951 bytes
On 11/2/2026 10:43 AM, John Levine wrote: > According to Stephen Fuld <sfuld@alumni.cmu.edu.invalid>: >> "Scientists and engineers demanded both precision and mathematical >> consistency." The result was both the 36 bit word and the use of >> mathematical representation that provided complete symmetry of positive >> and negative numbers. All of these machines used a numeric >> representation that had an equal number of positive and negative numbers >> and had both plus and minus zeros. These requirements are still present >> today in the form of the IEEE floating point standard. The IBM , GE and >> DEC machines used a signed-magnitude representation in which the sign >> bit was just that/ The Sperry Rand Univac systems used a >> ones-complement representation because it permitted faster addition and >> subtraction with less hardware. A complement cycle was not needed for >> most operations." > > The DEC PDP-10 had two's complement floating point but otherwise yes. > That last sentence is true compared to sign-magnitude but it did need > end-around carry. > >> Of course, the paper doesn't explain why the requirement for symmetry >> seemed to go away and two's complement became acceptable. > > IEEE floating point is still sign-magnitude since among other things that > enables the hidden bit so you get more precision almost for free. > > My guess is that for fixed point arithmetic, experience told people > that having to account for two versions of zero was a pain, while the > fact that the largest negative number had no positive representation > didn't matter. Could be. I can't talk to anyone else's experience or on any systems other than the 1100 series. But to me, minus zero was a sort of curiosity. I never worried about it. Actually, I can't recall ever having to deal with it at all. Perhaps that was due to the type of programming I was doing, i.e. not scientific/math heavy stuff. Or perhaps it was due to the design of the adder (a ones complement subtractive adder), which never generated minus zero as the result of an arithmetic operation, or the fact that the instructions that tested a register or a memory location for zero treated both positive and negative zero as zero. For me, the fact that the 1100 series was word addressable and accessing things like strings of characters was painful was far more of an issue than ones compliment arithmetic. -- - Stephen Fuld (e-mail address disguised to prevent spam)
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Levine
Date: Fri, 06 Nov 2026 19:22
Date: Fri, 06 Nov 2026 19:22
46 lines
3137 bytes
3137 bytes
It appears that Anton Ertl <anton@mips.complang.tuwien.ac.at> said: >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. Keep in mind that this computer was designed in 1962, built out of individual transistors soldered onto PC cards, and had 1K, 4K, or 8K 18 bit words of core memory. Of course more modern instruction sets are better. The point is that they understood that two's complement made multiple precision arithmetic a lot easier than one's comp or sign-magnitude, and they added a testable flag where they stored the carry. As the manual said about the tad instruction: 2's complement add. The C(Y) are added to C(AC) in 2's complement arithmetic. If there is a carry out of bit 0 of the AC, the Link will be set to 1. This feature is useful in multiple precision arithmetic. -- Regards, John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: Terje Mathisen
Date: Fri, 06 Nov 2026 19:50
Date: Fri, 06 Nov 2026 19:50
34 lines
2727 bytes
2727 bytes
Anton Ertl wrote: > Terje Mathisen <terje.mathisen@tmsw.no> writes: > [add with carry-in and carry-out] >> On Alpha you needed to play tricks with predicated instructions, afair >> you had two forms of ADD, one that just added two registers and one that >> did the same plus an extra increment which represented an incoming carry. > > No, Alpha is just like MIPS and RISC-V. For RISC-V: > > add tmp1, carry, summand1 > sltu carry1, tmp1, summand1 > add sum, tmp1, summand2 > sltu carry2, sum, tmp1 > add carry, carry2, carry1 > > Alpha has no predicated instructions apart from a conditional move and > no addition with an extra increment. > > What you describe reminds me of IA-64; it certeinly selects between > a+b and a+b+1 with predication, but I don't remember how it gets the > carry-out into a flag. Mea Culpa! You are correct, I mixed up Alpha and IA-64. In my defense I wrote some asm kernels for both, without ever having access to actual HW. :-( Terje -- - <Terje.Mathisen at tmsw.no> "almost all programming can be viewed as an exercise in caching"
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Levine
Date: Sat, 07 Nov 2026 02:36
Date: Sat, 07 Nov 2026 02:36
30 lines
2588 bytes
2588 bytes
According to Scott Lurndal <slp53@pacbell.net>: >>The DEC Computer Engineering book says that the PDP-4 was designd to >>be a lower cost PDP-1, 5/8 of the performance for half the cost. 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 > >Was this mnemonic really DAC? For the PDP-8, it was DCA >(Deposit and Clear Accumulator). I looked at the maual. The load instruction was actually "lac", load accumulator, the store instruction "dac" for deposit accumulator. It also had "dzm" deposit zero to memory. xor, and xct (execute.) The PDP-5/8 had only half as manyinstructions so they came up with the clever hack of having the two's complement TAD instruction, no load instruction, but DCA stored and cleared so you could use a TAD to load the next value. -- Regards, John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly
carry-in (was: two's complement and Flags)
Author: Anton Ertl
Date: Sat, 07 Nov 2026 07:41
Date: Sat, 07 Nov 2026 07:41
64 lines
4545 bytes
4545 bytes
John Levine <johnl@taugh.com> writes: >It appears that Anton Ertl <anton@mips.complang.tuwien.ac.at> said: [PDP-4] >>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. > >Keep in mind that this computer was designed in 1962, built out of >individual transistors soldered onto PC cards, and had 1K, 4K, or 8K >18 bit words of core memory. Of course more modern instruction sets are >better. I don't think it has anything to do with the materials from which it was built. Turning TAD into TADC (with carry-in) would only have require to use a full adder instead of a half-adder for the lowest bit of the adder and put a wire from the link bit to the carry-in of that full adder. And given that it also has a ones-complement addition, the lowest bit probaly already uses a full adder for the end-around-carry (another reason would be that it may have a narrower (maybe even 1-bit) adder that is used in multiple rounds for a full-width addition, like the original Nova). So the only cost would be to mux the link bit with the end-around-carry depending on the instruction, rather than just masking the end-around carry depending on the instruction. Doing the multiplexing with a wired-or would require one additional gate and two wires; even for a cheap model, the incremental cost would be tiny. The 6502 was also designed to be extremely cheap, and it was designed to be so cheap that it does not even support 16-bit-wide ALU operations despite having 16-bit addresses, but it does include carry-in. They could have shaved off a few more transistors for having only a half-adder for the lowest bit of the ALU, but did not. As for 1962 and more modern instruction sets being better, I think that, yes, they suffered from not having that many good examples to look at, while 64 years later I can point at the 6502 as an example that did this aspect better, while being designed for very low cost, too. S/360 does not have an add with carry-in, either, and IIRC it took until S390 (or S390x?) for them to add it, while microprocessors, having learned the lesson with the 8-bit architectures, usually included add with carry-in and carry-out from the start (with the notable exceptions of MIPS and its descendants). Looking at the PDP-11, it seems to me that again, it supports double-precision arithmetic with the ADC and SBC instructions, but not multiple-precision arithmetics: It splits the add with carry-in into two instructions: ADC and ADD (ADC only adds the carry), but the carries of the two instructions have to be combined with a complex sequence of instructions in order to achieve an add with carry-in and carry-out. The VAX has ADWC, which is a full add with carry-in and carry-out, so the minis eventually learned the lesson, shortly after the micros, and a lot of years before the mainframes. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: carry-in (was: two's complement and Flags)
Author: Thomas Koenig
Date: Sat, 07 Nov 2026 12:09
Date: Sat, 07 Nov 2026 12:09
19 lines
2225 bytes
2225 bytes
Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb: > I don't think it has anything to do with the materials from which it > was built. Turning TAD into TADC (with carry-in) would only have > require to use a full adder instead of a half-adder for the lowest bit > of the adder and put a wire from the link bit to the carry-in of that > full adder. And given that it also has a ones-complement addition, > the lowest bit probaly already uses a full adder for the > end-around-carry (another reason would be that it may have a narrower > (maybe even 1-bit) adder that is used in multiple rounds for a > full-width addition, like the original Nova). The original Nova had a four-bit TI 7483 as an adder. You might be thinking of the PDP-8/S. -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
Re: two's complement and Flags (Re: arithmetic and endian history)
Author: John Savard
Date: Sat, 07 Nov 2026 13:52
Date: Sat, 07 Nov 2026 13:52
12 lines
1682 bytes
1682 bytes
On Fri, 6 Nov 2026 03:22:16 -0000 (UTC), John Levine <johnl@taugh.com> wrote: >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. Given that, it's a wonder that _any_ computer, ever, at least any computer with a short word length, used one's complement arithmetic. John Savard
Re: carry-in (was: two's complement and Flags)
Author: Anton Ertl
Date: Sat, 07 Nov 2026 16:19
Date: Sat, 07 Nov 2026 16:19
22 lines
2378 bytes
2378 bytes
Thomas Koenig <tkoenig@netcologne.de> writes: >Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb: > >> I don't think it has anything to do with the materials from which it >> was built. Turning TAD into TADC (with carry-in) would only have >> require to use a full adder instead of a half-adder for the lowest bit >> of the adder and put a wire from the link bit to the carry-in of that >> full adder. And given that it also has a ones-complement addition, >> the lowest bit probaly already uses a full adder for the >> end-around-carry (another reason would be that it may have a narrower >> (maybe even 1-bit) adder that is used in multiple rounds for a >> full-width addition, like the original Nova). > >The original Nova had a four-bit TI 7483 as an adder. And it needed four rounds through that adder for a full-width addition. That's what I meant. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: carry-in
Author: Stephen Fuld
Date: Sat, 07 Nov 2026 18:17
Date: Sat, 07 Nov 2026 18:17
77 lines
5399 bytes
5399 bytes
On 11/6/2026 11:41 PM, Anton Ertl wrote: > John Levine <johnl@taugh.com> writes: >> It appears that Anton Ertl <anton@mips.complang.tuwien.ac.at> said: > [PDP-4] >>> 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. >> >> Keep in mind that this computer was designed in 1962, built out of >> individual transistors soldered onto PC cards, and had 1K, 4K, or 8K >> 18 bit words of core memory. Of course more modern instruction sets are >> better. > > I don't think it has anything to do with the materials from which it > was built. Turning TAD into TADC (with carry-in) would only have > require to use a full adder instead of a half-adder for the lowest bit > of the adder and put a wire from the link bit to the carry-in of that > full adder. And given that it also has a ones-complement addition, > the lowest bit probaly already uses a full adder for the > end-around-carry (another reason would be that it may have a narrower > (maybe even 1-bit) adder that is used in multiple rounds for a > full-width addition, like the original Nova). > > So the only cost would be to mux the link bit with the > end-around-carry depending on the instruction, rather than just > masking the end-around carry depending on the instruction. Doing the > multiplexing with a wired-or would require one additional gate and two > wires; even for a cheap model, the incremental cost would be tiny. > > The 6502 was also designed to be extremely cheap, and it was designed > to be so cheap that it does not even support 16-bit-wide ALU > operations despite having 16-bit addresses, but it does include > carry-in. They could have shaved off a few more transistors for > having only a half-adder for the lowest bit of the ALU, but did not. > > As for 1962 and more modern instruction sets being better, I think > that, yes, they suffered from not having that many good examples to > look at, while 64 years later I can point at the 6502 as an example > that did this aspect better, while being designed for very low cost, > too. > > S/360 does not have an add with carry-in, either, and IIRC it took > until S390 (or S390x?) for them to add it, while microprocessors, > having learned the lesson with the 8-bit architectures, usually > included add with carry-in and carry-out from the start (with the > notable exceptions of MIPS and its descendants). > > Looking at the PDP-11, it seems to me that again, it supports > double-precision arithmetic with the ADC and SBC instructions, but not > multiple-precision arithmetics: It splits the add with carry-in into > two instructions: ADC and ADD (ADC only adds the carry), but the > carries of the two instructions have to be combined with a complex > sequence of instructions in order to achieve an add with carry-in and > carry-out. > > The VAX has ADWC, which is a full add with carry-in and carry-out, so > the minis eventually learned the lesson, shortly after the micros, and > a lot of years before the mainframes. Perhaps a reason for that was that the mainframes started with bigger word sizes to begin with (32, 36, or even 60 bits) so the pressure to easily handle multi word arithmetic was less. However, note that the 1108 in 1965 had a pretty full complement of double word arithmetic instructions, 72 bit add and subtract, 36*36 giving 72 bit multiplication, and 72 divided by 36 bit giving 36 bit dividend and remainder. This lessened pressure for multi precision capabilities. Never the less, it supported both carry and overflow flags and conditional jump instructions to test for them. -- - Stephen Fuld (e-mail address disguised to prevent spam)
Re: carry-in (was: two's complement and Flags)
Author: Thomas Koenig
Date: Sat, 07 Nov 2026 18:20
Date: Sat, 07 Nov 2026 18:20
29 lines
2696 bytes
2696 bytes
Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb: > Thomas Koenig <tkoenig@netcologne.de> writes: >>Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb: >> >>> I don't think it has anything to do with the materials from which it >>> was built. Turning TAD into TADC (with carry-in) would only have >>> require to use a full adder instead of a half-adder for the lowest bit >>> of the adder and put a wire from the link bit to the carry-in of that >>> full adder. And given that it also has a ones-complement addition, >>> the lowest bit probaly already uses a full adder for the >>> end-around-carry (another reason would be that it may have a narrower >>> (maybe even 1-bit) adder that is used in multiple rounds for a >>> full-width addition, like the original Nova). >> >>The original Nova had a four-bit TI 7483 as an adder. > > And it needed four rounds through that adder for a full-width > addition. That's what I meant. I only recently learned that the Z80 also has a four-bit ALU, making two passes for an 8-bit addition. I *had* wondered why the 6502 got similar performance at 1 MHz as the Z80 at 3 to 4. -- This USENET posting was made without artificial intelligence, artificial impertinence, artificial arrogance, artificial stupidity, artificial flavorings or artificial colorants.
6502 vs Z80 (was: carry-in)
Author: Anton Ertl
Date: Sat, 07 Nov 2026 18:35
Date: Sat, 07 Nov 2026 18:35
92 lines
4866 bytes
4866 bytes
Thomas Koenig <tkoenig@netcologne.de> writes: >I *had* wondered why the 6502 got similar performance at 1 MHz as >the Z80 at 3 to 4. <https://en.wikipedia.org/wiki/Z80#Instruction_execution> says: |Each instruction is executed in steps that are usually termed machine |cycles (M-cycles), each of which can take between three and six clock |periods (T-states). It gives examples, e.g. INC B takes 1 M-cycle consisting of 4 T-states. On the 6502 INX and INY take 2 cycles. ADD HL, DE takes 3 M-cycles consisting of 11 T-states. The 6502 does not do reg-reg adds and does not have 16-bit registers, but the minimum would be something like: #L in A # C is known to be clear, otherwise preprend CLC at 2 cycles adc E # E in zero page sta L lda H # H in zero page adc D # D in zero page #H in A with a total of 12 cycles. INC (IY+d) takes 6 M-cycles and 23 T-states On the 6502 this might be either # IY in x, but x can only hold 8 bits INC d,x # 6 cycles with d in zero page, 7 otherwise or, if that's too restrictive, # IY in zero page # C is known to be clear, otherwise preprend CLC at 2 cycles ldy #d lda (IY),y adc #1 sta (IY),y with a total of 14 or 16 cycles. So even this sequence beats the Z80 in terms of cycles (but not by a factor of 3 or 4). The restricted version beats it by a factor of 3-4 in cycles. So if the 6502 programmer could arrange to use of INC d,x for INC (IY+d) often, and the Z80 progammer could not make use of ADD HL,DE often, the factor of 3-4 in cycles is possible. However, my impression is that there is a lot of cherry-picking in such reports. For a more recent and, I think, more balanced report, but still using only one particular task popular in benchmarking during the period, <https://www.ele.uva.es/~jesus/sieves/update.pdf> reports a factor 1.9 more cycles on the Z80 than the 6502 (so a TRS-80 Model I (1.78MHz Z80) would perform very similar to a PET or Apple II (1MHz 6502)); however, 4MHz became a more common clock rate for Z80 systems, while even the 1982-vintage C64 still has only 1MHz. More on the sieve comparison can be found on <https://www.ele.uva.es/~jesus/sieves/sievetst.html>. This also points to an earlier paper by Jesus Arias <https://www.ele.uva.es/~jesus/sieves/onthe6502.pdf> where the benchmark programs were less optimized, but the relations between 6502 and Z80 are similar. But the interesting thing for an earlier discussion here is that he also compares to the BN16, a 16-bit RISC processor he designed. It takes 7678 transistors in CMOS, and he estimates that it would be 3000-4000 transistors in NMOS, which would be similar to the 6502. With that the task takes a similar number of executed instructions as on the 6502, but many fewer clock cycles. Apparently the BN16 uses a 16-bit data bus (it achieves 1.11 CPI), so it would be too expensive to use at the time. Designing it for an 8-bit data bus would take some more transistors and increase the CPI to 2.11 (with the same instruction set), but that's still better than the 6502's CPI of 3.04. Maybe one could design a CPU with lessons from RISCs, but also including 8-bit-wide instructions for a better CPI and smaller programs, without too many additional transistors. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Re: carry-in (was: two's complement and Flags)
Author: John Levine
Date: Sat, 07 Nov 2026 18:44
Date: Sat, 07 Nov 2026 18:44
48 lines
3509 bytes
3509 bytes
According to Anton Ertl <anton@mips.complang.tuwien.ac.at>: >John Levine <johnl@taugh.com> writes: >>It appears that Anton Ertl <anton@mips.complang.tuwien.ac.at> said: >[PDP-4] >>>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. >> >>Keep in mind that this computer was designed in 1962, built out of >>individual transistors soldered onto PC cards, and had 1K, 4K, or 8K >>18 bit words of core memory. Of course more modern instruction sets are >>better. > >I don't think it has anything to do with the materials from which it >was built. Turning TAD into TADC (with carry-in) would only have >require to use a full adder instead of a half-adder for the lowest bit ... Sure, but that would have needed another opcode, and all 16 of the available opcodes were taken. Once again, in retrospect this was rather primitive, but it did show that they understood that two's complement made multiple precision easier. Given that the PDP-5 only had two's complement they presumably figured that whatever disadvantage it might have compared to one's complement wasn't very important. >S/360 does not have an add with carry-in, either, and IIRC it took >until S390 (or S390x?) for them to add it, while microprocessors, >having learned the lesson with the 8-bit architectures, usually >included add with carry-in and carry-out from the start (with the >notable exceptions of MIPS and its descendants). It was S390x, 390 mode on z. Waving my hands a lot, I would guess that it was rare to need more than 64 bit integer arithmetic so the original AL was good enough. Then z made 64 bits the basic type so they retroactively gave s390 add with carry so it could handle larger (128 probably) more efficiently. Eight bit micros always needed carry in and out because 16 bits is rarely enough. -- Regards, John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly
Re: carry-in in history
Author: John Levine
Date: Sat, 07 Nov 2026 19:00
Date: Sat, 07 Nov 2026 19:00
27 lines
2420 bytes
2420 bytes
According to Stephen Fuld <sfuld@alumni.cmu.edu.invalid>: >Perhaps a reason for that was that the mainframes started with bigger >word sizes to begin with (32, 36, or even 60 bits) so the pressure to >easily handle multi word arithmetic was less. Makes sense. >However, note that the 1108 in 1965 had a pretty full complement of >double word arithmetic instructions, 72 bit add and subtract, 36*36 >giving 72 bit multiplication, and 72 divided by 36 bit giving 36 bit >dividend and remainder. The GE 635 in 1964 had add and subtract with carry, and multiplication an division with double word products and dividend. The PDP-6 had carry flags but you had to do conditional jumps to use them (it wasn't hard). It also had 36->72 and 72->36 multiplication and division. See the double precision integer programming examples on pages 7 and 8 here: https://bitsavers.org/pdf/dec/pdp6/F-64PX_PDP-6_Programming_Examples_Aug64.pdf So it seems everyone had similiar ideas about what kind of arithmetic people would want to do. -- Regards, John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly
Re: carry-in (was: two's complement and Flags)
Author: Lawrence DāOliveiro
Date: Sat, 07 Nov 2026 22:33
Date: Sat, 07 Nov 2026 22:33
19 lines
2265 bytes
2265 bytes
On Sat, 07 Nov 2026 07:41:34 GMT, Anton Ertl wrote: > The 6502 was also designed to be extremely cheap, and it was > designed to be so cheap that it does not even support 16-bit-wide > ALU operations despite having 16-bit addresses, but it does include > carry-in. I think the only 16-bit address arithmetic operation needed was adding 1 to the program counter. All the index registers were 8-bit; even the stack pointer was 8-bit, so there was no need for 16-bit arithmetic on that (beyond prepending a fixed high byte of 1 to construct the current top-of-stack address). > The VAX has ADWC, which is a full add with carry-in and carry-out, so > the minis eventually learned the lesson, shortly after the micros, and > a lot of years before the mainframes. Obviously such a feature had no value in mainframe COBOL ābusinessā programming, did it ... š
Re: carry-in
Author: Lawrence DāOliveiro
Date: Sat, 07 Nov 2026 22:37
Date: Sat, 07 Nov 2026 22:37
25 lines
2769 bytes
2769 bytes
On Sat, 7 Nov 2026 10:17:49 -0800, Stephen Fuld wrote: > Perhaps a reason for that was that the mainframes started with > bigger word sizes to begin with (32, 36, or even 60 bits) so the > pressure to easily handle multi word arithmetic was less. > > However, note that the 1108 in 1965 had a pretty full complement of > double word arithmetic instructions, 72 bit add and subtract, 36*36 > giving 72 bit multiplication, and 72 divided by 36 bit giving 36 bit > dividend and remainder. This lessened pressure for multi precision > capabilities. Never the less, it supported both carry and overflow > flags and conditional jump instructions to test for them. Remember also the pervasive distinction, right up to about the 1970s, between ābusinessā and āscientificā computing. Entire hardware/software systems were designed from the ground up specifically for one or the other. Any kind of number-theoretic operations beyond the most basic (i.e. fixed-precision) arithmetic would have been lumped in on the āscientificā side, rather than the ābusinessā side. Iām guessing that IBM were the kings of ābusinessā computing mainly, that āscientificā customers would have had a bit more awareness of the pros and cons of IBM gear versus the competition, and be less willing to succumb to the ānobody got fired for buy IBMā mentality ...
Re: carry-in (was: two's complement and Flags)
Author: Lawrence DāOliveiro
Date: Sat, 07 Nov 2026 22:38
Date: Sat, 07 Nov 2026 22:38
8 lines
1817 bytes
1817 bytes
On Sat, 7 Nov 2026 18:20:35 -0000 (UTC), Thomas Koenig wrote: > I *had* wondered why the 6502 got similar performance at 1 MHz as > the Z80 at 3 to 4. The main reason is that the 6502 is strictly doing 8-bit arithmetic even for addressing, while the Z80 is trying to support full 16-bit addressing/indexing modes.
Re: carry-in (was: two's complement and Flags)
Author: George Neuner
Date: Sun, 08 Nov 2026 07:55
Date: Sun, 08 Nov 2026 07:55
25 lines
2467 bytes
2467 bytes
On Sat, 7 Nov 2026 22:33:05 -0000 (UTC), Lawrence DĀ“Oliveiro <ldo@nz.invalid> wrote: >On Sat, 07 Nov 2026 07:41:34 GMT, Anton Ertl wrote: > >> The 6502 was also designed to be extremely cheap, and it was >> designed to be so cheap that it does not even support 16-bit-wide >> ALU operations despite having 16-bit addresses, but it does include >> carry-in. > >I think the only 16-bit address arithmetic operation needed was adding >1 to the program counter. All the index registers were 8-bit; even the >stack pointer was 8-bit, so there was no need for 16-bit arithmetic on >that (beyond prepending a fixed high byte of 1 to construct the >current top-of-stack address). All the 6502's indexed addressing modes required 16-bit arithmetic. >> The VAX has ADWC, which is a full add with carry-in and carry-out, so >> the minis eventually learned the lesson, shortly after the micros, and >> a lot of years before the mainframes. > >Obviously such a feature had no value in mainframe COBOL ābusinessā >programming, did it ... ?
Re: carry-in
Author: Robert Finch
Date: Sun, 08 Nov 2026 12:50
Date: Sun, 08 Nov 2026 12:50
34 lines
2852 bytes
2852 bytes
On 2026-11-08 2:55 a.m., George Neuner wrote: > On Sat, 7 Nov 2026 22:33:05 -0000 (UTC), Lawrence DĀ“Oliveiro > <ldo@nz.invalid> wrote: > >> On Sat, 07 Nov 2026 07:41:34 GMT, Anton Ertl wrote: >> >>> The 6502 was also designed to be extremely cheap, and it was >>> designed to be so cheap that it does not even support 16-bit-wide >>> ALU operations despite having 16-bit addresses, but it does include >>> carry-in. >> >> I think the only 16-bit address arithmetic operation needed was adding >> 1 to the program counter. All the index registers were 8-bit; even the >> stack pointer was 8-bit, so there was no need for 16-bit arithmetic on >> that (beyond prepending a fixed high byte of 1 to construct the >> current top-of-stack address). > > All the 6502's indexed addressing modes required 16-bit arithmetic. > > Yes, the index register could reach across page boundaries. So they would at least need a carry chain. It would have been nice if the SP was 16-bit. 6809 was a bit better with the registers. >>> The VAX has ADWC, which is a full add with carry-in and carry-out, so >>> the minis eventually learned the lesson, shortly after the micros, and >>> a lot of years before the mainframes. >> >> Obviously such a feature had no value in mainframe COBOL ābusinessā >> programming, did it ... ?
Re: carry-in
Author: Waldek Hebisch
Date: Sun, 08 Nov 2026 18:52
Date: Sun, 08 Nov 2026 18:52
57 lines
4073 bytes
4073 bytes
Thomas Koenig <tkoenig@netcologne.de> wrote:
> Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
>> Thomas Koenig <tkoenig@netcologne.de> writes:
>>>Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
>>>
>>>> I don't think it has anything to do with the materials from which it
>>>> was built. Turning TAD into TADC (with carry-in) would only have
>>>> require to use a full adder instead of a half-adder for the lowest bit
>>>> of the adder and put a wire from the link bit to the carry-in of that
>>>> full adder. And given that it also has a ones-complement addition,
>>>> the lowest bit probaly already uses a full adder for the
>>>> end-around-carry (another reason would be that it may have a narrower
>>>> (maybe even 1-bit) adder that is used in multiple rounds for a
>>>> full-width addition, like the original Nova).
>>>
>>>The original Nova had a four-bit TI 7483 as an adder.
>>
>> And it needed four rounds through that adder for a full-width
>> addition. That's what I meant.
>
> I only recently learned that the Z80 also has a four-bit ALU, making
> two passes for an 8-bit addition.
>
> I *had* wondered why the 6502 got similar performance at 1 MHz as
> the Z80 at 3 to 4.
1) Clock frequency is not everything. 6502 had 2 phase clock,
giving it 4 synchronized transitions per clock, Z80 had one
phase clock giving it 2 synchronized transitions.
2) Z80 included refresh functionality, so had to do fetch in
2 clocks, while using 2 clock of M1 cycle for memory refresh.
That means that its nominal memory bandwidth was lower than
other processors using similarly clocked memory.
3) Z80 needed 4 clocks per fetch and 3 clocks for other memory
accesses, 6502 was able to do memory access in each clock.
4) I think that 6502 instruction set was slightly better matched
to usage at that time. Namely, 6502 was oriented to operating
on memory, while Z80 offered register operations. Trouble was
that with 8 bit for opcode and registers Z80 had to use
accumulator for most operations. So keeping data in registers
gave small if any gain compared to using data from memory
(both cases required move to accumulator, op and move back).
Registers were useful for keeping addreses, but once more
than 1 address was in use one needed extra instruction or
prefixes (which increased time to fetch instructions).
Comaratively 0 page addressing meant shorter instructions,
I am not sure how much one gained due to addresing modes
but probably comparably to Z80 registers.
To summarize, due to bus interface 1 MHz 6502 and about 3.5 MHz
Z80 had similar memory bandwidth, with Z80 needing faster
memory chips. Probably on average 6502 instructions were
slightly shorter, but that presumably varied from application
to application.
--
Waldek Hebisch
Re: carry-in (was: two's complement and Flags)
Author: John Savard
Date: Mon, 09 Nov 2026 02:09
Date: Mon, 09 Nov 2026 02:09
14 lines
1864 bytes
1864 bytes
On Sat, 07 Nov 2026 07:41:34 GMT, anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: >The 6502 was also designed to be extremely cheap, and it was designed >to be so cheap that it does not even support 16-bit-wide ALU >operations despite having 16-bit addresses, but it does include >carry-in. IIRC, the 6809 and the Z-80 had a 16-bit add instruction - but the 8080 and the 6800 did not. So not having one was not a consequence of how cheap the 6502 was designed to be, although it definitely was designed to be much cheaper than the 8080 and 6800. John Savard
Re: carry-in
Author: Waldek Hebisch
Date: Thu, 26 Nov 2026 01:52
Date: Thu, 26 Nov 2026 01:52
28 lines
2132 bytes
2132 bytes
John Savard <quadibloc@invalid.com> wrote:
> On Sat, 07 Nov 2026 07:41:34 GMT, anton@mips.complang.tuwien.ac.at
> (Anton Ertl) wrote:
>
>>The 6502 was also designed to be extremely cheap, and it was designed
>>to be so cheap that it does not even support 16-bit-wide ALU
>>operations despite having 16-bit addresses, but it does include
>>carry-in.
>
> IIRC, the 6809 and the Z-80 had a 16-bit add instruction - but the
> 8080
8080 has DAD B, DAD D, DAD H and DAD SP which add register pairs
with result in HL. There is also DCX B and similar (which decrement
register pair). It does not handle carry, and does not have
general 16 bit subtraction.
> and the 6800 did not. So not having one was not a consequence of
> how cheap the 6502 was designed to be, although it definitely was
> designed to be much cheaper than the 8080 and 6800.
I am not sure about "much". 6502 looks simpler than 8080, but
not much simpler. IIUC in not so long time prices of Z80 (which
is sigmificantly more complex than 8080) and 6502 got very
similar.
--
Waldek Hebisch
Re: carry-in
Author: Anton Ertl
Date: Thu, 26 Nov 2026 07:40
Date: Thu, 26 Nov 2026 07:40
36 lines
2721 bytes
2721 bytes
antispam@fricas.org (Waldek Hebisch) writes: >John Savard <quadibloc@invalid.com> wrote: >> On Sat, 07 Nov 2026 07:41:34 GMT, anton@mips.complang.tuwien.ac.at >> (Anton Ertl) wrote: >> So not having one was not a consequence of >> how cheap the 6502 was designed to be, although it definitely was >> designed to be much cheaper than the 8080 and 6800. > >I am not sure about "much". The target price for the 6502 was USD 25 at a time when the 6800 cost $175. I call that "much" cheaper. >6502 looks simpler than 8080, but >not much simpler. Not from the design alone. I think that Intel and Motorola did not lower the prices of their products as yields improved, and MOS Technology used that window to enter the market with a drastically cheaper product; and the smaller design meant that they would always have lower cost than Motorola. >IIUC in not so long time prices of Z80 (which >is sigmificantly more complex than 8080) and 6502 got very >similar. The Z80 initially cost USD 200 <https://tedium.co/2024/05/11/zilog-z80-history/>, a year after the 6502. I expect that competition drove the price down soon, and once the dies are cheap to make, the packaging limits the cost. Both CPUs use 40-pin DIPs, so ... - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Page 1 of 2 ⢠52 total messages
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads