mirror of
https://github.com/irmen/prog8.git
synced 2024-12-11 19:49:45 +00:00
31 lines
661 B
Lua
31 lines
661 B
Lua
%import textio
|
|
|
|
main {
|
|
|
|
sub crc16(uword data, uword length) -> uword {
|
|
uword crc = 0
|
|
repeat length {
|
|
crc ^= @(data) << $0008
|
|
repeat 8 {
|
|
if crc & $8000
|
|
crc = (crc<<1)^$1021
|
|
else
|
|
crc<<=1
|
|
}
|
|
data++
|
|
}
|
|
return crc
|
|
}
|
|
|
|
sub start() {
|
|
txt.print("calculating...")
|
|
c64.SETTIM(0,0,0)
|
|
uword crc = crc16($e000, $2000)
|
|
txt.print_uwhex(crc, true) ; should be $ffd0
|
|
txt.nl()
|
|
txt.print_uw(c64.RDTIM16())
|
|
txt.print(" jiffies")
|
|
sys.wait(100)
|
|
}
|
|
}
|