please dont rip this site
; 
; From Dallas Application note 27
;
; CRC-16  (x^16+x^15+x^2+x^0)
; No tables, No loops, No temporary registers used.
;
; This code is from Dallas Semiconductor Application Note 27:
;
;   Understanding and Using Cyclic Redundancy Checks 
;   with Dallas Semiconductor iButton(TM) Products. 
;
; This routine that calculates the same CRC as the hardware 
; in the DS5001/2 secure micro.
;-----------------------------------------------------------------------
        NAME    CRC_test

?DT?CRC_test SEGMENT DATA
	rseg	?DT?CRC_test
CRCH:   ds      1
CRCL:   ds      1


?CO?CRC_test	SEGMENT	CODE
	RSEG	?CO?CRC_test

        public  CRC_test
	
CRC_test:

        mov     CRCH,#0
        mov     CRCL,#0
	
        mov     A,#080H
        call    CRC16

        mov     A,#075H
        call    CRC16
	
        mov     A,#08AH
        call    CRC16

        mov     A,#00BH
        call    CRC16

        mov     A,#075H
        call    CRC16

        mov     A,#0C7H
        call    CRC16

        mov     A,#0AAH
        call    CRC16

        mov     A,#075H
        call    CRC16

        mov     A,#0C7H
        call    CRC16

        mov     A,#055H
        call    CRC16

        mov     A,#043H
        call    CRC16

        ljmp    CRC_test


;CALCULATE CRC16 IN PARALLEL TO THE GREATEST EXTENT PRACTICAL
;       INPUT:  BYTE TO BE INCUDED IN CRC CALCULATION IS IN ACC
;       OUTPUT: CRCH:CRCL UPDATED TO INCLUDE THE NEW BYTE
;
CRC16:  
        PUSH    ACC                     ;save this in case the caller needs it
        XRL     A,CRCL
        MOV     CRCL,CRCH               ;put the high byte of the crc in its dest..
        MOV     CRCH,A                  ;save data xor low(crc) for later
        MOV     C,P
        JNC     CRC0
        XRL     CRCL,#001H

CRC0:   
        RRC     A                       ;get the low bit in c
        JNC     CRC1
        XRL     CRCL,#040H

CRC1:   
        MOV     C,ACC.7
        XRL     A,CRCH                  ;compute the results for bits P...U
        RRC     A                       ;shift them into place
        MOV     CRCH,A                  ;and save them
        JNC     CRC2
        XRL     CRCL,#080H

CRC2:   
        POP     ACC                     ;and restore everything and return
        RET

        end


file: /Techref/8051/crc16.htm, 2KB, , updated: 2001/4/17 09:21, local time: 2024/12/18 08:45,
TOP NEW HELP FIND: 
3.16.75.224:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/techref/8051/crc16.htm"> 8051 crc16</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .