prog8/examples/bench8/crc16.p8
Irmen de Jong e35cfd4971 get rid of the redundant 'f' suffix of several funtions in floats module (breaking change!)
Unfortunately a few routines (minf, maxf, clampf) remain unchanged, because removing the 'f' would make them clash with a builtin function.

floats.rndf -> floats.rnd
floats.parse_f -> floats.parse
floats.rndseedf -> floats.rndseed
floats.print_f -> floats.print
floats.str_f -> floats.tostr
2023-12-29 03:12:44 +01:00

33 lines
761 B
Lua

%import textio
%import floats
main {
sub crc16(uword data, uword length) -> uword {
uword crc = 0
repeat length {
crc ^= mkword(@(data), 0)
repeat 8 {
if crc & $8000
crc = (crc<<1)^$1021
else
crc<<=1
}
data++
}
return crc
}
sub start() {
txt.print("calculating (expecting $ffd0)...\n")
txt.print(" if mismatch: first check if kernal is maybe updated?\n")
cbm.SETTIM(0,0,0)
uword crc = crc16($e000, $2000)
txt.print_uwhex(crc, true)
txt.nl()
floats.print(cbm.RDTIM16() / 60.0)
txt.print(" seconds")
sys.wait(9999)
}
}