;=============================================================================
;Immobilizer_release制御プログラム 2011/1/12
;=============================================================================
;**** Define
Processo
;
LIST
P=18F23K20
INCLUDE
P18F13K22.INC
;;****
Configurations
40MHz PLL mode HFINTOSC
CONFIG
FOSC=HS, PLLEN = ON ,IESO=OFF, PWRTEN=ON, BOREN=ON,
BORV=30, WDTEN=OFF, WDTPS=256, MCLRE = OFF
CONFIG
CP0=ON, CP1=ON, CPB=ON, CPD=OFF
CONFIG
WRT0=ON, WRT1=ON, WRTB=ON, WRTC=ON
CONFIG
WRTD=OFF, EBTR0=ON, EBTR1=ON, EBTRB=ON
;PORTA,2
IN
UN_LOCK
;PORTC,0
IN
LOCK
;PORTC,1
IN
IG
;PORTC,2
ACC
;PORTB,4
IG1
;PORTB,5
IG2
(実車ではST時はカットされている)
;PORTB,6
ST
;PORTB,7
LED
;PORTC,5
CAN/OUT
;PORTC,4
CAN_IN
;**** ID Location
__IDLOCS
_IDLOC0,H'2'
__IDLOCS
_IDLOC1,H'0'
__IDLOCS
_IDLOC2,H'1'
__IDLOCS
_IDLOC3,H'1'
__IDLOCS
_IDLOC4,H'0'
__IDLOCS
_IDLOC5,H'6'
__IDLOCS
_IDLOC6,H'1'
__IDLOCS
_IDLOC7,H'1'
;**** Define
Variables
CBLOCK
0x000
TEST_CNT
CNT1
;Timer counter
CNT2
CNT3
CNT4
CNT5
SETTEI_CNT
EEADR_CNT
ID_LOW
ID_HI
ID_LOW_0
ID_HI_0
ID_HI_CHK_CNT
ID_LOW_CHK_CNT
L_5bit_CHK
H_5bit_CHK
RTR_RB0_RB1
DLC
DLC_0
RTR_RB0_RB1_BIT_CNT
DLC_BIT_CNT
DATA_X
DATA_1
DATA_2
DATA_3
DATA_4
DATA_5
DATA_6
DATA_7
DATA_8
CRC_DATA_1
CRC_DATA_2
DATA_1_0
DATA_2_0
DATA_3_0
DATA_4_0
DATA_5_0
DATA_6_0
DATA_7_0
DATA_8_0
DATAX_1_0
DATAX_2_0
DATAX_3_0
DATAX_4_0
DATAX_5_0
DATAX_6_0
DATAX_7_0
DATAX_8_0
plaintext_DATA_1
plaintext_DATA_2
plaintext_DATA_3
plaintext_DATA_4
plaintext_DATA_5
plaintext_DATA_6
plaintext_DATA_7
plaintext_DATA_8
Reproduce_DATA1
Reproduce_DATA2
Reproduce_DATA3
Reproduce_DATA4
Reproduce_DATA5
Reproduce_DATA6
Reproduce_DATA7
Reproduce_DATA8
DATA_1_CNT
DATA_2_CNT
DATA_3_CNT
DATA_4_CNT
DATA_5_CNT
DATA_6_CNT
DATA_7_CNT
DATA_8_CNT
CRC_DATA_1_CNT
CRC_DATA_2_CNT
CRC_X
CRC_L
CRC_L_X
CRC_H
CRC_H_X
Reproduce_CRC_L
Reproduce_CRC_H
DATA_BIT_CNT
BIT_CNT
HI_BIT_CNT
LOW_BIT_CNT
SADOU_PORT
_0D1_CNT
ST_CNT
ON_CNT
FULL_END_CNT
W_TEMP
S_TEMP
TIMER_CNT
CAN_CHK_CNT
ID_0D_CNT
ENDC
;**** EEPROM WRITE
ORG
0xF00000
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
DE
H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00',H'00'
;
;******************************************
ORG
0
GOTO
START
;******************************************
;=============================================================
T_10u
MOVLW
D'37'
MOVWF
CNT1
T_10u_LP
CLRWDT
DECFSZ
CNT1,F
;2+4*37-1+2=151
GOTO
T_10u_LP
RETURN
;151*0.067=10usec
T_100u
MOVLW
D'10'
MOVWF
CNT2
T_100u_LP
CALL
T_10u
DECFSZ
CNT2,F
GOTO
T_100u_LP
RETURN
TIME1M
MOVLW
D'100'
MOVWF
CNT2
TIME1_LP
CALL
T_10u
DECFSZ
CNT2,F
GOTO
TIME1_LP
RETURN
TIME10M
MOVLW
D'10'
MOVWF
CNT3
TIME10M_LP
CALL
TIME1M
DECFSZ
CNT3,F
GOTO
TIME10M_LP
RETURN
TIME20M
MOVLW
D'20'
MOVWF
CNT3
TIME20M_LP
CALL
TIME1M
DECFSZ
CNT3,F
GOTO
TIME20M_LP
RETURN
TIME100M
MOVLW
D'100'
MOVWF
CNT3
TIME100M_LP
CALL
TIME1M
DECFSZ
CNT3,F
GOTO
TIME100M_LP
RETURN
TIME0.5S
MOVLW
D'5'
MOVWF
CNT4
TIME0.5S_LP
CALL
TIME100M
DECFSZ
CNT4,F
GOTO
TIME0.5S_LP
RETURN
TIM1S
MOVLW
D'10'
MOVWF
CNT4
TIM1S_LP
CALL
TIME100M
DECFSZ
CNT4,F
GOTO
TIM1S_LP
RETURN
TIME2S
MOVLW
D'20'
MOVWF
CNT4
TIME2S_LP
CALL
TIME100M
DECFSZ
CNT4,F
GOTO
TIME2S_LP
RETURN
TIME5S
MOVLW
D'50'
MOVWF
CNT4
TIME5S_LP
CALL
TIME100M
DECFSZ
CNT4,F
GOTO
TIME5S_LP
RETURN
;******************************************************************
CYCLE_30
NOP
;30
CYCLE_29
NOP
;29
CYCLE_28
NOP
;28
CYCLE_27
NOP
;27
CYCLE_26
NOP
;26
CYCLE_25
NOP
;25
CYCLE_24
NOP
;24
CYCLE_23
NOP
;23
CYCLE_22
NOP
;22
CYCLE_21
NOP
;21
CYCLE_20
NOP
;20
CYCLE_19
NOP
;19
CYCLE_18
NOP
;18
CYCLE_17
NOP
;17
CYCLE_16
NOP
;16
CYCLE_15
NOP
;15
CYCLE_14
NOP
;14
CYCLE_13
NOP
;13
CYCLE_12
NOP
;12
CYCLE_11
NOP
;11
CYCLE_10
NOP
;10
CYCLE_9
NOP
;9
CYCLE_8
NOP
;8
CYCLE_7
NOP
;7
CYCLE_6
NOP
;6
CYCLE_5
NOP
;5
CYCLE_4
NOP
;4
CYCLE_3
NOP
;3
CYCLE_2
RETURN
;1,2
CYCLE_12_H
NOP
BTFSS
PORTC,4
;skip(2)
GOTO
CYCLE_HENKA
BTFSS
PORTC,4
;skip(2)
GOTO
CYCLE_HENKA
BTFSS
PORTC,4
;skip(2)
GOTO
CYCLE_HENKA
RETURN
;(2)
2*5+2=12
CYCLE_12_L
NOP
BTFSC
PORTC,4
;skip(2)
GOTO
CYCLE_HENKA
BTFSC
PORTC,4
;skip(2)
GOTO
CYCLE_HENKA
BTFSC
PORTC,4
;skip(2)
GOTO
CYCLE_HENKA
RETURN
;(2)
2*5+2=12
CYCLE_HENKA
RETURN
;(2)
2+2=4
その前の判断で+3 =7
;ここには5回連続して同ビットが検出された時にスタッフビット処理のためにくる
H_5bit_
;Hビットが5回連続したビットスタッフの対応
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
BTFSS
PORTC,4
;(1)
GOTO
H_5bit_1
;(2)
GOTO
EOF_CHK_0
H_5bit_1
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
MOVLW
D'4'
;(1)
MOVWF
L_5bit_CHK
;(1)
CALL
CYCLE_12
RETURN
;(2)
21+2
L_5bit_
;Lビットが5回連続したビットスタッフの対応
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
BTFSC
PORTC,4
;(1)
GOTO
L_5bit_1
;(2)
GOTO
EOF_CHK_0
L_5bit_1
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
MOVLW
D'4'
;(1)
MOVWF
H_5bit_CHK
;(1)
CALL
CYCLE_12
RETURN
;(2)
23
;**************************************
EE_REED
MOVF
EEADR_CNT,W ;
MOVWF
EEADR
; Data Memory Address to write
BCF
EECON1,EEPGD
; Point to DATA memory
BCF
EECON1,CFGS
BSF
EECON1,RD
; EEPROM Read
MOVF
EEDATA,W
; W = EEDATA
MOVWF
SETTEI_CNT
RETURN
;**************************************
EE_WRITE
MOVF
EEADR_CNT,W
;
MOVWF
EEADR
; Data Memory Address to write
MOVF
SETTEI_CNT,W
;
MOVWF
EEDATA
; Data Memory Value to write
BCF
EECON1,EEPGD
; Point to DATA memory
BCF
EECON1,CFGS
; Access EEPROM
BSF
EECON1,WREN
; Enable writes
BCF
INTCON,GIE
; Disable Interrupts
MOVLW
55h ;
Required
MOVWF
EECON2
; Write 55h
Sequence
MOVLW
0AAh ;
MOVWF
EECON2
; Write 0AAh
BSF
EECON1,WR
; Set WR bit to begin write
BTFSC
EECON1,WR
;完了待ち
BRA
$-2
BSF
INTCON,GIE
; Enable Interrupts
; User
code execution
BCF
EECON1, WREN
; Disable writes on write complete (EEIF set)
RETURN
;*********************************************************************************************************
;*********************************************************************************************************
START
;PORTA,2
IN
UN_LOCK
;PORTC,0
IN
LOCK
;PORTC,1
IN
IG
BANKSEL
ANSELH
MOVLW
B'00000000'
; anarog
MOVWF
ANSELH;
CLRF
ANSELH ;
MOVLW
B'00001010'
; anarog
MOVWF
ANSEL;
MOVLW
B'00000100'
; OUTput
MOVWF
TRISA
;
MOVLW
B'00000000'
;RB0 OUTput
MOVWF
TRISB
MOVLW
B'00010011'
;OUTput
MOVWF
TRISC
;
MOVLW
B'10111001'
;
MOVWf
CM1CON0
CLRF
EEADR_CNT
CLRF
SADOU_PORT
MOVLW
D'0'
;(1)
MOVWF
ID_0D_CNT
BSF
SWDTEN,0
CALL
TIME100M
;
RE_START
MOVLW
H'00'
;
MOVWF
FSR0H
MOVLW
H'00'
MOVWF
FSR0L
RAM_CLR
CLRF
INDF0
INCFSZ
FSR0L,F
GOTO
RAM_CLR
CLRF
PORTA
NOP
CLRF
PORTB
NOP
CLRF
PORTC
NOP
MOVLW
H'00'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
SADOU_PORT
MOVLW
H'01'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
plaintext_DATA_1
MOVLW
H'02'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
plaintext_DATA_2
MOVLW
H'03'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
plaintext_DATA_3
MOVLW
H'04'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
plaintext_DATA_4
MOVLW
H'05'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
plaintext_DATA_5
MOVLW
H'06'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
plaintext_DATA_6
MOVLW
H'07'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
plaintext_DATA_7
MOVLW
H'08'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
plaintext_DATA_8
MOVLW
H'0E'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
ON_CNT
MOVLW
H'0F'
MOVWF
EEADR_CNT
CALL
EE_REED
MOVF
SETTEI_CNT,W ;
MOVWF
FULL_END_CNT
BTFSC
FULL_END_CNT,0
GOTO
FULL_CNT_STOP
INCF
ON_CNT,F
;30回を越えたら停止
MOVLW
D'30'
SUBWF
ON_CNT,W
BTFSC
STATUS,Z
GOTO
FULL_CNT_STOP
MOVLW
H'0E'
MOVWF
EEADR_CNT
MOVF
ON_CNT,W
MOVWF
SETTEI_CNT
CALL
EE_WRITE
Main
CLRF
_0D1_CNT
CLRWDT
CLRF
T0CON
BTFSS
SADOU_PORT,0
;
平文の記憶
GOTO
EOF_CHK_0
;******************************************************************
EOF_CHK_0
;検出サイクルの精度のため、スタートビットの検出前に各セットを行っておく
;IDのHi/Lowビット数の組み合わせ (合わせて11ビットになるように)
CLRWDT
BSF
PORTC,5
BCF
PORTB,7
;LED
平文の記憶がまだならLED点灯
BTFSS
SADOU_PORT,0
BSF
PORTB,7
;LED 消灯していれば記憶している
BTFSS
PORTA,3
GOTO
RE_SET
MOVLW
D'3'
;
MOVWF
HI_BIT_CNT
;ID/Hi
MOVWF
RTR_RB0_RB1_BIT_CNT
MOVLW
D'4'
;
MOVWF
DLC_BIT_CNT
MOVLW
D'5'
;
MOVWF
H_5bit_CHK
;
MOVLW
D'4'
;注意
SOFでHビットを消費するので5−1
MOVWF
L_5bit_CHK
;
MOVLW
D'8'
;
MOVWF
LOW_BIT_CNT
;ID/Low
MOVWF
DATA_1_CNT
MOVWF
DATA_2_CNT
MOVWF
DATA_3_CNT
MOVWF
DATA_4_CNT
MOVWF
DATA_5_CNT
MOVWF
DATA_6_CNT
MOVWF
DATA_7_CNT
MOVWF
DATA_8_CNT
MOVWF
CRC_DATA_1_CNT
MOVWF
CRC_DATA_2_CNT
;IDクリア
CLRF
ID_LOW
CLRF
ID_HI
CLRF
RTR_RB0_RB1
CLRF
DLC
CLRF
DATA_1
CLRF
DATA_2
CLRF
DATA_3
CLRF
DATA_4
CLRF
DATA_5
CLRF
DATA_6
CLRF
DATA_7
CLRF
DATA_8
CLRF
CRC_DATA_1
CLRF
CRC_DATA_2
EOF_CHK
MOVLW
D'9'
;終了の連続ビット CAN-Bでは7ビット以上 初回の1ビットは検出で消費
MOVWF
BIT_CNT
EOF_CHK_LP
BTFSS
PORTC,4
;(2)
GOTO
EOF_CHK_LP
CALL
CYCLE_10
;(12)CYCLE_10+CALL(2)=12CYCLE
NOP
;ここまでで15
EOF_CHK_2
CALL
CYCLE_10
;(12)CYCLE_10+CALL(2)=12CYCLE
CALL
CYCLE_10
;(12)CYCLE_10+CALL(2)=12CYCLE
BTFSS
PORTC,4
;(2)
GOTO
EOF_CHK
NOP
;(1)
DECFSZ
BIT_CNT,F
;(1)
GOTO
EOF_CHK_2
;(2)
;******************************************************************
;スタートビットの検出
;******************************************************************
SOF_CHK_0
SOF_CHK
BTFSC
PORTC,4
;(2)
GOTO
SOF_CHK
CALL
CYCLE_10
;(12)CYCLE_10+CALL(2)=12CYCLE
BTFSC
PORTC,4
;(2)
GOTO
SOF_CHK
NOP
NOP
NOP
NOP
NOP
NOP
CALL
CYCLE_10
;(12)CYCLE_10+CALL(2)=12CYCLE
CALL
CYCLE_10
;(12)CYCLE_10+CALL(2)=12CYCLE
ここまでで(48)
;******************************************************************
;ID/Hiの検出 注意 IDコードがBENZに対して反転
;******************************************************************
ID_HI_CHK
;ID_HI_CHK - IDH_1bit_END(30)
NOP
NOP
RLCF
ID_HI,F
;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2) 1 2
15/30目をチェック
GOTO
ID_HI_L
;(2)
ID_HI_H
NOP
;(1)3
BSF
ID_HI,0
;(1)4
MOVLW
D'5'
;(1)5
MOVWF
L_5bit_CHK
;(1)6
DECFSZ
H_5bit_CHK,F
;(1) skip(2)7
GOTO
ID_HI_H_1bit_END
;(2)8 9
CALL
H_5bit_
;(2)
ID_HI_H_1bit_END
CALL
CYCLE_12_H
;(14)CYCLE_12+CALL(2)=14CYCLE
24
DECF
HI_BIT_CNT,F
;(1) 25
BZ
ID_HI_CHK_END
;(1) GOTO(2) 26
NOP
;(1) 27
NOP
;(1) 28
GOTO
ID_HI_CHK
;(2)
30
ID_HI_L
BCF
ID_HI,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
ID_HI_L_1bit_END
;(2)
CALL
L_5bit_
;(2)
ID_HI_L_1bit_END
CALL
CYCLE_12_L
;(17)CYCLE_12+CALL(2)=15CYCLE
DECF
HI_BIT_CNT,F
;(1) 25
BZ
ID_HI_CHK_END
;(1) GOTO(2) 26
NOP
;(1) 27
NOP
;(1) 28
GOTO
ID_HI_CHK
;(2)
30
ID_HI_CHK_END
MOVLW
H'00'
;(1)
SUBWF
ID_HI,W
;(1)
BTFSS
STATUS,Z
;(2)
GOTO
EOF_CHK_0
;******************************************************************
;ID/LOWの検出
;******************************************************************
ID_LOW_CHK
;ID_LOW_CHK - IDLOW1bit_END(30)
NOP
NOP
RLCF
ID_LOW,F
;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
ID_LOW_L
;(2)
ID_LOW_H
NOP
;(1)
BSF
ID_LOW,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
ID_LOW_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
ID_LOW_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
LOW_BIT_CNT,F
;(1)
BZ
ID_LOW_CHK_END
;(1) GOTO(2)
NOP
;(1)
NOP
;(1)
GOTO
ID_LOW_CHK
;(2)
ID_LOW_L
BCF
ID_LOW,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
ID_LOW_L_1bit_END
;(2)
CALL
L_5bit_
;(2)
ID_LOW_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
LOW_BIT_CNT,F
;(1)
BZ
ID_LOW_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
ID_LOW_CHK
;(2)
;↑↑↑↑ここまででIDの取り出し終了↑↑↑↑
ID_LOW_CHK_END
;
MOVLW
H'D1'
;(1)
;
SUBWF
ID_LOW,W
;(1)
;
BTFSS
STATUS,Z
;(2)
;
GOTO
EOF_CHK_0
NOP
NOP
NOP
;↑↑↑↑ここでID解析のみチェック↑↑↑↑ 2サイクル
;******************************************************************
;RTR_RB0_RB1の通過
;******************************************************************
RTR_RB0_RB1_CHK
;RTR_RB0_RB1_CHK - RTR_RB0_RB11bit_END(30)
NOP
NOP
RLCF
RTR_RB0_RB1,F
;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
RTR_RB0_RB1_L
;(2)
RTR_RB0_RB1_H
NOP
;(1)
BCF
RTR_RB0_RB1,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
RRR_LOW_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
RRR_LOW_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
RTR_RB0_RB1_BIT_CNT,F
;(1)
BZ
RTR_RB0_RB1_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
RTR_RB0_RB1_CHK
;(2)
RTR_RB0_RB1_L
BSF
RTR_RB0_RB1,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
RRR_LOW_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
RRR_LOW_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
RTR_RB0_RB1_BIT_CNT,F
;(1)
BZ
RTR_RB0_RB1_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
RTR_RB0_RB1_CHK
;(2)
RTR_RB0_RB1_CHK_END
NOP
NOP
NOP
;******************************************************************
;DLC
の通過
;******************************************************************
DLC_CHK
;DLC_CHK - DLC1bit_END(30)
NOP
NOP
RLCF
DLC,F
;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
DLC_L
;(2)
DLC_H
NOP
;(1)
BSF
DLC,0
;(1)
※NOT_BSF
注意 DLCは1111で0バイト0xxxで8バイト
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DLC_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
DLC_H_1bit_END
CALL
CYCLE_12_H
;(14)CYCLE_12+CALL(2)=14CYCLE
DECF
DLC_BIT_CNT,F
;(1)
BZ
DLC_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DLC_CHK
;(2)
;(2)
DLC_L
BCF
DLC,0
;(1)※NOT_BCF
注意 DLCは1111で0バイト0xxxで8バイト
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DLC_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
DLC_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DLC_BIT_CNT,F
;(1)
BZ
DLC_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DLC_CHK
;(2)
DLC_CHK_END
NOP
NOP
NOP
;******************************************************************
;データーの検出
;******************************************************************
DATA_CHK
MOVF
DLC,W
;DLCは、データーのバイト数
MOVWF
DATA_BIT_CNT
DATA_1_CHK
;DATA_1_CHK - DATA_11bit_END(30)
NOP
NOP
RLCF
DATA_1,F ;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
DATA_1_L
;(2)
DATA_1_H
NOP
;(1)
BSF
DATA_1,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_1_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
DATA_1_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_1_CNT,F
;(1)
BZ
DATA_1_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_1_CHK
;(2)
DATA_1_L
BCF
DATA_1,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_1_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
DATA_1_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_1_CNT,F
;(1)
BZ
DATA_1_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_1_CHK
;(2)
DATA_1_CHK_END
DECFSZ
DATA_BIT_CNT,F
GOTO
DATA_2_CHK
GOTO
DATA_ALL_CHK_END
DATA_2_CHK
;DATA_2_CHK - DATA_21bit_END(30)
NOP
NOP
RLCF
DATA_2,F ;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
DATA_2_L
;(2)
DATA_2_H
NOP
;(1)
BSF
DATA_2,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_2_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
DATA_2_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_2_CNT,F
;(1)
BZ
DATA_2_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_2_CHK
;(2)
DATA_2_L
BCF
DATA_2,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_2_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
DATA_2_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_2_CNT,F
;(1)
BZ
DATA_2_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_2_CHK
;(2)
DATA_2_CHK_END
DECFSZ
DATA_BIT_CNT,F
GOTO
DATA_3_CHK
GOTO
DATA_ALL_CHK_END
DATA_3_CHK
;DATA_3_CHK - DATA_31bit_END(30)
NOP
NOP
RLCF
DATA_3,F ;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
DATA_3_L
;(2)
DATA_3_H
NOP
;(1)
BSF
DATA_3,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_3_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
DATA_3_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_3_CNT,F
;(1)
BZ
DATA_3_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_3_CHK
;(2)
DATA_3_L
BCF
DATA_3,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_3_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
DATA_3_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_3_CNT,F
;(1)
BZ
DATA_3_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_3_CHK
;(2)
DATA_3_CHK_END
DECFSZ
DATA_BIT_CNT,F
GOTO
DATA_4_CHK
GOTO
DATA_ALL_CHK_END
DATA_4_CHK
;DATA_4_CHK - DATA_41bit_END(30)
NOP
NOP
RLCF
DATA_4,F ;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
DATA_4_L
;(2)
DATA_4_H
NOP
;(1)
BSF
DATA_4,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_4_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
DATA_4_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_4_CNT,F
;(1)
BZ
DATA_4_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_4_CHK
;(2)
DATA_4_L
BCF
DATA_4,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_4_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
DATA_4_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_4_CNT,F
;(1)
BZ
DATA_4_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_4_CHK
;(2)
DATA_4_CHK_END
DECFSZ
DATA_BIT_CNT,F
GOTO
DATA_5_CHK
GOTO
DATA_ALL_CHK_END
DATA_5_CHK
;DATA_5_CHK - DATA_51bit_END(30)
NOP
NOP
RLCF
DATA_5,F ;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
DATA_5_L
;(2)
DATA_5_H
NOP
;(1)
BSF
DATA_5,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_5_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
DATA_5_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_5_CNT,F
;(1)
BZ
DATA_5_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_5_CHK
;(2)
DATA_5_L
BCF
DATA_5,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_5_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
DATA_5_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_5_CNT,F
;(1)
BZ
DATA_5_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_5_CHK
;(2)
DATA_5_CHK_END
DECFSZ
DATA_BIT_CNT,F
GOTO
DATA_6_CHK
GOTO
DATA_ALL_CHK_END
DATA_6_CHK
;DATA_6_CHK - DATA_61bit_END(30)
NOP
NOP
RLCF
DATA_6,F ;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
DATA_6_L
;(2)
DATA_6_H
NOP
;(1)
BSF
DATA_6,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_6_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
DATA_6_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_6_CNT,F
;(1)
BZ
DATA_6_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_6_CHK
;(2)
DATA_6_L
BCF
DATA_6,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_6_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
DATA_6_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_6_CNT,F
;(1)
BZ
DATA_6_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_6_CHK
;(2)
DATA_6_CHK_END
DECFSZ
DATA_BIT_CNT,F
GOTO
DATA_7_CHK
GOTO
DATA_ALL_CHK_END
DATA_7_CHK
;DATA_7_CHK - DATA_71bit_END(30)
NOP
NOP
RLCF
DATA_7,F ;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
DATA_7_L
;(2)
DATA_7_H
NOP
;(1)
BSF
DATA_7,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_7_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
DATA_7_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_7_CNT,F
;(1)
BZ
DATA_7_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_7_CHK
;(2)
DATA_7_L
BCF
DATA_7,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_7_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
DATA_7_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_7_CNT,F
;(1)
BZ
DATA_7_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_7_CHK
;(2)
DATA_7_CHK_END
DECFSZ
DATA_BIT_CNT,F
GOTO
DATA_8_CHK
GOTO
DATA_ALL_CHK_END
DATA_8_CHK
;DATA_8_CHK - DATA_81bit_END(30)
NOP
NOP
RLCF
DATA_8,F ;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
DATA_8_L
;(2)
DATA_8_H
NOP
;(1)
BSF
DATA_8,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_8_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
DATA_8_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_8_CNT,F
;(1)
BZ
DATA_8_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_8_CHK
;(2)
DATA_8_L
BCF
DATA_8,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATA_8_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
DATA_8_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
DATA_8_CNT,F
;(1)
BZ
DATA_8_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
DATA_8_CHK
;(2)
DATA_8_CHK_END
NOP
GOTO
DATA_ALL_CHK_END
DATA_ALL_CHK_END
NOP
NOP
NOP
;↑↑↑↑ここまででデーターの取り出し終了↑↑↑↑
;******************************************************************
;CRCの検出
;******************************************************************
CRC_DATA_1_CHK
;CRC_DATA_1_CHK - CRC_DATA_11bit_END(30)
NOP
NOP
RLCF
CRC_DATA_1,F
;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
CRC_DATA_1_L
;(2)
CRC_DATA_1_H
NOP
;(1)
BSF
CRC_DATA_1,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
CRC_DATA_1_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
CRC_DATA_1_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
CRC_DATA_1_CNT,F
;(1)
BZ
CRC_DATA_1_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
CRC_DATA_1_CHK
;(2)
CRC_DATA_1_L
BCF
CRC_DATA_1,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
CRC_DATA_1_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
CRC_DATA_1_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
CRC_DATA_1_CNT,F
;(1)
BZ
CRC_DATA_1_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
CRC_DATA_1_CHK
;(2)
CRC_DATA_1_CHK_END
NOP
GOTO
CRC_DATA_2_CHK
CRC_DATA_2_CHK
;CRC_DATA_2_CHK - CRC_DATA_21bit_END(30)
NOP
NOP
RLCF
CRC_DATA_2,F
;(1)左に順送り
BTFSS
PORTC,4
;(1) skip(2)
GOTO
CRC_DATA_2_L
;(2)
CRC_DATA_2_H
NOP
;(1)
BSF
CRC_DATA_2,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
CRC_DATA_2_H_1bit_END
;(2)
CALL
H_5bit_
;
(2)
CRC_DATA_2_H_1bit_END
CALL
CYCLE_12_H
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
CRC_DATA_2_CNT,F
;(1)
BZ
CRC_DATA_2_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
CRC_DATA_2_CHK
;(2)
CRC_DATA_2_L
BCF
CRC_DATA_2,0
;(1)
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
CRC_DATA_2_L_1bit_END
;(2)
CALL
L_5bit_
;
(2)
CRC_DATA_2_L_1bit_END
CALL
CYCLE_12_L
;(15)CYCLE_12+CALL(2)=15CYCLE
DECF
CRC_DATA_2_CNT,F
;(1)
BZ
CRC_DATA_2_CHK_END
;(1) GOTO(2)
NOP
NOP
GOTO
CRC_DATA_2_CHK
;(2)
CRC_DATA_2_CHK_END
;↑↑↑↑ここまででCRCの取り出し終了↑↑↑↑
;******************************************************************
;解除データーの生成
;******************************************************************
KYE_DATA_MAKE
MOVLW
H'D1'
;(1)
質問
SUBWF
ID_LOW,W
;(1)
BTFSC
STATUS,Z
;(2)
GOTO
_D1_DATA_CHK
BTFSC
SADOU_PORT,0
GOTO
EOF_CHK_0
;平文の算出が終わっていれば'D0'はもう必要ない
MOVLW
H'D0'
;(1) 回答
SUBWF
ID_LOW,W
;(1)
BTFSC
STATUS,Z
;(2)
GOTO
_D0_DATA_CHK
GOTO
EOF_CHK_0
_D1_DATA_CHK
;質問がきたら DATA_X を DATA_X_0 に代入する。
INCF
_0D1_CNT,F
MOVF
DATA_1,W
MOVWF
DATA_1_0
MOVF
DATA_2,W
MOVWF
DATA_2_0
MOVF
DATA_3,W
MOVWF
DATA_3_0
MOVF
DATA_4,W
MOVWF
DATA_4_0
MOVF
DATA_5,W
MOVWF
DATA_5_0
MOVF
DATA_6,W
MOVWF
DATA_6_0
MOVF
DATA_7,W
MOVWF
DATA_7_0
MOVF
DATA_8,W
MOVWF
DATA_8_0
BTFSC
SADOU_PORT,0
GOTO
_plaintext
;平文の算出が終わっていれば_plaintext
にいく
GOTO
EOF_CHK_0
_D0_DATA_CHK
MOVF
DATA_1,W
MOVWF
DATAX_1_0
MOVF
DATA_2,W
MOVWF
DATAX_2_0
MOVF
DATA_3,W
MOVWF
DATAX_3_0
MOVF
DATA_4,W
MOVWF
DATAX_4_0
MOVF
DATA_5,W
MOVWF
DATAX_5_0
MOVF
DATA_6,W
MOVWF
DATAX_6_0
MOVF
DATA_7,W
MOVWF
DATAX_7_0
MOVF
DATA_8,W
MOVWF
DATAX_8_0
GOTO
DATA_conversion
_plaintext
MOVF
plaintext_DATA_1,W
MOVWF
DATAX_1_0
MOVF
plaintext_DATA_2,W
MOVWF
DATAX_2_0
MOVF
plaintext_DATA_3,W
MOVWF
DATAX_3_0
MOVF
plaintext_DATA_4,W
MOVWF
DATAX_4_0
MOVF
plaintext_DATA_5,W
MOVWF
DATAX_5_0
MOVF
plaintext_DATA_6,W
MOVWF
DATAX_6_0
MOVF
plaintext_DATA_7,W
MOVWF
DATAX_7_0
MOVF
plaintext_DATA_8,W
MOVWF
DATAX_8_0
DATA_conversion
BTFSC
DATA_2_0,7
CALL
_2N1
BTFSC
DATA_2_0,6
CALL
_2N2
BTFSC
DATA_2_0,5
CALL
_2N3
BTFSC
DATA_2_0,4
CALL
_2N4
BTFSC
DATA_2_0,3
CALL
_2N5
BTFSC
DATA_2_0,2
CALL
_2N6
BTFSC
DATA_2_0,1
CALL
_2N7
BTFSC
DATA_2_0,0
CALL
_2N8
BTFSC
DATA_3_0,7
CALL
_3N1
BTFSC
DATA_3_0,6
CALL
_3N2
BTFSC
DATA_3_0,5
CALL
_3N3
BTFSC
DATA_3_0,4
CALL
_3N4
BTFSC
DATA_3_0,3
CALL
_3N5
BTFSC
DATA_3_0,2
CALL
_3N6
BTFSC
DATA_3_0,1
CALL
_3N7
BTFSC
DATA_3_0,0
CALL
_3N8
BTFSC
DATA_4_0,7
CALL
_4N1
BTFSC
DATA_4_0,6
CALL
_4N2
BTFSC
DATA_4_0,5
CALL
_4N3
BTFSC
DATA_4_0,4
CALL
_4N4
BTFSC
DATA_4_0,3
CALL
_4N5
BTFSC
DATA_4_0,2
CALL
_4N6
BTFSC
DATA_4_0,1
CALL
_4N7
BTFSC
DATA_4_0,0
CALL
_4N8
BTFSC
DATA_5_0,7
CALL
_5N1
BTFSC
DATA_5_0,6
CALL
_5N2
BTFSC
DATA_5_0,5
CALL
_5N3
BTFSC
DATA_5_0,4
CALL
_5N4
BTFSC
DATA_5_0,3
CALL
_5N5
BTFSC
DATA_5_0,2
CALL
_5N6
BTFSC
DATA_5_0,1
CALL
_5N7
BTFSC
DATA_5_0,0
CALL
_5N8
BTFSC
DATA_6_0,7
CALL
_6N1
BTFSC
DATA_6_0,6
CALL
_6N2
BTFSC
DATA_6_0,5
CALL
_6N3
BTFSC
DATA_6_0,4
CALL
_6N4
BTFSC
DATA_6_0,3
CALL
_6N5
BTFSC
DATA_6_0,2
CALL
_6N6
BTFSC
DATA_6_0,1
CALL
_6N7
BTFSC
DATA_6_0,0
CALL
_6N8
BTFSC
DATA_7_0,7
CALL
_7N1
BTFSC
DATA_7_0,6
CALL
_7N2
BTFSC
DATA_7_0,5
CALL
_7N3
BTFSC
DATA_7_0,4
CALL
_7N4
BTFSC
DATA_7_0,3
CALL
_7N5
BTFSC
DATA_7_0,2
CALL
_7N6
BTFSC
DATA_7_0,1
CALL
_7N7
BTFSC
DATA_7_0,0
CALL
_7N8
BTFSC
DATA_8_0,7
CALL
_8N1
BTFSC
DATA_8_0,6
CALL
_8N2
BTFSC
DATA_8_0,5
CALL
_8N3
BTFSC
DATA_8_0,4
CALL
_8N4
BTFSC
DATA_8_0,3
CALL
_8N5
BTFSC
DATA_8_0,2
CALL
_8N6
BTFSC
DATA_8_0,1
CALL
_8N7
BTFSC
DATA_8_0,0
CALL
_8N8
BTFSC
SADOU_PORT,0
GOTO
KYE_DATA_MAKE_END
MOVF
DATAX_1_0,W
MOVWF
plaintext_DATA_1
MOVF
DATAX_2_0,W
MOVWF
plaintext_DATA_2
MOVF
DATAX_3_0,W
MOVWF
plaintext_DATA_3
MOVF
DATAX_4_0,W
MOVWF
plaintext_DATA_4
MOVF
DATAX_5_0,W
MOVWF
plaintext_DATA_5
MOVF
DATAX_6_0,W
MOVWF
plaintext_DATA_6
MOVF
DATAX_7_0,W
MOVWF
plaintext_DATA_7
MOVF
DATAX_8_0,W
MOVWF
plaintext_DATA_8
BSF
SADOU_PORT,0
BCF
PORTB,7
;LED
MOVLW
H'00'
MOVWF
EEADR_CNT
MOVF
SADOU_PORT,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
MOVLW
H'01'
MOVWF
EEADR_CNT
MOVF
plaintext_DATA_1,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
MOVLW
H'02'
MOVWF
EEADR_CNT
MOVF
plaintext_DATA_2,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
MOVLW
H'03'
MOVWF
EEADR_CNT
MOVF
plaintext_DATA_3,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
MOVLW
H'04'
MOVWF
EEADR_CNT
MOVF
plaintext_DATA_4,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
MOVLW
H'05'
MOVWF
EEADR_CNT
MOVF
plaintext_DATA_5,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
MOVLW
H'06'
MOVWF
EEADR_CNT
MOVF
plaintext_DATA_6,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
MOVLW
H'07'
MOVWF
EEADR_CNT
MOVF
plaintext_DATA_7,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
MOVLW
H'08'
MOVWF
EEADR_CNT
MOVF
plaintext_DATA_8,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
GOTO
Main
KYE_DATA_MAKE_END
;↑↑↑↑ここまでで平文データー/解除データの作成終了↑↑↑↑
;******************************************************************
;CRCデーターの生成
;******************************************************************
CRC_DATA_MAKE
CLRF
CRC_L
CLRF
CRC_H
CLRF
CRC_L_X
CLRF
CRC_H_X
;_SOF
CALL
IN_L
;_0
CALL
IN_L
CALL
IN_L
CALL
IN_L
;_D
CALL
IN_H
CALL
IN_H
CALL
IN_L
CALL
IN_H
;_0
CALL
IN_L
CALL
IN_L
CALL
IN_L
CALL
IN_L
;_RRR
CALL
IN_L
CALL
IN_L
CALL
IN_L
;_1000
CALL
IN_H
CALL
IN_L
CALL
IN_L
CALL
IN_L
DATAX_1_CRC
MOVLW
D'8'
MOVWF
DATA_BIT_CNT
MOVF
DATAX_1_0,W
MOVWF
DATA_X
DATAX_1_CRC_LP
BTFSC
DATA_X,7
CALL
IN_H
BTFSS
DATA_X,7
CALL
IN_L
RLCF
DATA_X,F
DECFSZ
DATA_BIT_CNT,F
GOTO
DATAX_1_CRC_LP
DATAX_2_CRC
MOVLW
D'8'
MOVWF
DATA_BIT_CNT
MOVF
DATAX_2_0,W
MOVWF
DATA_X
DATAX_2_CRC_LP
BTFSC
DATA_X,7
CALL
IN_H
BTFSS
DATA_X,7
CALL
IN_L
RLCF
DATA_X,F
DECFSZ
DATA_BIT_CNT,F
GOTO
DATAX_2_CRC_LP
DATAX_3_CRC
MOVLW
D'8'
MOVWF
DATA_BIT_CNT
MOVF
DATAX_3_0,W
MOVWF
DATA_X
DATAX_3_CRC_LP
BTFSC
DATA_X,7
CALL
IN_H
BTFSS
DATA_X,7
CALL
IN_L
RLCF
DATA_X,F
DECFSZ
DATA_BIT_CNT,F
GOTO
DATAX_3_CRC_LP
DATAX_4_CRC
MOVLW
D'8'
MOVWF
DATA_BIT_CNT
MOVF
DATAX_4_0,W
MOVWF
DATA_X
DATAX_4_CRC_LP
BTFSC
DATA_X,7
CALL
IN_H
BTFSS
DATA_X,7
CALL
IN_L
RLCF
DATA_X,F
DECFSZ
DATA_BIT_CNT,F
GOTO
DATAX_4_CRC_LP
DATAX_5_CRC
MOVLW
D'8'
MOVWF
DATA_BIT_CNT
MOVF
DATAX_5_0,W
MOVWF
DATA_X
DATAX_5_CRC_LP
BTFSC
DATA_X,7
CALL
IN_H
BTFSS
DATA_X,7
CALL
IN_L
RLCF
DATA_X,F
DECFSZ
DATA_BIT_CNT,F
GOTO
DATAX_5_CRC_LP
DATAX_6_CRC
MOVLW
D'8'
MOVWF
DATA_BIT_CNT
MOVF
DATAX_6_0,W
MOVWF
DATA_X
DATAX_6_CRC_LP
BTFSC
DATA_X,7
CALL
IN_H
BTFSS
DATA_X,7
CALL
IN_L
RLCF
DATA_X,F
DECFSZ
DATA_BIT_CNT,F
GOTO
DATAX_6_CRC_LP
DATAX_7_CRC
MOVLW
D'8'
MOVWF
DATA_BIT_CNT
MOVF
DATAX_7_0,W
MOVWF
DATA_X
DATAX_7_CRC_LP
BTFSC
DATA_X,7
CALL
IN_H
BTFSS
DATA_X,7
CALL
IN_L
RLCF
DATA_X,F
DECFSZ
DATA_BIT_CNT,F
GOTO
DATAX_7_CRC_LP
DATAX_8_CRC
MOVLW
D'8'
MOVWF
DATA_BIT_CNT
MOVF
DATAX_8_0,W
MOVWF
DATA_X
DATAX_8_CRC_LP
BTFSC
DATA_X,7
CALL
IN_H
BTFSS
DATA_X,7
CALL
IN_L
RLCF
DATA_X,F
DECFSZ
DATA_BIT_CNT,F
GOTO
DATAX_8_CRC_LP
CRC_MAKE_END
;↑↑↑↑ここまででCRCの作成終了↑↑↑↑
GOTO
DATA_Processing_CHK
;******************************************************************
;データーの再現
;******************************************************************
DATA_Processing_CHK
MOVLW
D'50'
SUBWF
_0D1_CNT,W
;50回を越えたらプログラム停止
BTFSC
STATUS,Z
GOTO
FULL_CNT_STOP
DATA_Processing
;解除キーの送出
MOVLW
D'5'
;
MOVWF
H_5bit_CHK
;
MOVLW
D'2'
;
MOVWF
L_5bit_CHK
;
MOVLW
D'8'
;
MOVWF
DATA_1_CNT
MOVWF
DATA_2_CNT
MOVWF
DATA_3_CNT
MOVWF
DATA_4_CNT
MOVWF
DATA_5_CNT
MOVWF
DATA_6_CNT
MOVWF
DATA_7_CNT
MOVWF
DATA_8_CNT
MOVWF
CRC_DATA_1_CNT
MOVWF
CRC_DATA_2_CNT
MOVF
DATAX_1_0,W
MOVWF
Reproduce_DATA1
MOVF
DATAX_2_0,W
MOVWF
Reproduce_DATA2
MOVF
DATAX_3_0,W
MOVWF
Reproduce_DATA3
MOVF
DATAX_4_0,W
MOVWF
Reproduce_DATA4
MOVF
DATAX_5_0,W
MOVWF
Reproduce_DATA5
MOVF
DATAX_6_0,W
MOVWF
Reproduce_DATA6
MOVF
DATAX_7_0,W
MOVWF
Reproduce_DATA7
MOVF
DATAX_8_0,W
MOVWF
Reproduce_DATA8
MOVF
CRC_H,W
MOVWF
Reproduce_CRC_H
MOVF
CRC_L,W
MOVWF
Reproduce_CRC_L
EOF_CHK_MATI_LP
BTFSC
PORTC,4
;(2)
GOTO
EOF_CHK_MATI_LP
EOF_CHK_B
MOVLW
D'12'
;終了の連続ビット
MOVWF
BIT_CNT
EOF_CHK_B_LP
BTFSS
PORTC,4
;(2)
GOTO
EOF_CHK_B_LP
CALL
CYCLE_29
;(12)CYCLE_10+CALL(2)=12CYCLE
EOF_CHK_B2
CALL
CYCLE_27
;(12)CYCLE_25+CALL(2)=27CYCLE
BTFSS
PORTC,4
;(2)
GOTO
EOF_CHK_B
DECFSZ
BIT_CNT,F
;(1)
GOTO
EOF_CHK_B2
;(2)
;↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ここから↓↓↓↓↓↓↓↓↓↓↓↓↓
;_SOF
BCF
PORTC,5
CALL
CYCLE_29
;_0
BCF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
;_D
BSF
PORTC,5
CALL
CYCLE_29
BSF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
BSF
PORTC,5
CALL
CYCLE_29
;_0
BCF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
;_RRR
BC
PORTC,5
CALL
CYCLE_29
BSF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
;_1000
BSF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_26
DATAX_1_Reproduce
BTFSS
Reproduce_DATA1,7
GOTO
DATAX_1_L
DATAX_1_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_1_1bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
DATAX_1_1bit_END
;(2)
DATAX_1_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_1_1bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
DATAX_1_1bit_END
;(2)
DATAX_1_1bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_DATA1,F
;(1)左に順送り
DECFSZ
DATA_1_CNT,F
;(1) skip(2)
GOTO
DATAX_1_Reproduce
;(2)
DATAX_2_Reproduce
BTFSS
Reproduce_DATA2,7
GOTO
DATAX_2_L
DATAX_2_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_2_1bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
DATAX_2_1bit_END
;(2)
DATAX_2_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_2_1bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
DATAX_2_1bit_END
;(2)
DATAX_2_1bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_DATA2,F
;(1)左に順送り
DECFSZ
DATA_2_CNT,F
;(1) skip(2)
GOTO
DATAX_2_Reproduce
;(2)
DATAX_3_Reproduce
BTFSS
Reproduce_DATA3,7
GOTO
DATAX_3_L
DATAX_3_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_3_1bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
DATAX_3_1bit_END
;(2)
DATAX_3_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_3_1bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
DATAX_3_1bit_END
;(2)
DATAX_3_1bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_DATA3,F
;(1)左に順送り
DECFSZ
DATA_3_CNT,F
;(1) skip(2)
GOTO
DATAX_3_Reproduce
;(2)
DATAX_4_Reproduce
BTFSS
Reproduce_DATA4,7
GOTO
DATAX_4_L
DATAX_4_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_4_1bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
DATAX_4_1bit_END
;(2)
DATAX_4_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_4_1bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
DATAX_4_1bit_END
;(2)
DATAX_4_1bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_DATA4,F
;(1)左に順送り
DECFSZ
DATA_4_CNT,F
;(1) skip(2)
GOTO
DATAX_4_Reproduce
;(2)
DATAX_5_Reproduce
BTFSS
Reproduce_DATA5,7
GOTO
DATAX_5_L
DATAX_5_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_5_1bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
DATAX_5_1bit_END
;(2)
DATAX_5_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_5_1bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
DATAX_5_1bit_END
;(2)
DATAX_5_1bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_DATA5,F
;(1)左に順送り
DECFSZ
DATA_5_CNT,F
;(1) skip(2)
GOTO
DATAX_5_Reproduce
;(2)
DATAX_6_Reproduce
BTFSS
Reproduce_DATA6,7
GOTO
DATAX_6_L
DATAX_6_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_6_1bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
DATAX_6_1bit_END
;(2)
DATAX_6_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_6_1bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
DATAX_6_1bit_END
;(2)
DATAX_6_1bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_DATA6,F
;(1)左に順送り
DECFSZ
DATA_6_CNT,F
;(1) skip(2)
GOTO
DATAX_6_Reproduce
;(2)
DATAX_7_Reproduce
BTFSS
Reproduce_DATA7,7
GOTO
DATAX_7_L
DATAX_7_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_7_1bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
DATAX_7_1bit_END
;(2)
DATAX_7_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_7_1bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
DATAX_7_1bit_END
;(2)
DATAX_7_1bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_DATA7,F
;(1)左に順送り
DECFSZ
DATA_7_CNT,F
;(1) skip(2)
GOTO
DATAX_7_Reproduce
;(2)
DATAX_8_Reproduce
BTFSS
Reproduce_DATA8,7
GOTO
DATAX_8_L
DATAX_8_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_8_8bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
DATAX_8_8bit_END
;(2)
DATAX_8_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
DATAX_8_8bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
DATAX_8_8bit_END
;(2)
DATAX_8_8bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_DATA8,F
;(1)左に順送り
DECFSZ
DATA_8_CNT,F
;(1) skip(2)
GOTO
DATAX_8_Reproduce
;(2)
CRC_H_Reproduce
BTFSS
Reproduce_CRC_H,7
GOTO
CRC_H_L
CRC_H_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
CRC_H_1bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
CRC_H_1bit_END
;(2)
CRC_H_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
CRC_H_1bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
CRC_H_1bit_END
;(2)
CRC_H_1bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_CRC_H,F
;(1)左に順送り
DECFSZ
CRC_DATA_1_CNT,F
;(1) skip(2)
GOTO
CRC_H_Reproduce
;(2)
CRC_L_Reproduce
BTFSS
Reproduce_CRC_L,7
GOTO
CRC_L_L
CRC_L_H
NOP
BSF
PORTC,5
;(1)
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
DECFSZ
H_5bit_CHK,F
;(1) skip(2)
GOTO
CRC_L_1bit_END
;(2)
CALL
H_5bit_Reproduce
;(2)
GOTO
CRC_L_1bit_END
;(2)
CRC_L_L
BCF
PORTC,5
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
DECFSZ
L_5bit_CHK,F
;(1) skip(2)
GOTO
CRC_L_1bit_END
;(2)
CALL
L_5bit_Reproduce
;(2)
GOTO
CRC_L_1bit_END
;(2)
CRC_L_1bit_END
CALL
CYCLE_17
;
RLCF
Reproduce_CRC_L,F
;(1)左に順送り
DECFSZ
CRC_DATA_2_CNT,F
;(1) skip(2)
GOTO
CRC_L_Reproduce
;(2)
;******************************************************************
BSF
PORTB,7
;LED
CALL
TIME20M
BCF
PORTB,7
;LED
INCF
ID_0D_CNT,F
MOVLW
D'05'
SUBWF
ID_0D_CNT,W
BTFSC
STATUS,Z
GOTO
DUMY_DO
GOTO
EOF_CHK_0
;******************************************************************
;解除キー作成処理
;******************************************************************
_2N1
;0000 0080 0800 0200
MOVLW
80H
XORWF
DATAX_4_0,F
MOVLW
08H
XORWF
DATAX_5_0,F
MOVLW
02H
XORWF
DATAX_7_0,F
RETURN
_2N2
;0000 2000 0400 0040
MOVLW
20H
XORWF
DATAX_3_0,F
MOVLW
04H
XORWF
DATAX_5_0,F
MOVLW
40H
XORWF
DATAX_8_0,F
RETURN
_2N3
;0008 0000 0204 0000
MOVLW
08H
XORWF
DATAX_2_0,F
MOVLW
02H
XORWF
DATAX_5_0,F
MOVLW
04H
XORWF
DATAX_6_0,F
RETURN
_2N4
;0000 1000 0100 0002
MOVLW
10H
XORWF
DATAX_3_0,F
MOVLW
01H
XORWF
DATAX_5_0,F
MOVLW
02H
XORWF
DATAX_8_0,F
RETURN
_2N5
;0000 4000 0280 0000
MOVLW
40H
XORWF
DATAX_3_0,F
MOVLW
02H
XORWF
DATAX_5_0,F
MOVLW
80H
XORWF
DATAX_6_0,F
RETURN
_2N6
;0000 0001 0040 0004
MOVLW
01H
XORWF
DATAX_4_0,F
MOVLW
40H
XORWF
DATAX_6_0,F
MOVLW
04H
XORWF
DATAX_8_0,F
RETURN
_2N7
;0010 0000 0021 0000
MOVLW
10H
XORWF
DATAX_2_0,F
MOVLW
21H
XORWF
DATAX_6_0,F
RETURN
_2N8
;0000 0040 0018 0000
MOVLW
40H
XORWF
DATAX_4_0,F
MOVLW
18H
XORWF
DATAX_6_0,F
RETURN
_3N1
;0000 0100 0808 0000
MOVLW
01H
XORWF
DATAX_3_0,F
MOVLW
08H
XORWF
DATAX_5_0,F
MOVLW
08H
XORWF
DATAX_6_0,F
RETURN
_3N2
;0020 0000 0084 0000
MOVLW
20H
XORWF
DATAX_2_0,F
MOVLW
84H
XORWF
DATAX_6_0,F
RETURN
_3N3
;0000 0004 0012 0000
MOVLW
04H
XORWF
DATAX_4_0,F
MOVLW
12H
XORWF
DATAX_6_0,F
RETURN
_3N4
;0000 0000 2041 0000
MOVLW
20H
XORWF
DATAX_5_0,F
MOVLW
41H
XORWF
DATAX_6_0,F
RETURN
_3N5
;0040 0000 0002 8000
MOVLW
40H
XORWF
DATAX_2_0,F
MOVLW
02H
XORWF
DATAX_6_0,F
MOVLW
80H
XORWF
DATAX_7_0,F
RETURN
_3N6
;0000 0800 0400 4000
MOVLW
08H
XORWF
DATAX_3_0,F
MOVLW
04H
XORWF
DATAX_5_0,F
MOVLW
40H
XORWF
DATAX_7_0,F
RETURN
_3N7
;0000 0000 8000 6000
MOVLW
80H
XORWF
DATAX_5_0,F
MOVLW
60H
XORWF
DATAX_7_0,F
RETURN
_3N8
;0080 0000 0000 1800
MOVLW
80H
XORWF
DATAX_2_0,F
MOVLW
18H
XORWF
DATAX_7_0,F
RETURN
_4N1
;0000 0020 0000 2800
MOVLW
20H
XORWF
DATAX_4_0,F
MOVLW
28H
XORWF
DATAX_7_0,F
RETURN
_4N2
;0000 8000 0000 1400
MOVLW
80H
XORWF
DATAX_3_0,F
MOVLW
14H
XORWF
DATAX_7_0,F
RETURN
_4N3
;0000 0200 0000 0208
MOVLW
02H
XORWF
DATAX_3_0,F
MOVLW
02H
XORWF
DATAX_7_0,F
MOVLW
08H
XORWF
DATAX_8_0,F
RETURN
_4N4
;0000 0002 0000 0101
MOVLW
02H
XORWF
DATAX_4_0,F
MOVLW
01H
XORWF
DATAX_7_0,F
MOVLW
01H
XORWF
DATAX_8_0,F
RETURN
_4N5
;0000 0008 0000 0000
MOVLW
08H
XORWF
DATAX_4_0,F
RETURN
_4N6
;0001 0000 0000 0440
MOVLW
01H
XORWF
DATAX_2_0,F
MOVLW
04H
XORWF
DATAX_7_0,F
MOVLW
40H
XORWF
DATAX_8_0,F
RETURN
_4N7
;0000 0000 1020 0020
MOVLW
10H
XORWF
DATAX_5_0,F
MOVLW
20H
XORWF
DATAX_6_0,F
MOVLW
20H
XORWF
DATAX_8_0,F
RETURN
_4N8
;0000 0000 4000 0110
MOVLW
40H
XORWF
DATAX_5_0,F
MOVLW
01H
XORWF
DATAX_7_0,F
MOVLW
10H
XORWF
DATAX_8_0,F
RETURN
_5N1
;0000 0400 0000 8008
MOVLW
04H
XORWF
DATAX_3_0,F
MOVLW
80H
XORWF
DATAX_7_0,F
MOVLW
08H
XORWF
DATAX_8_0,F
RETURN
_5N2
;0000 0010 0000 0024
MOVLW
10H
XORWF
DATAX_4_0,F
MOVLW
24H
XORWF
DATAX_8_0,F
RETURN
_5N3
;0004 0000 0000 0012
MOVLW
04H
XORWF
DATAX_2_0,F
MOVLW
12H
XORWF
DATAX_8_0,F
RETURN
_5N4
;0002 0000 0100 0001
MOVLW
02H
XORWF
DATAX_2_0,F
MOVLW
01H
XORWF
DATAX_5_0,F
MOVLW
01H
XORWF
DATAX_8_0,F
RETURN
_5N5
;0080 0020 0000 2000
MOVLW
80H
XORWF
DATAX_2_0,F
MOVLW
20H
XORWF
DATAX_4_0,F
MOVLW
20H
XORWF
DATAX_7_0,F
RETURN
_5N6
;0040 0004 0010 0000
MOVLW
40H
XORWF
DATAX_2_0,F
MOVLW
04H
XORWF
DATAX_4_0,F
MOVLW
10H
XORWF
DATAX_6_0,F
RETURN
_5N7
;0020 4000 0200 0000
MOVLW
20H
XORWF
DATAX_2_0,F
MOVLW
40H
XORWF
DATAX_3_0,F
MOVLW
02H
XORWF
DATAX_5_0,F
RETURN
_5N8
;0010 0000 2040 0000
MOVLW
10H
XORWF
DATAX_2_0,F
MOVLW
20H
XORWF
DATAX_5_0,F
MOVLW
40H
XORWF
DATAX_6_0,F
RETURN
_6N1
;0028 0000 0080 0000
MOVLW
28H
XORWF
DATAX_2_0,F
MOVLW
80H
XORWF
DATAX_6_0,F
RETURN
_6N2
;0004 0000 4000 0100
MOVLW
04H
XORWF
DATAX_2_0,F
MOVLW
40H
XORWF
DATAX_5_0,F
MOVLW
01H
XORWF
DATAX_7_0,F
RETURN
_6N3
;0002 1000 0000 0002
MOVLW
02H
XORWF
DATAX_2_0,F
MOVLW
10H
XORWF
DATAX_3_0,F
MOVLW
02H
XORWF
DATAX_8_0,F
RETURN
_6N4
;0001 8000 0000 1000
MOVLW
01H
XORWF
DATAX_2_0,F
MOVLW
80H
XORWF
DATAX_3_0,F
MOVLW
10H
XORWF
DATAX_7_0,F
RETURN
_6N5
;0080 8000 0000 0800
MOVLW
80H
XORWF
DATAX_2_0,F
MOVLW
80H
XORWF
DATAX_3_0,F
MOVLW
08H
XORWF
DATAX_7_0,F
RETURN
_6N6
;0008 4000 0004 0000
MOVLW
08H
XORWF
DATAX_2_0,F
MOVLW
40H
XORWF
DATAX_3_0,F
MOVLW
04H
XORWF
DATAX_6_0,F
RETURN
_6N7
;0001 2000 0000 0400
MOVLW
01H
XORWF
DATAX_2_0,F
MOVLW
20H
XORWF
DATAX_3_0,F
MOVLW
04H
XORWF
DATAX_7_0,F
RETURN
_6N8
;0004 1000 0000 0010
MOVLW
04H
XORWF
DATAX_2_0,F
MOVLW
10H
XORWF
DATAX_3_0,F
MOVLW
10H
XORWF
DATAX_8_0,F
RETURN
_7N1
;0000 2800 0000 0040
MOVLW
28H
XORWF
DATAX_3_0,F
MOVLW
40H
XORWF
DATAX_8_0,F
RETURN
_7N2
;0040 0400 0002 0000
MOVLW
40H
XORWF
DATAX_2_0,F
MOVLW
04H
XORWF
DATAX_3_0,F
MOVLW
02H
XORWF
DATAX_6_0,F
RETURN
_7N3
;0000 0600 0000 8000
MOVLW
06H
XORWF
DATAX_3_0,F
MOVLW
80H
XORWF
DATAX_7_0,F
RETURN
_7N4
;0000 0180 0000 0200
MOVLW
01H
XORWF
DATAX_3_0,F
MOVLW
80H
XORWF
DATAX_4_0,F
MOVLW
02H
XORWF
DATAX_7_0,F
RETURN
_7N5
;0000 0280 0000 0008
MOVLW
02H
XORWF
DATAX_3_0,F
MOVLW
80H
XORWF
DATAX_4_0,F
MOVLW
08H
XORWF
DATAX_8_0,F
RETURN
_7N6
;0000 0140 0800 0000
MOVLW
01H
XORWF
DATAX_3_0,F
MOVLW
40H
XORWF
DATAX_4_0,F
MOVLW
08H
XORWF
DATAX_5_0,F
RETURN
_7N7
;0000 0020 8000 4000
MOVLW
20H
XORWF
DATAX_4_0,F
MOVLW
80H
XORWF
DATAX_5_0,F
MOVLW
40H
XORWF
DATAX_7_0,F
RETURN
_7N8
;0000 0010 1020 0000
MOVLW
10H
XORWF
DATAX_4_0,F
MOVLW
10H
XORWF
DATAX_5_0,F
MOVLW
20H
XORWF
DATAX_6_0,F
RETURN
_8N1
;0000 0000 0000 0080
MOVLW
80H
XORWF
DATAX_8_0,F
RETURN
_8N2
;0000 0044 0008 0000
MOVLW
44H
XORWF
DATAX_4_0,F
MOVLW
08H
XORWF
DATAX_6_0,F
RETURN
_8N3
;0002 0002 0100 0000
MOVLW
02H
XORWF
DATAX_2_0,F
MOVLW
02H
XORWF
DATAX_4_0,F
MOVLW
01H
XORWF
DATAX_5_0,F
RETURN
_8N4
;0000 0011 0000 0020
MOVLW
11H
XORWF
DATAX_4_0,F
MOVLW
20H
XORWF
DATAX_8_0,F
RETURN
_8N5
;0000 0800 8400 0000
MOVLW
08H
XORWF
DATAX_3_0,F
MOVLW
84H
XORWF
DATAX_5_0,F
RETURN
_8N6
;0000 0002 4000 0001
MOVLW
02H
XORWF
DATAX_4_0,F
MOVLW
40H
XORWF
DATAX_5_0,F
MOVLW
01H
XORWF
DATAX_8_0,F
RETURN
_8N7
;0000 0001 2000 0004
MOVLW
01H
XORWF
DATAX_4_0,F
MOVLW
20H
XORWF
DATAX_5_0,F
MOVLW
04H
XORWF
DATAX_8_0,F
RETURN
_8N8
;0010 0000 1001 0000
MOVLW
10H
XORWF
DATAX_2_0,F
MOVLW
10H
XORWF
DATAX_5_0,F
MOVLW
01H
XORWF
DATAX_6_0,F
RETURN
;******************************************************************
;CRC作成処理
;******************************************************************
;CRCNXT = NXTBIT
EXOR CRC_RG(14)
;14ビット目をXORした結果をCRCNXTとする
;CRC_RG(14:1) =
CRC_RG(13:0); // shift left by
;従来のCRCを左にシフトする
;CRC_RG(0) = 0; // 1
position
;0ビット目はクリア
;IF CRCNXT THEN
;CRCNXTが真(1)であればCRCを4599でXORする
;CRC_RG(14:0) =
CRC_RG(14:0) EXOR (4599hex);
;ENDIF
IN_L
MOVF
CRC_H,W
MOVWF
CRC_H_X
;1ビットだけXORしたいので仮に代入する
MOVLW
B'00000000'
XORWF
CRC_H_X,F
BTFSC
CRC_H_X,7
GOTO
XOR_H
;結果によって
XOR_H XOR_L へ進む
GOTO
XOR_L
IN_H
MOVF
CRC_H,W
MOVWF
CRC_H_X
MOVLW
B'10000000'
XORWF
CRC_H_X,F
BTFSC
CRC_H_X,7
GOTO
XOR_H
GOTO
XOR_L
XOR_L
;偽(0)だったのでシフトして0ビット(CRC_L,1)をクリアだけをする
RLCF
CRC_H,F
RLCF
CRC_L,F
BCF
CRC_H,0
BTFSC
STATUS,C
BSF
CRC_H,0
BCF
CRC_L,1
BSF
CRC_L,0
;ドミナントはエラーフラグなのでリセッシブルにする。
RETURN
XOR_H
;真(1)だったのでシフトして0ビット(CRC_L,1)をクリアしたのち、CRCを4599でXORする
RLCF
CRC_H,F
RLCF
CRC_L,F
BCF
CRC_H,0
BTFSC
STATUS,C
BSF
CRC_H,0
BCF
CRC_L,1
MOVLW
B'10001011'
XORWF
CRC_H,F
MOVLW
B'00110010'
XORWF
CRC_L,F
BSF
CRC_L,0
;ドミナントはエラーフラグなのでリセッシブルにする。
RETURN
;******************************************************************
;スタッフビット再現処理
;******************************************************************
H_5bit_Reproduce
;Hビットが5回連続した時逆位相再現
CALL
CYCLE_19
MOVLW
D'5'
;(1)
MOVWF
H_5bit_CHK
;(1)
MOVLW
D'4'
;(1)
MOVWF
L_5bit_CHK
;(1)
BCF
PORTC,5
NOP
RETURN
;(2)
L_5bit_Reproduce
;Lビットが5回連続した時逆位相再現
CALL
CYCLE_19
MOVLW
D'5'
;(1)
MOVWF
L_5bit_CHK
;(1)
MOVLW
D'4'
;(1)
MOVWF
H_5bit_CHK
;(1)
BSF
PORTC,5
NOP
RETURN
;(2)
;******************************************************************
;記憶消去
;******************************************************************
RE_SET
MOVLW
D'100'
MOVWF
CNT4
SW_CHK_LP
BTFSC
PORTA,3
GOTO
EOF_CHK_0
CALL
TIME20M
DECFSZ
CNT4,F
GOTO
SW_CHK_LP
MOVLW
H'00'
MOVWF
EEADR_CNT
MOVWF
SETTEI_CNT
CALL
EE_WRITE
MOVLW
H'01'
MOVWF
EEADR_CNT
CALL
EE_WRITE
MOVLW
H'02'
MOVWF
EEADR_CNT
CALL
EE_WRITE
MOVLW
H'03'
MOVWF
EEADR_CNT
CALL
EE_WRITE
MOVLW
H'04'
MOVWF
EEADR_CNT
CALL
EE_WRITE
MOVLW
H'05'
MOVWF
EEADR_CNT
CALL
EE_WRITE
MOVLW
H'06'
MOVWF
EEADR_CNT
CALL
EE_WRITE
MOVLW
H'07'
MOVWF
EEADR_CNT
CALL
EE_WRITE
MOVLW
H'08'
MOVWF
EEADR_CNT
CALL
EE_WRITE
GOTO
RE_START
FULL_CNT_STOP
BSF
FULL_END_CNT,0
MOVLW
H'0F'
MOVWF
EEADR_CNT
MOVF
FULL_END_CNT,W ;
MOVWF
SETTEI_CNT
CALL
EE_WRITE
FULL_CNT_STOP_LP
CLRWDT
GOTO
FULL_CNT_STOP_LP
DUMY_1
CLRF
CNT1
DUMY_1_LP
CLRWDT
BSF
PORTC,5
CALL
CYCLE_29
BCF
PORTC,5
CALL
CYCLE_29
DECFSZ
CNT1,F
GOTO
DUMY_1_LP
RETURN
DUMY_DO
BSF
PORTB,7
;LED 消灯していれば記憶している
CLRF
CNT2
DUMY_2_LP
CALL
DUMY_1
DECFSZ
CNT2,F
GOTO
DUMY_2_LP
BCF
PORTB,7
;LED
平文の記憶がまだならLED点灯
DUMY_DO_LP
CLRWDT
NOP
NOP
GOTO
DUMY_DO_LP
END
|