The following is a DX-FORTH script that can be
used to calculate the crc. Just plug in the
header values you wish to use.
\ TD0CRC.F
\ TD0 CRC header checksum calculator
\ Use: dx - include td0crc.f bye
empty forth definitions decimal application
hex
\ TD0 header data - 10 bytes
here
54 c, 44 c, 00 c, 5B c, 15 c, 80 c, 01 c, 80 c, 00 c, 02 c,
here over - 2constant HDR-DATA ( -- adr len )
\ TD0 header crc - 2 bytes lo|hi
create HDR-CRC ( -- adr )
0F c, 75 c,
decimal
\ Hex formatted numeric output
: (DH.N) ( ud n -- )
base @ >r hex <# 0 do # loop #> r> base ! ;
: (HW.) ( u -- a u ) 0 4 (dh.n) ;
: HW. ( u -- ) (hw.) type space ;
: TD0-CRC ( crc byt -- crc' )
>< xor 8 0 do dup 0< if 2* $A097 xor else 2* then loop ;
: get16 ( adr -- 16b )
dup c@ ( lo) swap 1+ c@ ( hi) 8 lshift + ;
: calc ( -- )
hdr-crc get16 cr ." CRC existing " hw.
0 hdr-data bounds do i c@ td0-crc loop ( crc)
cr ." CRC calculated " hw. ;
calc
\ end