CRC16-STANDARD的快速算法,51汇编

发布者:德州小孙最新更新时间:2015-03-12 来源: laogu关键字:CRC16-STANDARD  快速算法  51汇编 手机看文章 扫描二维码
随时随地手机看文章
CRC16-STANDARD的快速算法
 
;入口: R0-原CRC结果高位 R1-原CRC结果低位R2-下个参与计算的字节值
;(最开始可设置R0=0,R1=0,R2=第一字节值)
;出口: R0-CRC结果高位 R1-CRC结果低位
 
影响:A,DPH,DPL
CRC16:
PUSH DPH
PUSH DPL
PUSH ACC
MOV A,R1
XRL A,R2
MOV DPH,#20h
MOV DPL,A
CLR A
MOVC A,@A+DPTR
XRL A,R0
MOV R1,A
INC DPH
CLR A
MOVC A,@A+DPTR
MOV R0,A
POP ACC
POP DPL
POP DPh
RET
NOP
NOP
LJMP MAIN
ORG 2000H ;(根据你的实际情况而定)
CRCTABLE:
DB 
000H,0C1H,081H,040H,001H,0C0H,080H,041H,001H,0C0H,080H,041H,000H,0C1H,081H,040H
DB 
001H,0C0H,080H,041H,000H,0C1H,081H,040H,000H,0C1H,081H,040H,001H,0C0H,080H,041H
DB 
001H,0C0H,080H,041H,000H,0C1H,081H,040H,000H,0C1H,081H,040H,001H,0C0H,080H,041H
DB 
000H,0C1H,081H,040H,001H,0C0H,080H,041H,001H,0C0H,080H,041H,000H,0C1H,081H,040H
DB 
001H,0C0H,080H,041H,000H,0C1H,081H,040H,000H,0C1H,081H,040H,001H,0C0H,080H,041H
DB 
000H,0C1H,081H,040H,001H,0C0H,080H,041H,001H,0C0H,080H,041H,000H,0C1H,081H,040H
DB 
000H,0C1H,081H,040H,001H,0C0H,080H,041H,001H,0C0H,080H,041H,000H,0C1H,081H,040H
DB 
001H,0C0H,080H,041H,000H,0C1H,081H,040H,000H,0C1H,081H,040H,001H,0C0H,080H,041H
DB 
001H,0C0H,080H,041H,000H,0C1H,081H,040H,000H,0C1H,081H,040H,001H,0C0H,080H,041H
DB 
000H,0C1H,081H,040H,001H,0C0H,080H,041H,001H,0C0H,080H,041H,000H,0C1H,081H,040H
DB 
000H,0C1H,081H,040H,001H,0C0H,080H,041H,001H,0C0H,080H,041H,000H,0C1H,081H,040H
DB 
001H,0C0H,080H,041H,000H,0C1H,081H,040H,000H,0C1H,081H,040H,001H,0C0H,080H,041H
DB 
000H,0C1H,081H,040H,001H,0C0H,080H,041H,001H,0C0H,080H,041H,000H,0C1H,081H,040H
DB 
001H,0C0H,080H,041H,000H,0C1H,081H,040H,000H,0C1H,081H,040H,001H,0C0H,080H,041H
DB 
001H,0C0H,080H,041H,000H,0C1H,081H,040H,000H,0C1H,081H,040H,001H,0C0H,080H,041H
DB 
000H,0C1H,081H,040H,001H,0C0H,080H,041H,001H,0C0H,080H,041H,000H,0C1H,081H,040H
 
