05-02-2015, 05:17 PM
(Seda postitust muudeti viimati: 05-02-2015, 06:40 PM ja muutjaks oli madis.)
(05-02-2015, 02:32 PM)madis Kirjutas: Lõppsõnaks ütleks:
main(a,b)char**b;{int c=1,d=c,e=a-d;for(;e;e--)_(e)<_( c)?c=e:_(e)>_(d)?d=e:7;
while(++e<a)printf("\xe2\x96%c",129+(**b=8*(_(e)-_( c))/(_(d)-_( c))));}
HELL YEAH !
Maybe...
Ma sain vahepeal asmi rutiini tööle. Tänud ideede eest !
Kood:
;===============================================================================
; CRC 1 baidi arvutamise algo
;#define X25_INIT_CRC 0xffff
; tmp=data ^ (*crcAccum &0xff);
; tmp^= (tmp<<4);
; tmp &= (0x00ff);
; *crcAccum = (*crcAccum>>8) ^ (tmp<<8) ^ (tmp <<3) ^ (tmp>>4);
; result= (*crcAccum);
; näidis testjada:
; http://www.privatprojekte.de/multicopter/telemetriedecoder.html
;FE 09 4E 01 01 00 00 00 00 00 02 03 51 04 03 1C 7F + 32
; ülalolev testjada laadida aadressile 0x20 ja edaspidi
; 0xFE jätta välja
; CRC=0x7F1C
; enne viimast tehet lasta CRC-st läbi bait 0x32 (magic byte ehk seed)
; funkab küll !!!
#define crcH TBLPTRHt
#define crcL TBLPTRLt
#define tmpH tempor0_h
#define tmpL tempor0_l
#define tmpHa t1_count
#define tmpLa t2_count
test: movlw 0xFF ; crc_init(&crcTmp)
movwf TBLPTRLt
movwf TBLPTRHt
clrf tmpH
clrf tmpL
movlw .15
movwf t_count
LFSR .0,0x20
tst1: movf POSTINC0,W ; loe databait puhvrist -> W
xorwf crcL,W ; databait XOR CRC LOW -> tmp=data ^ (*crcAccum &0xff);
movwf tmpL
movff tmpH,tmpHa ; säilita algne tmp
movff tmpL,tmpLa
bcf CARRY ; (tmp<<4)
rlcf tmpL,F
rlcf tmpH,F
bcf CARRY
rlcf tmpL,F
rlcf tmpH,F
bcf CARRY
rlcf tmpL,F
rlcf tmpH,F
bcf CARRY
rlcf tmpL,F
rlcf tmpH,F
movf tmpHa,W ; XOR
xorwf tmpH,F
movf tmpLa,W
xorwf tmpL,F
clrf tmpH ; tmp &= (0x00ff)
; *crcAccum = (*crcAccum>>8) ^ (tmp<<8) ^ (tmp <<3) ^ (tmp>>4);
movff tmpH,tmpHa ; tee tmp-st koopia
movff tmpL,tmpLa
bcf CARRY ; crcAccum>>8
rrcf crcH,F
rrcf crcL,F
bcf CARRY
rrcf crcH,F
rrcf crcL,F
bcf CARRY
rrcf crcH,F
rrcf crcL,F
bcf CARRY
rrcf crcH,F
rrcf crcL,F
bcf CARRY
rrcf crcH,F
rrcf crcL,F
bcf CARRY
rrcf crcH,F
rrcf crcL,F
bcf CARRY
rrcf crcH,F
rrcf crcL,F
bcf CARRY
rrcf crcH,F
rrcf crcL,F
bcf CARRY ; tmp= (tmp<<8)
rlcf tmpLa,F
rlcf tmpHa,F
bcf CARRY
rlcf tmpLa,F
rlcf tmpHa,F
bcf CARRY
rlcf tmpLa,F
rlcf tmpHa,F
bcf CARRY
rlcf tmpLa,F
rlcf tmpHa,F
bcf CARRY
rlcf tmpLa,F
rlcf tmpHa,F
bcf CARRY
rlcf tmpLa,F
rlcf tmpHa,F
bcf CARRY
rlcf tmpLa,F
rlcf tmpHa,F
bcf CARRY
rlcf tmpLa,F
rlcf tmpHa,F
movf tmpHa,W ; XOR
xorwf crcH
movf tmpLa,W
xorwf crcL
movff tmpH,tmpHa ; loe algne tmp
movff tmpL,tmpLa
bcf CARRY ; tmp= (tmp<<3)
rlcf tmpLa,F
rlcf tmpHa,F
bcf CARRY
rlcf tmpLa,F
rlcf tmpHa,F
bcf CARRY
rlcf tmpLa,F
rlcf tmpHa,F
movf tmpHa,W ; XOR
xorwf crcH
movf tmpLa,W
xorwf crcL
movff tmpH,tmpHa ; loe algne tmp
movff tmpL,tmpLa
bcf CARRY ; tmp= (tmp>>4)
rrcf tmpHa,F
rrcf tmpLa,F
bcf CARRY
rrcf tmpHa,F
rrcf tmpLa,F
bcf CARRY
rrcf tmpHa,F
rrcf tmpLa,F
bcf CARRY
rrcf tmpHa,F
rrcf tmpLa,F
movf tmpHa,W ; XOR
xorwf crcH
movf tmpLa,W
xorwf crcL
decfsz t_count
goto tst1 ; loop until "iso siiperi"
return