prog8/examples/bench8/crc8.p8

33 lines
741 B
Plaintext
Raw Normal View History

2022-08-12 20:02:44 +00:00
%import textio
2023-09-05 20:59:36 +00:00
%import floats
2022-08-12 20:02:44 +00:00
main {
sub crc8(uword data, uword length) -> ubyte {
ubyte crc = 0
repeat length {
crc ^= @(data)
repeat 8 {
if crc & $80
crc = (crc<<1)^$1d
else
crc<<=1
}
data++
}
return crc
}
sub start() {
txt.print("calculating (expecting $a2)...\n")
txt.print(" if mismatch: first check if kernal is maybe updated?\n")
cbm.SETTIM(0,0,0)
2022-08-12 20:02:44 +00:00
ubyte crc = crc8($e000, $2000)
txt.print_ubhex(crc, true)
2022-08-12 20:02:44 +00:00
txt.nl()
floats.print(cbm.RDTIM16() / 60.0)
2023-09-05 20:59:36 +00:00
txt.print(" seconds")
sys.wait(9999)
2022-08-12 20:02:44 +00:00
}
}