please dont rip this site
#include <stdio.h>


/********************************************************************
 
  CRC-16  (x^16+x^15+x^2+x^0)
  No tables, No jumps.
 
  Input:  c = Data byte for CRC calculation
          usp_crc = pointer to 16 bit CRC register
 
  Output: CRC at pointer usp_crc is updated
 
 
  Copyright (C) February 11, 2000. All Right Reserved.
  Charles Ader, PO Box 940 Pleasanton, California, USA.
 
  This code started out as an example program found in 
  Dallas Semiconductor Application Note 27:
 
    Understanding and Using Cyclic Redundancy Checks 
    with Dallas Semiconductor iButton(TM) Products. 
 
  The application note shows an 8051 assembly language 
  routine that calculates the same CRC as the hardware 
  in the DS5001/2 secure micro.
 
********************************************************************/
void crc16(unsigned short *usp_crc, unsigned char c)
{
unsigned short crc;     /* use a local temp so the compiler will */
                        /* handle all the x86 pointer crap.      */
    crc = *usp_crc;

    _asm {
        mov     al,c
        mov     cx,crc

        XOR     AL,CL
        MOV     CL,CH
        MOV     CH,AL
	
        LAHF
        NOT     AH
        RCR     AH,1
        RCR     AH,1
        AND     AH,1
        XOR     CL,AH

        RCR     AX,1
        SBB     AH,AH
        AND     AH,0x40
        XOR     CL,AH

        MOV     AH,AL
        XOR     AL,CH
        RCL     AH,1
        RCR     AL,1
        MOV     CH,AL
        RCR     AL,1
        AND     AL,0x80
        XOR     CL,AL

        mov     crc,cx
    }
    *usp_crc = crc;
}

/******************************************************
*         MAIN FUNCTION                               *
*******************************************************/

main()
{
unsigned int crc;
    while(1) {
        crc = 0;          /* crc = 0x0000 */
        crc16(&crc,0x80); /* crc = 0xA001 */
        crc16(&crc,0x75); /* crc = 0x27A0 */
        crc16(&crc,0x8A); /* crc = 0xDFA6 */
        crc16(&crc,0x0B); /* crc = 0xBD1E */
        crc16(&crc,0x75); /* crc = 0xEFFC */
        crc16(&crc,0xC7); /* crc = 0xD3AE */
        crc16(&crc,0xAA); /* crc = 0xC3D2 */
        crc16(&crc,0x75); /* crc = 0xBA82 */
        crc16(&crc,0xC7); /* crc = 0xF37B */
        crc16(&crc,0x55); /* crc = 0x1C73 */
        crc16(&crc,0x43); /* crc = 0x141C */
        crc16(&crc,0x1C); /* crc = 0x0014 */
        crc16(&crc,0x14); /* crc = 0x0000 */
    }
} /* end of main */

file: /Techref/intel/16bit/crc16.htm, 2KB, , updated: 2000/2/23 08:46, local time: 2024/11/28 15:08,
TOP NEW HELP FIND: 
3.145.92.98: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://sxlist.com/techref/intel/16bit/crc16.htm"> intel 16bit 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 sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .