IP Checksum coding challenge ?
Nikolai Golovchenko email (remove spam text)
Scott Dattalo wrote:
> 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.
I'm afraid that doesn't work either. Suppose the carry is cleared
after the addwf, and zero flag is set, which is the case when
zero added to zero. The increment after skpnc will be skipped,
but the next one after skpnz won't!
> 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.
That would fix the problem also, since the increment will never
be executed on cleared carry. But I see a way to avoid the code
size grows. Take a look:
; 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: <Pine.LNX.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