piclist 2001\01\10\123726a >
Thread: IP Checksum coding challenge ?
face BY : Scott Dattalo email (remove spam text)

On Wed, 10 Jan 2001, Nikolai Golovchenko wrote:

{Quote hidden}


You're right. Bill caught this too.

> I think there should be 2 too many instructions, as always :)

You're right again :). This is what I posted to Bill:

I was thinking add +1 in which case the carry and Z would both be set. However,
that's not necessarily the case. You can say that if Z is set after the addwf,
then the carry will be set too. So change the spknz above to a skpnc.

Now suppose the carry is set after the addwf. The skpnc will not skip and the
incf ipcksum_l will execute. If this rolls over, then the z bit will be set (but
the carry won't be affected. The next skpnz will detect this rollover and
increment the high byte accordingly.

Note, at the cost of increasing the worst case execution time, you can improve
the average execution time by inverting the polarity of the skp instructions and
execute returns if the skip is not taken.

; enter with "b" in W


   incf   ipcksum_b,f
   btfsc  ipcksum_b,0
    goto  l1

   addwf  ipcksum_h,f
    incf  ipcksum_l,f
    incf  ipcksum_h,f

   addwf  ipcksum_l,f
    incf  ipcksum_h,f
    incf  ipcksum_l,f


http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listserv@spam@spammitvma.mit.edu with SET PICList DIGEST in the body


In reply to: <4412819840.20010110104528@yahoo.com>
See also: www.piclist.com/techref/method/errors.htm?key=checksum
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) IP Checksum coding challenge ?

month overview.

new search...