mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 09:48:05 +11:00
sdc: implement _crc16 in z80
This commit is contained in:
parent
8d78ca9dac
commit
5219887ad7
23
blk/373
23
blk/373
@ -1,9 +1,16 @@
|
||||
CODE _sdcSel
|
||||
SDC_CSLOW OUTnA,
|
||||
CODE _sdcSel SDC_CSLOW OUTnA, ;CODE
|
||||
CODE _sdcDesel SDC_CSHIGH OUTnA, ;CODE
|
||||
( Computes n into crc c with polynomial 0x1021 )
|
||||
CODE _crc16 ( c n -- c )
|
||||
HL POPqq, ( n ) DE POPqq, ( c )
|
||||
A L LDrr, D XORr, D A LDrr,
|
||||
B 8 LDrn,
|
||||
BEGIN,
|
||||
E SLAr, D RLr,
|
||||
IFC, ( msb is set, apply polynomial )
|
||||
A D LDrr, 0x10 XORn, D A LDrr,
|
||||
A E LDrr, 0x21 XORn, E A LDrr,
|
||||
THEN,
|
||||
DJNZ, AGAIN,
|
||||
DE PUSHqq,
|
||||
;CODE
|
||||
|
||||
CODE _sdcDesel
|
||||
SDC_CSHIGH OUTnA,
|
||||
;CODE
|
||||
|
||||
|
||||
|
12
blk/377
12
blk/377
@ -1,15 +1,3 @@
|
||||
( 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 ;
|
||||
|
@ -5,6 +5,6 @@
|
||||
372 LOAD ( sdc.z80 )
|
||||
374 LOAD ( sdc.fs )
|
||||
|
||||
0x0000 0x0000 _crc16 0x0000 #eq
|
||||
0x0000 0x0001 _crc16 0x1021 #eq
|
||||
0x5678 0x1234 _crc16 0x43c4 #eq
|
||||
0x0000 0x00 _crc16 0x0000 #eq
|
||||
0x0000 0x01 _crc16 0x1021 #eq
|
||||
0x5678 0x34 _crc16 0x34e4 #eq
|
||||
|
Loading…
Reference in New Issue
Block a user