DB 
000H,0C0H,0C1H,001H,0C3H,003H,002H,0C2H,0C6H,006H,007H,0C7H,005H,0C5H,0C4H,004H
DB 
0CCH,00CH,00DH,0CDH,00FH,0CFH,0CEH,00EH,00AH,0CAH,0CBH,00BH,0C9H,009H,008H,0C8H
DB 
0D8H,018H,019H,0D9H,01BH,0DBH,0DAH,01AH,01EH,0DEH,0DFH,01FH,0DDH,01DH,01CH,0DCH
DB 
014H,0D4H,0D5H,015H,0D7H,017H,016H,0D6H,0D2H,012H,013H,0D3H,011H,0D1H,0D0H,010H
DB 
0F0H,030H,031H,0F1H,033H,0F3H,0F2H,032H,036H,0F6H,0F7H,037H,0F5H,035H,034H,0F4H
DB 
03CH,0FCH,0FDH,03DH,0FFH,03FH,03EH,0FEH,0FAH,03AH,03BH,0FBH,039H,0F9H,0F8H,038H
DB 
028H,0E8H,0E9H,029H,0EBH,02BH,02AH,0EAH,0EEH,02EH,02FH,0EFH,02DH,0EDH,0ECH,02CH
DB 
0E4H,024H,025H,0E5H,027H,0E7H,0E6H,026H,022H,0E2H,0E3H,023H,0E1H,021H,020H,0E0H
DB 
0A0H,060H,061H,0A1H,063H,0A3H,0A2H,062H,066H,0A6H,0A7H,067H,0A5H,065H,064H,0A4H
DB 
06CH,0ACH,0ADH,06DH,0AFH,06FH,06EH,0AEH,0AAH,06AH,06BH,0ABH,069H,0A9H,0A8H,068H
DB 
078H,0B8H,0B9H,079H,0BBH,07BH,07AH,0BAH,0BEH,07EH,07FH,0BFH,07DH,0BDH,0BCH,07CH
DB 
0B4H,074H,075H,0B5H,077H,0B7H,0B6H,076H,072H,0B2H,0B3H,073H,0B1H,071H,070H,0B0H
DB 
050H,090H,091H,051H,093H,053H,052H,092H,096H,056H,057H,097H,055H,095H,094H,054H
DB 
09CH,05CH,05DH,09DH,05FH,09FH,09EH,05EH,05AH,09AH,09BH,05BH,099H,059H,058H,098H
DB 
088H,048H,049H,089H,04BH,08BH,08AH,04AH,04EH,08EH,08FH,04FH,08DH,04DH,04CH,08CH
DB 
044H,084H,085H,045H,087H,047H,046H,086H,082H,042H,043H,083H,041H,081H,080H,040H
NOP
NOP
LJMP MAIN
关键字:CRC16-STANDARD  快速算法  51汇编 引用地址:CRC16-STANDARD的快速算法,51汇编

上一篇:C51 怎样将1个子程序段定位在1个固定的地址位置?
下一篇:基于RTOS和ISP功能的数字仪表系统设计与实现

推荐阅读最新更新时间:2024-03-16 13:54

嵌入式系统学习笔记(6)——MCS51汇编语言程序设计
有汇编程序和反汇编程序,可以由机器语言得到汇编语言 不是所有都会默认从0000H开始,保险起见,还是要在开头用ORG 0000H,然后加一条跳转指令到程序存放起始地址 交叉汇编,在一台电脑上汇编,在另一台电脑上运行 注意,除了51单片机之外,其它单片机上电后PC值并不一定是0000H,所以需要根据实际情况放第一条指令的位置。此外,0003H到0023H是中断入口,所以第一条指令只能是0000H到0002H一共三个字节,LJMP指令恰好就是3个字节。跳转后的两个NOP是为了等外接芯片复位,因为外接芯片可能复位比51的CPU慢,这段时
[单片机]
嵌入式系统学习笔记(6)——MCS<font color='red'>51汇编</font>语言程序设计
Cortex--M0单片机二-十进制整数转换的快速算法
  为了提高Cortex—M0系列单片机应用系统的二进制到十进制BCD码整数转换代码的执行效率,采用除十求余数法来实现。该快速算法的核心内容是通过高效的汇编语言来实现常数除法,无论在程序代码的运行时间和存储空间上,都远胜于sprintf函数。   在单片机应用系统中,一般都需要高效快速地完成系统所需要的任务,并在任务完成后使系统进入睡眠或低功耗状态,以便最大限度地节省系统功耗,增强系统的抗干扰能力。因此,必须优化和提高系统中各个模块的运算速度,以最大限度地压缩软件运行时间。许多单片机应用系统中都需要进行二进制整数转换为十进制BCD码的操作,以便实现系统信息的显示。对于Cortex—M0系列单片机,由于其指令系统中没有十进制调整指令
[单片机]
Cortex--M0单片机二-十进制整数转换的<font color='red'>快速</font><font color='red'>算法</font>
小广播
添点儿料...
无论热点新闻、行业分析、技术干货……
设计资源 培训 开发板 精华推荐

最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

换一换 更多 相关热搜器件
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved