;This is D-PCM TYPE ONDEJI NEXT ASM
;                25-08-2001 V1.0　　SLIDE-fukkatubann (non log)
; 
; 　　　BUG　FIX　
;
	list	p=16F84a
	include <P16F84a.INC>

	__config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _CP_OFF

;BANK1

	BSF	STATUS,RP0	
	BCF	STATUS,RP1

	MOVLW	B'11000100'	;PORT A BIT 2= INPUT)
	MOVWF	TRISA	;WRITE
	MOVLW	B'00000000'	;PORT B OUTPUT
	MOVWF	TRISB	;WRITE
;BANK0
	BCF	STATUS,RP0	


	MOVLW	H'80'
	MOVWF	H'30'	
	MOVWF	H'31'	
　	MOVWF	H'32'
	MOVWF	H'33'	
	MOVWF	H'34'	
	MOVWF	H'35'	
	MOVWF	H'36'	
	MOVWF	H'37'    
	MOVWF	H'40'	
	MOVWF	H'41'	
	MOVWF	H'42'	
	MOVWF	H'43'	
	MOVWF	H'44'	
	MOVWF	H'45'	
	MOVWF	H'46'	
	MOVWF	H'47'	

	MOVLW	H'80'
	MOVWF	H'32'	






BIT_DOUKI1
        BTFSS H'05',2	
	GOTO BIT_DOUKI1

BIT_DOUKI2
	BTFSC H'05',2	
	GOTO BIT_DOUKI2	
;
	CALL WAIT20
	CALL WAIT20
	CALL WAIT20



OK_RECIVE


LOOP

	CLRF H'31'
	btfsc 05,2 ;INPUT=0 THEN SKIP
	bsf H'31',0 	;	
	BTFSC 05,2 ;INPUT=0 THEN SKIP
	GOTO NORMAL	 
	CALL WAIT24
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI	                
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	BTFSC 05,2	                
	GOTO DOUKI
	CALL WAIT22
	NOP
	GOTO PONPOKO

DOUKI
	CALL WAIT24
	CALL WAIT24
	CALL WAIT10
	GOTO PONPOKO

NORMAL
 	CALL WAIT24
	CALL WAIT24
        CALL WAIT24
        CALL WAIT24
        CALL WAIT24
PONPOKO
	btfsc 05,2 ;INPUT=0 THEN SKIP
	bsf H'31',1 	;	
	CALL WAIT24
	CALL WAIT24
        CALL WAIT24
        CALL WAIT24
        CALL WAIT24
        NOP
	NOP
	NOP
	btfsc 05,2 ;INPUT=0 THEN SKIP
	bsf H'31',2 	;	
	CALL WAIT24
	CALL WAIT24
        CALL WAIT24
        CALL WAIT24
        CALL WAIT24
        NOP
	NOP
	NOP
	btfsc 05,2 ;INPUT=0 THEN SKIP
	bsf H'31',3 	;	
	CALL WAIT24
	CALL WAIT24
        CALL WAIT24
        CALL WAIT24
        NOP
	CALL WAIT12

MAKE_PARITY2
	CLRF H'47'
	MOVLW H'00'
	MOVWF H'36'	
        BTFSC H'31',0 	
	INCF H'36',1
        BTFSC H'31',1 	
	INCF H'36',1
        BTFSC H'31',2 	
	INCF H'36',1
        BTFSC H'31',3 	
	INCF H'36',1
        BTFSC H'36',0	
	BSF H'47',0	
	CLRF H'37'
	btfsc 05,2 
	BSF H'37',0 	;
	MOVF H'47',0
	SUBWF H'37',0
	BTFSS H'03',2
	GOTO PARITY_NG2
	GOTO PARITY_OK2
PARITY_NG2	;KOKOMADE 6STEP GOTO KARA 2  STEP
	MOVLW H'00'
	MOVWF H'05'
	CALL WAIT22
	CALL WAIT20
	CALL WAIT20
	CALL WAIT20
	MOVLW H'01'
	MOVWF H'05'
	GOTO BIT_DOUKI1

PARITY_OK2

	BTFSS H'31',3	
	GOTO GENSHOUD

	MOVLW H'0F'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAIE
        MOVLW H'24'
	MOVWF H'35'
DAIE
	MOVLW H'0E'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAID
        MOVLW H'1C'
	MOVWF H'35'
DAID
	MOVLW H'0D'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAIC
        MOVLW H'15'
	MOVWF H'35'
DAIC
	MOVLW H'0C'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAIB
        MOVLW H'0F'
	MOVWF H'35'
DAIB
	MOVLW H'0B'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAIA
        MOVLW H'0A'
	MOVWF H'35'
DAIA
	MOVLW H'0A'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAI9
        MOVLW H'06'
	MOVWF H'35'
DAI9
	MOVLW H'09'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAI8
        MOVLW H'03'
	MOVWF H'35'
DAI8
	MOVLW H'08'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAIX
        MOVLW H'01'
	MOVWF H'35'
DAIX

	MOVF H'35',0   ;DAIHOUCHI> W
	ADDWF H'32',1  ;NAIBUCHI+DAIHYOUCHI=NAIBUCHI
	BTFSS H'3',0	;IF CALLY=1 THEN NEXT SKIP
	GOTO DAIX2
	MOVLW H'FF'
	MOVWF H'32'
	GOTO DAIX3
DAIX2
	NOP
	NOP
	NOP

DAIX3

	GOTO DAIZ

GENSHOUD

	MOVLW H'00'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAI1
        MOVLW H'24'
	MOVWF H'35'
DAI1
	MOVLW H'01'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAI2
        MOVLW H'1C'
	MOVWF H'35'
DAI2
	MOVLW H'02'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAI3
        MOVLW H'15'
	MOVWF H'35'
DAI3
	MOVLW H'03'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAI4
        MOVLW H'0F'
	MOVWF H'35'
DAI4
	MOVLW H'04'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAI5
        MOVLW H'0A'
	MOVWF H'35'
DAI5
	MOVLW H'05'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAI6
        MOVLW H'06'
	MOVWF H'35'
DAI6
	MOVLW H'06'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAI7
        MOVLW H'03'
	MOVWF H'35'
DAI7
	MOVLW H'07'
	SUBWF H'31',0
	BTFSS H'3',2
	GOTO DAIY
        MOVLW H'01'
	MOVWF H'35'

DAIY


	MOVF H'35',0  
	SUBWF H'32',1	
	BTFSC H'3',0	
	GOTO DAIY2
	MOVLW H'00'
	MOVWF H'32'
	GOTO DAIY3	;KOKOMADE63STEP
DAIY2
	NOP
	NOP
	NOP

DAIY3
	NOP



DAIZ

	MOVF H'32',0
	MOVWF H'06'


	CALL WAIT24
	CALL WAIT24
	CALL WAIT10
	NOP

	GOTO LOOP




WAIT24	nop
	nop
WAIT22	nop
	nop
WAIT20	nop
	nop
WAIT18	nop
	nop
WAIT16	nop
	nop
WAIT14	nop
	nop
WAIT12	nop
	nop
WAIT10	nop
	nop
WAIT8	nop
	nop
WAIT6	nop
	nop
	return	;goto-2 return-2 and nop


	end

