Annotation of xinu/sys/cksum.s, revision 1.1

1.1     ! root        1: /* cksum.s - cksum */
        !             2: 
        !             3: /*
        !             4:  *----------------------------------------------------------------------------
        !             5:  * cksum -- compute ones complement of 16-bit ones complement checksum
        !             6:  *----------------------------------------------------------------------------
        !             7:  * This routine computes the one's complement of the 16 bit two's complement
        !             8:  * checksum of an array of words, and is thus suitable for computing the
        !             9:  * checksum of various levels of the DARPA InterNet protocols.
        !            10:  *
        !            11:  *  C Calling sequence:
        !            12:  *
        !            13:  *     check = cksum(&buf, nwords)
        !            14:  *
        !            15:  *  where arguments are declared as:
        !            16:  *
        !            17:  *     int     buf[];           array of words to be summed
        !            18:  *     int     nwords;          number of 16-bit words in buf
        !            19:  *     int     check;           returned value
        !            20: */
        !            21:  
        !            22:        .align  1
        !            23:        .text
        !            24:        .globl  _cksum
        !            25: _cksum:
        !            26:        .word   0x4                     /* save r2                      */
        !            27:        calls   $0, _ovfloff            /* clear overflow bit           */
        !            28:        movl    4(ap),  r1              /* r1 = address of buf          */
        !            29:        movl    8(ap),  r2              /* r2 = nwords                  */
        !            30:        clrl    r0
        !            31: loop:                                  /* no  ==> compute cksum        */
        !            32:        addw2   (r1)+,  r0
        !            33:        bcc     decrmnt                 /* no carry ==> continue        */
        !            34:        incw    r0                      /* add carry to r0              */
        !            35: decrmnt:
        !            36:        sobgtr  r2,     loop            /* not done? go back to loop    */
        !            37:        mcomw   r0,     r0              /* compute one's complement     */
        !            38:        ret

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.