2022-08-12 20:02:44 +00:00
|
|
|
%import textio
|
|
|
|
|
|
|
|
main {
|
|
|
|
sub crc32(uword data, uword length) {
|
|
|
|
; because prog8 doesn't have 32 bits integers, we have to split up the calucation over 2 words.
|
|
|
|
; result in cx16.r0 (high word) and cx1.r1 (low word).
|
|
|
|
cx16.r0 = 0
|
|
|
|
cx16.r1 = 0
|
|
|
|
repeat length {
|
|
|
|
cx16.r0 ^= @(data) << $0008
|
|
|
|
repeat 8 {
|
|
|
|
if cx16.r0 & $8000 {
|
|
|
|
sys.clear_carry()
|
|
|
|
rol(cx16.r1)
|
|
|
|
rol(cx16.r0)
|
|
|
|
cx16.r0 ^= $04c1
|
|
|
|
cx16.r1 ^= $1db7
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sys.clear_carry()
|
|
|
|
rol(cx16.r1)
|
|
|
|
rol(cx16.r0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data++
|
|
|
|
}
|
|
|
|
cx16.r0 ^= $ffff
|
|
|
|
cx16.r1 ^= $ffff
|
|
|
|
}
|
|
|
|
|
|
|
|
sub start() {
|
2023-09-05 19:44:03 +00:00
|
|
|
txt.print("calculating (expecting $e1fa84c6)...\n")
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.SETTIM(0,0,0)
|
2022-08-12 20:02:44 +00:00
|
|
|
crc32($e000, $2000)
|
|
|
|
txt.print_uwhex(cx16.r0, true)
|
|
|
|
txt.print_uwhex(cx16.r1, false)
|
|
|
|
txt.nl()
|
2023-04-28 21:13:03 +00:00
|
|
|
txt.print_uw(cbm.RDTIM16())
|
2022-08-12 20:02:44 +00:00
|
|
|
txt.print(" jiffies")
|
2023-09-05 19:44:03 +00:00
|
|
|
sys.wait(300)
|
2022-08-12 20:02:44 +00:00
|
|
|
}
|
|
|
|
}
|