1 /* BEGIN INCLUDE FILE gtss_checksum.incl.pl1 */
 2 
 3 checksum: proc (p, n) returns (bit (36)aligned);
 4 
 5 /* Calculate checksum of "n" words pointed to by "p".
 6 
 7    Author: Al Kepner 1978
 8    Change: Al Dupuis 09/24/79 Added an extra add after do loop in case carry was generated.
 9 */
10 dcl  p                        ptr parm;
11 dcl  n                        fixed bin (18)parm;
12 
13 /* Calculate the checksum for n words starting at p */
14 
15           a = 0;
16           do i = 1 to n;
17                b = fixed (array (i), 36) + fixed (sum, 36) + fixed (carry, 1);
18                a = b;
19           end;
20           b = fixed (sum, 36) + fixed (carry, 1); /* last add may have generated carry */
21           a = b;
22           return (sum);
23 
24 dcl  a                        fixed bin(71);
25 dcl  b                        fixed bin(71);
26 dcl  i                        fixed bin(24);
27 dcl  array                    (n) bit (36) based (p);
28 dcl 1 a_overlay aligned based (addr (a)),
29     2 fill bit (35) unal,
30     2 carry bit (1) unal,
31     2 sum bit (36);
32 
33      end checksum;
34 
35 /*   END INCLUDE FILE gtss_checksum.incl.pl1 */