[comp.arch] Add with carry

cet1@cl.cam.ac.uk (C.E. Thompson) (09/13/90)

In article <3737@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
>
>Many "stock" architectures (/370, 680x0, 80*86, 32?32, ... provide all
                             !!!!
>the primitives (add with carry, n*n -> 2n multiply, and so on) that are
                 !!!!!!!!!!!!!!
>needed to synthesise integer arithmetic of any size.  

You touch on a sore point there. The IBM/370 instruction set does *not*
contain an "add with carry". It contains an "add logical" instruction that
sets the condition code according to the unsigned carry-out, but you then
have to use a conditional branch (or a long sequence of instructions if you
feel you absolutely have to avoid the branch). This is usable, just about,
for double-length integer arithmetic, but it is hell to use for real bignum  
arithmetic. Together with the fact that there is no *unsigned* 32x32 -> 64
multiply instruction, this provides one reason why bignum arithmetic on
an IBM/370 is nearly always done using a base of 2**31 (or even lower power)
rather than 2**32.

Chris Thompson
JANET:    cet1@uk.ac.cam.phx
Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk