IP Checksum coding challenge ?
Scott Dattalo email (remove spam text)
On Wed, 10 Jan 2001, Nikolai Golovchenko wrote:
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
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email mitvma.mit.edu with SET PICList DIGEST in the body listserv
In reply to: <firstname.lastname@example.org>
See also: www.piclist.com/techref/method/errors.htm?key=checksum
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the