Re: Ones Complement

From: Charles Esson <charlese_at_cvs.com.au>
Date: Wed, 21 Jun 2000 15:06:11 +1000

Hi

It's no big deal doing one's complement on two complement machine you just
have to add in the carries. Can even do it in forth, in code below 32 bit
adder, the spec calls for a 16bit 1's complement sum.

Regards

Charles

 : cksum { variable %buffer variable %length ( --checksum) }
  zero
  %buffer @ %length @ + %buffer @ DO
   I W@ +
  2 +LOOP
  DUP $10 RSHIFT SWAP $0FFFF AND +
  DUP $10 RSHIFT +
  -1 XOR
  $0FFFF AND
 ;

Neil Bawd wrote:

> Charles Esson <charlese_at_cvs.com.au> wrote:
>
> > Try writing a TCP/IP stack, it riddled with 1's complement
> > arithmetic. It just is.
>
> Hi Charles,
>
> Thanks for your note.
>
> I used 1's-complement in 1964-1967, but not since then.
>
> >From 1982 to 1994 I was tool designer for a Unisys (later
> Ascom) division doing wide-area networks. The programmers
> never wanted 1's complement.
>
> Right now I'm studying cryptography. There the characters
> are 8-bit bytes, words are 32 bits, arithmetic is twos-
> complement (big-endian and little-endian).
>
> However I'll revise my quotation.
>
> --
> Wil Baden Costa Mesa, California Per neilbawd_at_earthlink.net
> In my world, "chars have 8 bits. They just do. All integral
> arithmetic is done in twos-complement binary. It just is. Several
> simple 'get real' assumptions like these make our work possible."
>
> _______________________________________________
> Sftalk mailing list Sftalk_at_forth.com
> Visit Sftalk on the web at http://www.forthinc.com/mailman/listinfo/sftalk
Received on Wed Jun 21 2000 - 02:39:51 PDT


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 08-Feb-2012. Archive updated nightly.