mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-26 15:08:05 +11:00
17 lines
376 B
Plaintext
17 lines
376 B
Plaintext
|
( 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 ;
|
||
|
|