I can't figure out, what algorithm was used in Unix V5 and V6 for the
$ python -c 'print(sum(bytearray(b"1111111111\n"*320)) & 0xFFFF)' 28928
Later, from the MacOS man pages, I found out that the
cksum commands had a long history of inconsistencies. However, even the "historic" algorithm versions provided on MacOS don't agree with the Unix V5's checksum. The closest match is the default
sum command of UNIX System V (invoked on Mac like
cksum -o 2), which returns the same checksum for this string, but disagrees for others:
$ python -c 'print("1111111111\n"*320, end="")' | cksum -o 2 28930 7
To be more specific, the
cksum -o 2 and Unix V5's
sum produce different output for most binary files in the emulator (for example, in folder
/bin), though they agree on most text files.
Is this a genuine behavior or a bug in the emulator? If it is genuine, what algorithm is it?
P.S. Here is the source code, if anyone can read assembly code from 1974.