piclist 2001\01\10\034630a >
Thread: IP Checksum coding challenge ?
www.piclist.com/techref/method/errors.htm?key=checksum
flavicon
face BY : Nikolai Golovchenko email (remove spam text)



---- Original Message ----
From: Scott Dattalo <KILLspamscottspamspamTakeThisOuTDATTALO.COM>
Sent: Wednesday, January 10, 2001 4:24:17
 To: spamBeGonePICLISTspamMITVMA.MIT.EDU
Subj: [PIC]: IP Checksum coding challenge ?
<snip>
{Quote hidden}

Scott, this doesn't seem to work! You don't check the carry flag
after addition. Also, when ipcksum_b.0==1 the data byte should be
added to the higher part of the checksum. Here is an alternative,
not using the known_zero register (17 instructions):

; enter with "b" in W

ipsum_running:

   incf   ipcksum_b,f
   btfss  ipcksum_b,0
    goto  l1

   addwf  ipcksum_h,f
   movlw 1
   skpnc
    addwf ipcksum_l,f
   skpnc
    addwf  ipcksum_h,f
   return

l1:
   addwf  ipcksum_l,f
   movlw 1
   skpnc
    addwf  ipcksum_h,f
   skpnc
    addwf  ipcksum_l,f
   return

Or, shrinked to 14 instructions:

ipsum_running
   incf   ipcksum_b,f
   btfsc  ipcksum_b,0
    addwf  ipcksum_h,f
   btfss  ipcksum_b,0
    addwf  ipcksum_l,f
   skpc
    return
   btfss  ipcksum_b,0
    incfsz  ipcksum_h,f
   btfsc  ipcksum_b,0
    incf  ipcksum_l,f
   skpnz
    incf  ipcksum_h,f
   return

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

Nikolai

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


<4412819840.20010110104528@yahoo.com> 7bit

In reply to: <Pine.LNX.4.21.0101091327110.10842-100000@tempest2.blackhat.net>
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...