电路设计,软件开发,专业项目团队承接电子产品开发!


ISPRO下载型编程器
火爆销售中

RS232/TTL转换器
全IC串口窃电

RS232/TTL转换线
全IC串口窃电

ByteBlasterMV Cable
CPLD/FPGA并口下载线

ByteBlaster II Cable ISPRO下载型编程器
支持S51/AVR/PIC
超级51开发板套件
前卫实用超值

PC/MCU/CPLD
三合一学习套件

全新万年历方案
AVR单片机开发板
 

Min51单片机仿真机
迷你型

ARM7开发板
仅售260元!
 

RS-232/RS-485双向接口电平转换器  

51单片机升级STM32
火爆销售中
MPLAB-ICD2
火爆销售中
LED51开发板
玩具又名图文显示棒

面板模块/开发板
经济危机明智决择

       

GSM MODEM GSM猫

SMS短信模块 工业级/全自动
火爆销售中

大功率数传电台

高速数传电台

您当前位置:电子技术资料 -> 外围驱动 -> CRC校验 ->

祝您阅读愉快!

ISPRO下载型编程器

RS232 TO TTL转换器
↑↑本文相关产品介绍↑↑

16bit CRC assembler program


类别:技术文章
来源:本站整理
作者:本站整理
关键字:CRC
加入日期:2002-7-2

16bit CRC assembler program

;----------------------------------------
; STRINT IS EF-NET OUT. THE INT.
; USE INT08
; 1. R1R0 -- TO OUTPUT BUFFER
; R2R3 -- STORE BCNT
; R4 -- STORE STAT
; R7R6 -- STORE CRC
; SIOFLG-- TRANSMIT FLAG.
; IF SIOFLG=00H, OUTPUT BYTE IS BCNTL
; =01H, OUTPUT BYTE IS BCNTH
; =02H, OUTPUT BYTE IS STATE
; =03H, OUTPUT BYTE IS DATA BYTE
; =04H, OUTPUT BYTE IS ADDL
; =05H, OUTPUT BYTE IS ADDH
; =06H, OUTPUT END
;------------------------------------------
STRINT: PUSH PSW
PUSH ACC
PUSH DPL
PUSH DPH
MOV PSW,#08H ;SELECT BANK-1
JBC TI,STR01 ;串口发送中断标志。
MOV TMR04,#00H ;INITIAL WATCH-DOG=120s
MOV TMR05,#08H
CLR RI
LJMP SREINT
; OUTPUT BCNTL
STR01: MOV A,SIOFLG
JNZ STR02
MOV SCON,#0C0H
MOV A,R2
SJMP STR26

; OUTPUT BCNTH
STR02: CJNE A,#01H,STR10
MOV A,R3
SJMP STR26
;
; OUTPUT STAT
STR10: CJNE A,#02H,STR20
INC SIOFLG ;OUT DATA BYTE FLAG
MOV A,R4
DEC R2
CJNE R2,#00H,STR28
SJMP STR26
;
; OUTPUT DATA BYTES
STR20: CJNE A,#03H,STR30
MOV DPL,R0
MOV DPH,R1
MOVX A,@DPTR
INC DPTR
MOV R0,DPL
MOV R1,DPH
DJNZ R2,STR28
STR26: INC SIOFLG

