📄 fastcrc8.lst
字号:
C51 COMPILER V7.06 FASTCRC8 04/13/2005 12:55:51 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE FASTCRC8
OBJECT MODULE PLACED IN fastcrc8.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE fastcrc8.c OMF2 BROWSE INCDIR(..\..\..\..\Include;..\..\..\..\lib) DEFINE(F
-REQ433) DEBUG
stmt level source
1 /*****************************************************************************
2 * *
3 * ********** *
4 * ************ *
5 * *** *** *
6 * *** +++ *** *
7 * *** + + *** *
8 * *** + CHIPCON CC1010 *
9 * *** + + *** CUL - fastcrc *
10 * *** +++ *** *
11 * *** *** *
12 * *********** *
13 * ********* *
14 * *
15 *****************************************************************************
16 * *
17 *****************************************************************************
18 * Author: JOL *
19 *****************************************************************************
20 * Revision history: *
21 * *
22 * $Log: fastcrc8.c,v $
23 * Revision 1.1 2002/10/14 12:26:12 tos
24 * Initial version in CVS.
25 *
26 * *
27 ****************************************************************************/
28
29
30 #include <chipcon/cul.h>
31
32
33 //----------------------------------------------------------------------------
34 // CRC-8 LUT
35 // newCRC = crc8LUT[dataByte ^ oldCRC]
36 //----------------------------------------------------------------------------
37 byte code crc8LUT[256] = {
38 0x00, 0x18, 0x30, 0x28, 0x60, 0x78, 0x50, 0x48,
39 0xC0, 0xD8, 0xF0, 0xE8, 0xA0, 0xB8, 0x90, 0x88,
40 0x98, 0x80, 0xA8, 0xB0, 0xF8, 0xE0, 0xC8, 0xD0,
41 0x58, 0x40, 0x68, 0x70, 0x38, 0x20, 0x08, 0x10,
42 0x28, 0x30, 0x18, 0x00, 0x48, 0x50, 0x78, 0x60,
43 0xE8, 0xF0, 0xD8, 0xC0, 0x88, 0x90, 0xB8, 0xA0,
44 0xB0, 0xA8, 0x80, 0x98, 0xD0, 0xC8, 0xE0, 0xF8,
45 0x70, 0x68, 0x40, 0x58, 0x10, 0x08, 0x20, 0x38,
46 0x50, 0x48, 0x60, 0x78, 0x30, 0x28, 0x00, 0x18,
47 0x90, 0x88, 0xA0, 0xB8, 0xF0, 0xE8, 0xC0, 0xD8,
48 0xC8, 0xD0, 0xF8, 0xE0, 0xA8, 0xB0, 0x98, 0x80,
49 0x08, 0x10, 0x38, 0x20, 0x68, 0x70, 0x58, 0x40,
50 0x78, 0x60, 0x48, 0x50, 0x18, 0x00, 0x28, 0x30,
51 0xB8, 0xA0, 0x88, 0x90, 0xD8, 0xC0, 0xE8, 0xF0,
52 0xE0, 0xF8, 0xD0, 0xC8, 0x80, 0x98, 0xB0, 0xA8,
53 0x20, 0x38, 0x10, 0x08, 0x40, 0x58, 0x70, 0x68,
54 0xA0, 0xB8, 0x90, 0x88, 0xC0, 0xD8, 0xF0, 0xE8,
C51 COMPILER V7.06 FASTCRC8 04/13/2005 12:55:51 PAGE 2
55 0x60, 0x78, 0x50, 0x48, 0x00, 0x18, 0x30, 0x28,
56 0x38, 0x20, 0x08, 0x10, 0x58, 0x40, 0x68, 0x70,
57 0xF8, 0xE0, 0xC8, 0xD0, 0x98, 0x80, 0xA8, 0xB0,
58 0x88, 0x90, 0xB8, 0xA0, 0xE8, 0xF0, 0xD8, 0xC0,
59 0x48, 0x50, 0x78, 0x60, 0x28, 0x30, 0x18, 0x00,
60 0x10, 0x08, 0x20, 0x38, 0x70, 0x68, 0x40, 0x58,
61 0xD0, 0xC8, 0xE0, 0xF8, 0xB0, 0xA8, 0x80, 0x98,
62 0xF0, 0xE8, 0xC0, 0xD8, 0x90, 0x88, 0xA0, 0xB8,
63 0x30, 0x28, 0x00, 0x18, 0x50, 0x48, 0x60, 0x78,
64 0x68, 0x70, 0x58, 0x40, 0x08, 0x10, 0x38, 0x20,
65 0xA8, 0xB0, 0x98, 0x80, 0xC8, 0xD0, 0xF8, 0xE0,
66 0xD8, 0xC0, 0xE8, 0xF0, 0xB8, 0xA0, 0x88, 0x90,
67 0x18, 0x00, 0x28, 0x30, 0x78, 0x60, 0x48, 0x50,
68 0x40, 0x58, 0x70, 0x68, 0x20, 0x38, 0x10, 0x08,
69 0x80, 0x98, 0xB0, 0xA8, 0xE0, 0xF8, 0xD0, 0xC8
70 }; // crc8LUT
71
72
73
74
75 //----------------------------------------------------------------------------
76 // byte culFastCRC8(crcData, crcReg)
77 //
78 // Description:
79 // A CRC-8 (DOW) implementation optimized for fast execution.
80 // The function should be called once for each byte in the data
81 // the CRC is to be performed on. Before the invocation on the first byte
82 // the FAST_CRC8_INIT() macro should be called. This final CRC-value
83 // should be added at the end of the data to facilitate a later CRC
84 // check. During checking the check should be performed on all the data
85 // AND the CRC-8 value appended to it. The data is intact if the value
86 // returned is 0.
87 //
88 // Arguments:
89 // byte crcData
90 // The data to perform the CRC-8 operation on.
91 // byte crcReg
92 // The current value of the CRC register. For each additional byte
93 // the value returned for the last invocation should be supplied.
94 //
95 // Return value (not for the macro):
96 // The updated value of the CRC8 register. This corresponds to the
97 // CRC-8 of the data supplied so far. During CRC checking, after working
98 // through all the data and the appended CRC-8 value, the value will be
99 // 0 if the data is intact.
100 //----------------------------------------------------------------------------
101 byte culFastCRC8(byte crcData, byte crcReg) {
102 1 return crc8LUT[crcData ^ crcReg];
103 1 } // culFastCRC8
104
105
106
107
108 //----------------------------------------------------------------------------
109 // byte culFastCRC8Block(byte *crcData, word length, byte crcReg)
110 //
111 // Description:
112 // An implementation of the above function (culFastCRC8) that operates
113 // on blocks of data instead of single bytes.
114 //
115 // Extra arguments:
116 // word length
C51 COMPILER V7.06 FASTCRC8 04/13/2005 12:55:51 PAGE 3
117 // The number of bytes in this block (crcData[]).
118 //----------------------------------------------------------------------------
119 byte culFastCRC8Block(byte *crcData, word length, byte crcReg) {
120 1 word i;
121 1
122 1 for (i = 0; i < length; i++) {
123 2 crcReg = crc8LUT[crcData[i] ^ crcReg];
124 2 }
125 1 return crcReg;
126 1 } // culFastCRC8Block
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 61 ----
CONSTANT SIZE = 256 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 6
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -