1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-26 15:08:05 +11:00
collapseos/blk/377

17 lines
376 B
Plaintext
Raw Normal View History

2020-04-24 03:55:00 +10:00
( c n -- c )
( Computes n into crc c with polynomial 0x1021 )
: _crc16
SWAP DUP 256 / ( n c c>>8 )
ROT XOR ( c x )
DUP 16 / XOR ( c x^x>>4 )
SWAP 256 * ( x c<<8 )
OVER 4096 * XOR ( x c^x<<12 )
OVER 32 * XOR ( x c^x<<5 )
XOR ( c )
;
( send-and-crc7 )
( n c -- c )
: _s+crc SWAP DUP _sdcSR DROP _crc7 ;