1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 12:48:05 +11:00

sdc: implement _crc16 in z80

This commit is contained in:
Virgil Dupras 2020-04-24 20:46:01 -04:00
parent 8d78ca9dac
commit 5219887ad7
4 changed files with 19 additions and 23 deletions

View File

@ -10,4 +10,5 @@
0xe6 OP2n ANDn,
0xf6 OP2n ORn,
0xd6 OP2n SUBn,
0xee OP2n XORn,

23
blk/373
View File

@ -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
View File

@ -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 ;

View File

@ -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