;_______________________________________________ ; CRC8 computing functions ; Polynome x^8 + x^5 + x^4 + x^0 ->8C CRC-8-Dallas/Maxim ; x^8 + x^7 + x^4 + x^3 + x + 1 ->D9 CRC-8-WCDMA ;_______________________________________________ ;_______________________________________________ ; Code segment ;_______________________________________________ ;.cseg ;Sortie R20 crc ;Entrée R18 DATA ;Compeur R17 Count ;Général R16 A ; R19 temp ;_______________________________________________ ; Update crc value ;_______________________________________________ CRC8Update: push A push count push DATA push temp ldi temp, 0x8C ldi count, 8 ;pour boucle 8 bits CRC8L: mov A,DATA ;ODD=DATA eor A,crc ;ODD=ODD^CRC lsr crc ;CRC>>1 lsr DATA ;DATA>>1 sbrc A, 0 ;Saute si bit0 de ODD=0 eor crc, temp ;CRC^0x8C dec count ;dec pour boucle brne CRC8L ;continue la boucle si count<0 pop temp pop DATA pop count pop A ret ;_______________________________________________ ; Clear crc value ;_______________________________________________ CRC8Init: ldi crc ,0 ret ;_______________________________________________ ; Copy crc value to DATA ;_______________________________________________ GetCRC8: mov DATA,crc ret ;_______________________________________________ ; End of crc8.inc file ;_______________________________________________