.title Header Checksum Routines ; DECUS C Calling Format ; ; jsr r5,csv$ ;save r2,r3, and r4 ; ;r5 is parameter base ; ;c$pmtr(r5) is first argument ; ;c$pmtr+2(r5) is second argument ; ;... ; ;return args in r0 ; ... ; user code ; ... ; ; jmp cret$ ;restore r2-r5 and return ; rts pc ;does the same (cret$ follows csv$) ; ; csv$ and cret$ need be used only if arguments are used ; ; ; Macro routines for special functions ; .psect c$code ; ; Internet header checksum ; header checksum is calculated for ; a higher level program to verify ; ; USAGE: ipcheck((IPKT *)ptr,(int)len_in_words) ; ipcheck:: jsr r5,csv$ mov c$pmtr(r5),r2 ;buffer address mov c$pmtr+2(r5),r1 ;word count clr r0 ;checksum 1$: add (r2)+,r0 ;build checksum adc r0 dec r1 bne 1$ com r0 ;complement rts pc ; ; TCP checksum ; header checksum is calculated for ; a higher level program to verify ; includes support for a pseudo-header ; ; USAGE: tcpcheck((TCPKT *)psptr, ; (TCPKT *)tcpptr,(int)len_in_bytes) ; tcpcheck:: jsr r5,csv$ mov c$pmtr(r5),r2 ;psuedo header address mov #6,r1 ;word count clr r0 ;checksum 1$: add (r2)+,r0 ;build checksum adc r0 dec r1 bne 1$ mov c$pmtr+2(r5),r2 ;tcp buffer address mov c$pmtr+4(r5),r3 ;byte count mov r3,r1 asr r1 ;word count 2$: add (r2)+,r0 ;continue with checksum adc r0 dec r1 bne 2$ ror r3 ;odd number of bytes ? bcc 3$ ;no - skip clr r3 ;else process last byte bisb (r2),r3 add r3,r0 adc r0 3$: com r0 ;complement rts pc .end