changed math.crc16() to now also take an initvalue and xorout value, to make it more flexible in calculating various variants of CRC16 checksums

This commit is contained in:
Irmen de Jong
2026-02-28 18:13:00 +01:00
parent fedf342cee
commit 0a52cd2cee
11 changed files with 121 additions and 116 deletions
@@ -1,6 +1,6 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
Prerelease version from git commit fedf342c in branch master
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-c128.p8
@@ -284,13 +284,12 @@ math {
cos8u (ubyte angle @A) clobbers (Y) -> ubyte @A
cosr8 (ubyte radians @A) clobbers (Y) -> byte @A
cosr8u (ubyte radians @A) clobbers (Y) -> ubyte @A
crc16 (^^ubyte data, uword length) -> uword
crc16_end () -> uword
crc16_start ()
crc16 (^^ubyte data, uword length, uword initvalue, uword xorout) -> uword
crc16_end (uword xorout) -> uword
crc16_start (uword initvalue)
crc16_update (ubyte value @A)
crc32 (^^ubyte data, uword length) -> long
crc32_end () -> long
crc32_end_result () -> long @R14R15
crc32_end () -> long @R14R15
crc32_start ()
crc32_update (ubyte value)
diff (ubyte v1 @A, ubyte v2 @Y) -> ubyte @A
@@ -1,6 +1,6 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
Prerelease version from git commit fedf342c in branch master
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-c64.p8
@@ -411,13 +411,12 @@ math {
cos8u (ubyte angle @A) clobbers (Y) -> ubyte @A
cosr8 (ubyte radians @A) clobbers (Y) -> byte @A
cosr8u (ubyte radians @A) clobbers (Y) -> ubyte @A
crc16 (^^ubyte data, uword length) -> uword
crc16_end () -> uword
crc16_start ()
crc16 (^^ubyte data, uword length, uword initvalue, uword xorout) -> uword
crc16_end (uword xorout) -> uword
crc16_start (uword initvalue)
crc16_update (ubyte value @A)
crc32 (^^ubyte data, uword length) -> long
crc32_end () -> long
crc32_end_result () -> long @R14R15
crc32_end () -> long @R14R15
crc32_start ()
crc32_update (ubyte value)
diff (ubyte v1 @A, ubyte v2 @Y) -> ubyte @A
@@ -1,6 +1,6 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
Prerelease version from git commit fedf342c in branch master
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-cx16.p8
@@ -587,13 +587,12 @@ math {
cos8u (ubyte angle @A) clobbers (Y) -> ubyte @A
cosr8 (ubyte radians @A) clobbers (Y) -> byte @A
cosr8u (ubyte radians @A) clobbers (Y) -> ubyte @A
crc16 (^^ubyte data, uword length) -> uword
crc16_end () -> uword
crc16_start ()
crc16 (^^ubyte data, uword length, uword initvalue, uword xorout) -> uword
crc16_end (uword xorout) -> uword
crc16_start (uword initvalue)
crc16_update (ubyte value @A)
crc32 (^^ubyte data, uword length) -> long
crc32_end () -> long
crc32_end_result () -> long @R14R15
crc32_end () -> long @R14R15
crc32_start ()
crc32_update (ubyte value)
diff (ubyte v1 @A, ubyte v2 @Y) -> ubyte @A
@@ -1,6 +1,6 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
Prerelease version from git commit fedf342c in branch master
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-pet32.p8
@@ -348,13 +348,12 @@ math {
cos8u (ubyte angle @A) clobbers (Y) -> ubyte @A
cosr8 (ubyte radians @A) clobbers (Y) -> byte @A
cosr8u (ubyte radians @A) clobbers (Y) -> ubyte @A
crc16 (^^ubyte data, uword length) -> uword
crc16_end () -> uword
crc16_start ()
crc16 (^^ubyte data, uword length, uword initvalue, uword xorout) -> uword
crc16_end (uword xorout) -> uword
crc16_start (uword initvalue)
crc16_update (ubyte value @A)
crc32 (^^ubyte data, uword length) -> long
crc32_end () -> long
crc32_end_result () -> long @R14R15
crc32_end () -> long @R14R15
crc32_start ()
crc32_update (ubyte value)
diff (ubyte v1 @A, ubyte v2 @Y) -> ubyte @A
@@ -1,6 +1,6 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
Prerelease version from git commit fedf342c in branch master
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-virtual.p8
@@ -270,9 +270,9 @@ math {
cos8u (ubyte angle) -> ubyte
cosr8 (ubyte radians) -> byte
cosr8u (ubyte radians) -> ubyte
crc16 (^^ubyte data, uword length) -> uword
crc16_end () -> uword
crc16_start ()
crc16 (^^ubyte data, uword length, uword initvalue, uword xorout) -> uword
crc16_end (uword xorout) -> uword
crc16_start (uword initvalue)
crc16_update (ubyte value)
crc32 (^^ubyte data, uword length) -> long
crc32_end () -> long