CRC25 - kuidas ?
#25
(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
Vasta


Sõnumeid selles teemas
CRC25 - kuidas ? - Autor: felch - 26-01-2015, 10:52 PM
RE: CRC25 - kuidas ? - Autor: A.R. - 27-01-2015, 10:54 AM
RE: CRC25 - kuidas ? - Autor: felch - 27-01-2015, 05:04 PM
RE: CRC25 - kuidas ? - Autor: A.R. - 27-01-2015, 06:47 PM
RE: CRC25 - kuidas ? - Autor: A.R. - 28-01-2015, 05:09 PM
RE: CRC25 - kuidas ? - Autor: felch - 28-01-2015, 08:51 PM
RE: CRC25 - kuidas ? - Autor: felch - 28-01-2015, 11:09 PM
RE: CRC25 - kuidas ? - Autor: A.R. - 29-01-2015, 08:03 AM
RE: CRC25 - kuidas ? - Autor: felch - 29-01-2015, 08:42 AM
RE: CRC25 - kuidas ? - Autor: A.R. - 29-01-2015, 09:49 AM
RE: CRC25 - kuidas ? - Autor: felch - 29-01-2015, 11:38 AM
RE: CRC25 - kuidas ? - Autor: A.R. - 29-01-2015, 11:57 AM
RE: CRC25 - kuidas ? - Autor: A.R. - 29-01-2015, 07:00 PM
RE: CRC25 - kuidas ? - Autor: felch - 30-01-2015, 09:40 PM
RE: CRC25 - kuidas ? - Autor: madis - 30-01-2015, 11:46 PM
RE: CRC25 - kuidas ? - Autor: admin - 04-02-2015, 02:48 PM
RE: CRC25 - kuidas ? - Autor: A.R. - 04-02-2015, 05:28 PM
RE: CRC25 - kuidas ? - Autor: admin - 04-02-2015, 06:50 PM
RE: CRC25 - kuidas ? - Autor: A.R. - 04-02-2015, 08:50 PM
RE: CRC25 - kuidas ? - Autor: admin - 04-02-2015, 09:08 PM
RE: CRC25 - kuidas ? - Autor: felch - 04-02-2015, 11:36 PM
RE: CRC25 - kuidas ? - Autor: madis - 05-02-2015, 12:56 AM
RE: CRC25 - kuidas ? - Autor: A.R. - 05-02-2015, 08:35 AM
RE: CRC25 - kuidas ? - Autor: madis - 05-02-2015, 02:32 PM
RE: CRC25 - kuidas ? - Autor: felch - 05-02-2015, 05:17 PM

Alamfoorumi hüpe:


Kasutaja, kes vaatavad seda teemat: 1 külali(st)ne