;**************************
STR28: MOV SBUF,A
MOV DPTR,#CRCTAB1
XRL A,R6
CLR C
RLC A
JNC STR2A
INC DPH
STR2A: ADD A,DPL
MOV DPL,A
CLR A
ADDC A,DPH
MOV DPH,A
CLR A
MOVC A,@A+DPTR
XRL A,R7
MOV R6,A
MOV A,#01H
MOVC A,@A+DPTR
MOV R7,A
;********************************
SJMP STR8A
;
; OUTPUT ADDL
STR30: CJNE A,#04H,STR40
INC SIOFLG
MOV SBUF,R6
SJMP STR8A
;
; OUTPUT ADDH
STR40: CJNE A,#05H,STR48
INC SIOFLG
MOV SBUF,R7
SJMP STR8A
STR48: MOV SCON,#0F0H
SETB HATSIO
STR8A: POP DPH
POP DPL
POP ACC
POP PSW
RETI
;
;-----------------------------------
; SREINT IS EF-NET RECEIVE THE INT.
; USE RI INT.(INT09)
; 1. SIOFLG,7=0 IS SLAVE MODE RECEIVE
; R1R0 --- INPUT BUFFER ADDR
; R2 --- STORE BCNT
; R6 --- STORE ADDBL
; R7 --- STORE ADDBH
;
; SR10--- STORE RECEIVED ADDR
; SR12--- STORE BCNT
; SR14--- STORE COMMAND NO.
; IF SIOFLG=80H, RECEIVE BYTE IS COMMAND BYTE
; =81H, RECEIVE BYTE IS ADDH BYTE
; =82H, RECEIVE BYTE IS BCNT LOW BYTE
; =83H, RECEIVE BYTE IS BCNT HIGH BYTE
; =84H, RECEIVE BYTE IS DATA BYTE
; =85H, RECEIVE BYTE IS ADDBH
; =86H, RECEIVE BYTE IS ADDBL
; SIOFLG.4=1 THEN BROADCAST COMMADN
;------------------------------------------------
;
SRE00: MOV A,SBUF ;READ ADDL
JZ SRE02
CJNE A,STAADL,SRE08
SRE02: CLR SM2
MOV SR10,A
CLR A
MOV SR11,A
MOV R7,A
MOV R6,A
MOV A,SR10
MOV SIOFLG,#80H
SJMP SRE68
SRE06: POP DPH
POP DPL
POP ACC
POP PSW
RETI
SRE08: MOV SIOFLG,#0FFH
SETB SM2
SJMP SRE06
;
SREINT: JB RB8,SRE00 ;RB8=1 GO
;
; IT IS COMMAND BYTES
SRE20: MOV A,SIOFLG
CJNE A,#80H,SRE30
MOV A,SBUF
MOV SR14,A
INC SIOFLG ;RECEIVE ADDH FLAG
JB ACC.7,SRE68
SJMP SRE66
;
; IT IS ADDH
SRE30: CJNE A,#81H,SRE40
MOV A,SBUF ;READ ADDH
CJNE A,STAADH,SRE08
MOV SR11,A
MOV A,SR10
CJNE A,STAADL,SRE08
MOV A,SR11
SJMP SRE66
;
;IT IS BCNT LOW BYTE
SRE40: CJNE A,#82H,SRE50
MOV A,SBUF
MOV R2,A
CLR C
SUBB A,#FILONG+1
JNC SRE08
MOV A,R2
SJMP SRE66
;
;IT IS BCNT HIGH BYTE
SRE50: CJNE A,#83H,SRE60
MOV A,SBUF
JNZ SRE08
INC SIOFLG ;RECEIVE DATA BYTE FLAG
MOV DPTR,#SIOBUF
MOV R0,DPL
MOV R1,DPH
CJNE R2,#00H,SRE68
SJMP SRE66
;
;RECEIVE DATA BYTES
SRE60: CJNE A,#84H,SRE70
MOV A,SBUF
MOV DPL,R0
MOV DPH,R1
MOVX @DPTR,A
INC DPTR
MOV R0,DPL
MOV R1,DPH
DJNZ R2,SRE68
SRE66: INC SIOFLG

;******************************
SRE68: MOV DPTR,#CRCTAB1
XRL A,R6
CLR C
RLC A
JNC SRE6A
INC DPH
SRE6A: ADD A,DPL
MOV DPL,A
CLR A
ADDC A,DPH
MOV DPH,A
CLR A
MOVC A,@A+DPTR
XRL A,R7
MOV R6,A
MOV A,#01H
MOVC A,@A+DPTR
MOV R7,A
;********************************
SRE6E: LJMP SRE06
;IT IS CRC LOW
SRE70: CJNE A,#85H,SRE80
MOV A,SBUF
XRL A,R6
JNZ SRE88
INC SIOFLG ;XORB FLAG

MOV A,SR14
ANL A,#7FH
CJNE A,#03H,SRE6E ;NOT COMMAND No. 03(TEXT COMMAND GO)
MOV TL0,#00H ;

SJMP SRE6E
;IT IS ACC HIGH
SRE80: CJNE A,#86H,SRE88
MOV A,SBUF
XRL A,R7
JZ SRDCOM
SRE88: LJMP SRE08
;



;
CRC_TAB: DB 000H,000H;00
DB 089H,011H;01
DB 012H,023H;02
DB 09BH,032H;03
DB 024H,046H;04
DB 0ADH,057H;05
DB 036H,065H;06
DB 0BFH,074H;07
DB 048H,08CH;08
DB 0C1H,09DH;09
DB 05AH,0AFH;0A
DB 0D3H,0BEH;0B
DB 06CH,0CAH;0C
DB 0E5H,0DBH;0D
DB 07EH,0E9H;0E
DB 0F7H,0F8H;0F
DB 081H,010H;010
DB 008H,001H;011
DB 093H,033H;012
DB 01AH,022H;013
DB 0A5H,056H;014
DB 02CH,047H;015
DB 0B7H,075H;016
DB 03EH,064H;017
DB 0C9H,09CH;018
DB 040H,08DH;019
DB 0DBH,0BFH;01A
DB 052H,0AEH;01B
DB 0EDH,0DAH;01C
DB 064H,0CBH;01D
DB 0FFH,0F9H;01E
DB 076H,0E8H;01F
DB 002H,021H;020
DB 08BH,030H;021
DB 010H,002H;022
DB 099H,013H;023
DB 026H,067H;024
DB 0AFH,076H;025
DB 034H,044H;026
DB 0BDH,055H;027
DB 04AH,0ADH;028
DB 0C3H,0BCH;029
DB 058H,08EH;02A
DB 0D1H,09FH;02B
DB 06EH,0EBH;02C
DB 0E7H,0FAH;02D
DB 07CH,0C8H;02E
DB 0F5H,0D9H;02F
DB 083H,031H;030
DB 00AH,020H;031
DB 091H,012H;032
DB 018H,003H;033
DB 0A7H,077H;034
DB 02EH,066H;035
DB 0B5H,054H;036
DB 03CH,045H;037
DB 0CBH,0BDH;038
DB 042H,0ACH;039
DB 0D9H,09EH;03A
DB 050H,08FH;03B
DB 0EFH,0FBH;03C
DB 066H,0EAH;03D
DB 0FDH,0D8H;03E
DB 074H,0C9H;03F
DB 004H,042H;040
DB 08DH,053H;041
DB 016H,061H;042
DB 09FH,070H;043
DB 020H,004H;044
DB 0A9H,015H;045
DB 032H,027H;046
DB 0BBH,036H;047
DB 04CH,0CEH;048
DB 0C5H,0DFH;049
DB 05EH,0EDH;04A
DB 0D7H,0FCH;04B
DB 068H,088H;04C
DB 0E1H,099H;04D
DB 07AH,0ABH;04E
DB 0F3H,0BAH;04F
DB 085H,052H;050
DB 00CH,043H;051
DB 097H,071H;052
DB 01EH,060H;053
DB 0A1H,014H;054
DB 028H,005H;055
DB 0B3H,037H;056
DB 03AH,026H;057
DB 0CDH,0DEH;058
DB 044H,0CFH;059
DB 0DFH,0FDH;05A
DB 056H,0ECH;05B
DB 0E9H,098H;05C
DB 060H,089H;05D
DB 0FBH,0BBH;05E
DB 072H,0AAH;05F
DB 006H,063H;060
DB 08FH,072H;061
DB 014H,040H;062
DB 09DH,051H;063
DB 022H,025H;064
DB 0ABH,034H;065
DB 030H,006H;066
DB 0B9H,017H;067
DB 04EH,0EFH;068
DB 0C7H,0FEH;069
DB 05CH,0CCH;06A
DB 0D5H,0DDH;06B
DB 06AH,0A9H;06C
DB 0E3H,0B8H;06D
DB 078H,08AH;06E
DB 0F1H,09BH;06F
DB 087H,073H;070
DB 00EH,062H;071
DB 095H,050H;072
DB 01CH,041H;073
DB 0A3H,035H;074
DB 02AH,024H;075
DB 0B1H,016H;076
DB 038H,007H;077
DB 0CFH,0FFH;078
DB 046H,0EEH;079
DB 0DDH,0DCH;07A
DB 054H,0CDH;07B
DB 0EBH,0B9H;07C
DB 062H,0A8H;07D
DB 0F9H,09AH;07E
DB 070H,08BH;07F
;-----------------------------------------
DB 008H,084H;080
DB 081H,095H;081
DB 01AH,0A7H;082
DB 093H,0B6H;083
DB 02CH,0C2H;084
DB 0A5H,0D3H;085
DB 03EH,0E1H;086
DB 0B7H,0F0H;087
DB 040H,008H;088
DB 0C9H,019H;089
DB 052H,02BH;08A
DB 0DBH,03AH;08B
DB 064H,04EH;08C
DB 0EDH,05FH;08D
DB 076H,06DH;08E
DB 0FFH,07CH;08F
DB 089H,094H;090
DB 000H,085H;091
DB 09BH,0B7H;092
DB 012H,0A6H;093
DB 0ADH,0D2H;094
DB 024H,0C3H;095
DB 0BFH,0F1H;096
DB 036H,0E0H;097
DB 0C1H,018H;098
DB 048H,009H;099
DB 0D3H,03BH;09A
DB 05AH,02AH;09B
DB 0E5H,05EH;09C
DB 06CH,04FH;09D
DB 0F7H,07DH;09E
DB 07EH,06CH;09F
DB 00AH,0A5H;0A0
DB 083H,0B4H;0A1
DB 018H,086H;0A2
DB 091H,097H;0A3
DB 02EH,0E3H;0A4
DB 0A7H,0F2H;0A5
DB 03CH,0C0H;0A6
DB 0B5H,0D1H;0A7
DB 042H,029H;0A8
DB 0CBH,038H;0A9
DB 050H,00AH;0AA
DB 0D9H,01BH;0AB
DB 066H,06FH;0AC
DB 0EFH,07EH;0AD
DB 074H,04CH;0AE
DB 0FDH,05DH;0AF
DB 08BH,0B5H;0B0
DB 002H,0A4H;0B1
DB 099H,096H;0B2
DB 010H,087H;0B3
DB 0AFH,0F3H;0B4
DB 026H,0E2H;0B5
DB 0BDH,0D0H;0B6
DB 034H,0C1H;0B7
DB 0C3H,039H;0B8
DB 04AH,028H;0B9
DB 0D1H,01AH;0BA
DB 058H,00BH;0BB
DB 0E7H,07FH;0BC
DB 06EH,06EH;0BD
DB 0F5H,05CH;0BE
DB 07CH,04DH;0BF
DB 00CH,0C6H;0C0
DB 085H,0D7H;0C1
DB 01EH,0E5H;0C2
DB 097H,0F4H;0C3
DB 028H,080H;0C4
DB 0A1H,091H;0C5
DB 03AH,0A3H;0C6
DB 0B3H,0B2H;0C7
DB 044H,04AH;0C8
DB 0CDH,05BH;0C9
DB 056H,069H;0CA
DB 0DFH,078H;0CB
DB 060H,00CH;0CC
DB 0E9H,01DH;0CD
DB 072H,02FH;0CE
DB 0FBH,03EH;0CF
DB 08DH,0D6H;0D0
DB 004H,0C7H;0D1
DB 09FH,0F5H;0D2
DB 016H,0E4H;0D3
DB 0A9H,090H;0D4
DB 020H,081H;0D5
DB 0BBH,0B3H;0D6
DB 032H,0A2H;0D7
DB 0C5H,05AH;0D8
DB 04CH,04BH;0D9
DB 0D7H,079H;0DA
DB 05EH,068H;0DB
DB 0E1H,01CH;0DC
DB 068H,00DH;0DD
DB 0F3H,03FH;0DE
DB 07AH,02EH;0DF
DB 00EH,0E7H;0E0
DB 087H,0F6H;0E1
DB 01CH,0C4H;0E2
DB 095H,0D5H;0E3
DB 02AH,0A1H;0E4
DB 0A3H,0B0H;0E5
DB 038H,082H;0E6
DB 0B1H,093H;0E7
DB 046H,06BH;0E8
DB 0CFH,07AH;0E9
DB 054H,048H;0EA
DB 0DDH,059H;0EB
DB 062H,02DH;0EC
DB 0EBH,03CH;0ED
DB 070H,00EH;0EE
DB 0F9H,01FH;0EF
DB 08FH,0F7H;0F0
DB 006H,0E6H;0F1
DB 09DH,0D4H;0F2
DB 014H,0C5H;0F3
DB 0ABH,0B1H;0F4
DB 022H,0A0H;0F5
DB 0B9H,092H;0F6
DB 030H,083H;0F7
DB 0C7H,07BH;0F8
DB 04EH,06AH;0F9
DB 0D5H,058H;0FA
DB 05CH,049H;0FB
DB 0E3H,03DH;0FC
DB 06AH,02CH;0FD
DB 0F1H,01EH;0FE
DB 078H,00FH;0FF


您可能还会关注的相关技术资料:

中国电子网
www.EC66.com
QQ:34740080 EMAIL:iloveaoe@163.com
最佳浏览:1024*768
Copyright (C) 2001-2010 EC66.COM All Rights Reserved
Aoe/帝国 制作维护
粤ICP备18061901号