Thanks. That looks more like the way I thought it should look. I just couldn't see it. > -----Original Message----- > From: Scott Dattalo [mailto:scott@DATTALO.COM] > Sent: Monday, February 19, 2001 4:42 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: Code challenge > > > On Mon, 19 Feb 2001, Don Hyde wrote: > > > I need to add a 24-bit signed number to a 40-bit total, > using a 16CXXX > > processor. > > > > What I've coded looks pretty messy by the time I've > propagated the carries. > > It seems really gross, and is slower than adding two 40-bit numbers! > > Perhaps someone out there has thought about these and has > it all worked out > > already? > > > > The 24-bit number is in AARGB2 thru AARGB0 (MSB) > > The total is being accumulated in Xsum3_2 thru Xsum3_oflo2 (MSB) > > > > ; Accumulate sum of cubes > > > > movfw AARGB2 > > addwf Xsum3_2,f > > > > movfw AARGB1 > > skpnc > > incfsz AARGB1,w > > addwf Xsum3_1,f > > > > movfw AARGB0 > > skpnc > > incfsz AARGB0,w > > addwf Xsum3_0,f > > > > clrf temp > > > > > rlf temp,w ;pick up the carry > addwf Xsum3_oflo,f ;and propogate to the upper 16bits > skpnc ;C will only be set if W=1 > addwf Xsum3_oflo2,f ;so we can add w to high 8. > > Scott > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body