Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

Re: Arithmetics with carry



"H. Peter Anvin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Followup to:  <[EMAIL PROTECTED]>
> By author:    "Glen Herrmannsfeldt" <[EMAIL PROTECTED]>
> In newsgroup: comp.arch.fpga
> >
> > This is true, except for generating the flags on the final add.  Well,
you
> > can either generate all the flags, or only the signed or unsigned flags.
> > For the intermediate adds only the carry, or lack of carry, from the
high
> > bit is important.  To detect signed overflow or underflow (more negative
> > than can be represented) requires comparing the carry into and out of
the
> > sign bit.

> It depends.  Some architectures define CF=0 to mean borrow-out from a
> subtraction.  Under that definition (used by the PDP-11, for example),
> SUB is equivalent to NEG + ADD (a desirable property in my opinion);
> under the "other" definition (as used by among others Intel processors
> ever since the 4004), SUB ends up producing the opposite carry from
> NEG+ADD.

For unsigned arithmetic, or all except the most significant word of
multiword signed arithmetic, yes, carry is the complement of borrow.
Somewhere back in the thread I wrote that.  For the most significant word or
only word for signed arithmetic overflow/underflow must be computed
differently.

-- glen






<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.