DIRECTORY ; Checksum: DEFINITIONS = BEGIN ComputeChecksum: PROC [ cs: CARD16 _ 0, nHalfWords: CARDINAL, p: POINTER] RETURNS [checksum: CARD16] = ComputeChecksumProc[cs, nHalfWords, p]; ComputeChecksumSoftware: PRIVATE PROC [ cs: CARD16 _ 0, nHalfWords: CARDINAL, p: POINTER] RETURNS [checksum: CARD16] = INLINE { FOR i: CARDINAL IN [0..nWords) DO t: CARD16; w: CARD16 = IF ODD[i] THEN LOOPHOLE[p^, Basics.LongNumber].lo ELSE LOOPHOLE[p^, Basics.LongNumber].hi; IF cs > (t _ cs + w) THEN cs _ t + 1 ELSE cs _ t; IF cs >= 100000B THEN cs _ cs*2 + 1 ELSE cs _ cs*2; IF ODD[i] THEN p _ p + 1; ENDLOOP; IF cs = 177777B THEN cs _ 0; RETURN[cs]; }; ComputeChecksumProc: PRIVATE PROC [ cs: CARD16 _ 0, nHalfWords: CARDINAL, p: POINTER] RETURNS [checksum: CARD16] = { NYI[] }; END. 4Checksum.mesa For Dragon Copyright c 1985 by Xerox Corporation. All rights reserved. Forrest, October 4, 1980 2:03 PM Russ Atkinson (RRA) January 29, 1985 0:37:17 am PST Doug Wyatt, February 26, 1985 2:50:29 pm PST Carl Hauser, October 28, 1986 11:51:28 am PST ... produces a checksum for nWords starting at p. Start with initial value cs (useful if forming a single checksum for discontinuous areas of memory). Note that since these checksums must agree with those computed in the existing world they are 16 bit checksums computed over an integral number of 16 bit halfwords, even though Dragon is a 32 bit machine. I would like to add a mathematical definition of the checksum being computed-- chh. ComputeChecksumSoftware is provided as documentation. As written here, it requires that the sequence of halfwords to be checksummed begin on a word boundary. To do otherwise requires another Boolean argument for the 33rd (low order) address bit. cs _ ((cs ONESADD p^) LEFTROTATE 1) ComputeChecksumProc is machine code that efficiently implements the above. Κΰ˜codešœ ™ KšΠbl ™ Kšœ Οmœ1™