MOA CRC

ZXNet echo conference «code.zx»

From Stanislav Udin To All 29 July 2001

Hello everyone! Here I slightly corrected the procedure that Kirill proposed, so that the table it turned out like MOA, but for some reason I can’t speed it up any more, although I feel like this can be done: D.I. LD HL,CRC_TAB LD C,0 BYTE LD E,0 LD D,C DEC D LD B,8 EX DE,HL NBIT ADD HL,HL JR C,NXOR LD A,L XOR #21 ;Here and below it’s faster to tinker with the contents ;register, but there are not enough registers :( LD L,A LD A,H XOR #10 LD H,A NXOR DJNZ NBIT EX DE,HL LD(HL),D INC HL LD(HL),E INC HL DEC C JR NZ,BYTE RET CRC_TAB DEFS 512.0 Is it possible to speed up the MOA procedure? ;Cyclic Redundancy Check. ;Calculation of checksum. ;IN : [DE] - START, [BC] - LENGHT ;OUT: [DE] - CRC-SUMM. CRC LD HL,#FFFF PUSH IX PUSH DE POP IX EX DE,HL CRC_1 LD HL,CRC_TAB LD A,(IX) INC IX XOR E ADD A,L LD L,A JR NC,CRC_2 INC H CRC_2 LD A,D XOR (HL) LD E,A INC HL XOR A XOR (HL) LD D,A DEC B.C. LD A,C OR B JR NZ,CRC_1 POP IX RET The procedures will always be used in pairs, that is, the table will be generated first,and then immediately calculate the CRC. Maybe these procedures can be combined and speed up this common conglomerate? Only 508 bytes will need to be processed. Stanislav

From Kirill Frolov To Stanislav Udin 30 July 2001

Press RESET immediately, Stanislav! 29 Jul 01 22:25, Stanislav Udin wrote to All: SU> I slightly corrected the procedure that Kirill proposed, so that SU> the table turned out like MOA's, but for some reason it doesn't work out for me anymore SU> speed up, although I feel it can be done: You need to think about algorithmic optimization, not about code. SU> LD H,A SU> NXOR DJNZ NBIT SU> EX DE,HL SU> LD (HL),D SU> INC HL SU> LD (HL),E SU> INC HL SU> - DEC C + INC C +LD A, C +CP 129 SU> JR NZ,BYTE SU> RET SU> CRC_TAB DEFS 512.0 CRC_TAB DEFS 258, 0 SU> CRC_1 LD HL,CRC_TAB SU> LD A,(IX) SU> INC IX SU> XOR E + ADD A, A + JR NC, $+3 +INC H SU> ADD A,L SU> LD L,A ^^^^^^^^^^Here's the error. Because of it, more than 257 bytes in the table are not used. SU> JR NC,CRC_2 SU> INC H SU> CRC_2 LD A,D