mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-27 09:08:05 +11:00
124da6adec
Although the SPI Relay driver is RC2014-specific, the SD Card driver is generic enough to be a subsystem. That's the second subsystem we add and this warrants, I think, the formalization of a new concept: protocols.
15 lines
409 B
Plaintext
15 lines
409 B
Plaintext
( Computes n into crc c with polynomial 0x1021 )
|
|
CODE _crc16 ( c n -- c ) EXX, ( protect BC )
|
|
HL POP, ( n ) DE POP, ( c )
|
|
A L LDrr, D XORr, D A LDrr,
|
|
B 8 LDri,
|
|
BEGIN,
|
|
E SLA, D RL,
|
|
IFC, ( msb is set, apply polynomial )
|
|
A D LDrr, 0x10 XORi, D A LDrr,
|
|
A E LDrr, 0x21 XORi, E A LDrr,
|
|
THEN,
|
|
DJNZ, AGAIN,
|
|
DE PUSH,
|
|
EXX, ( unprotect BC ) ;CODE
|