mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-06 01:30:55 +11:00
e4a4a9800d
It's a bit more inconvenient in terms of register protection (BC is much more generally useful than IY), but it makes tight spots such as next and execute much faster, so I think it's worth it.
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
|