1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-26 04:38:06 +11:00
collapseos/blk/603
Virgil Dupras e4a4a9800d z80: Use BC as IP register instead of IY
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.
2020-07-06 23:31:00 -04:00

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