;******************************************************************************************
;  16*32 LEDドッド表示器サンプル(8*8表示)
;   Program Name : 
;   Programer    :
;   Create date  :  Version 1.0    H17.11.05
;   History      :
;******************************************************************************************
;   Define I/O
;     A0-A3:LED Driver (Grand)
;     A4:Serial Data Input
;     A5:Serial Data Signal
;     E0:EEP (SCL) 
;     E1:EEP (SDA)
;     B0-B7:LED Driver (Data)
;     C0-C7,D0-D7:LED (Data)
;******************************************************************************************
;====================== 以下はPIC16F877用の記述 ======================
	LIST	P=16F877,ST=OFF,R=DEC
	INCLUDE	"P16F877.inc"
	__CONFIG	_CP_OFF & _DEBUG_OFF & _WRT_ENABLE_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC 
;====================== 以下はPIC16F877A用の記述 ======================
;	LIST	P=16F877A,ST=OFF,R=DEC
;	INCLUDE	"P16F877A.inc"
;	__CONFIG	_CP_OFF & _DEBUG_OFF & _WRT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC 
;======================================================================
;
DA00	EQU	20H
DA01	EQU	21H
DA02	EQU	22H
DA03	EQU	23H
DA04	EQU	24H
DA05	EQU	25H
DA06	EQU	26H
DA07	EQU	27H
DA08	EQU	28H
DA09	EQU	29H
DA0A	EQU	2AH
DA0B	EQU	2BH
DA0C	EQU	2CH
DA0D	EQU	2DH
DA0E	EQU	2EH
DA0F	EQU	2FH
DA10	EQU	30H
DA11	EQU	31H
DA12	EQU	32H
DA13	EQU	33H
DA14	EQU	34H
DA15	EQU	35H
DA16	EQU	36H
DA17	EQU	37H
DA18	EQU	38H
DA19	EQU	39H
DA1A	EQU	3AH
DA1B	EQU	3BH
DA1C	EQU	3CH
DA1D	EQU	3DH
DA1E	EQU	3EH
DA1F	EQU	3FH
;
DB00	EQU	40H
DB01	EQU	41H
DB02	EQU	42H
DB03	EQU	43H
DB04	EQU	44H
DB05	EQU	45H
DB06	EQU	46H
DB07	EQU	47H
DB08	EQU	48H
DB09	EQU	49H
DB0A	EQU	4AH
DB0B	EQU	4BH
DB0C	EQU	4CH
DB0D	EQU	4DH
DB0E	EQU	4EH
DB0F	EQU	4FH
DB10	EQU	50H
DB11	EQU	51H
DB12	EQU	52H
DB13	EQU	53H
DB14	EQU	54H
DB15	EQU	55H
DB16	EQU	56H
DB17	EQU	57H
DB18	EQU	58H
DB19	EQU	59H
DB1A	EQU	5AH
DB1B	EQU	5BH
DB1C	EQU	5CH
DB1D	EQU	5DH
DB1E	EQU	5EH
DB1F	EQU	5FH
;
DSPCOD	EQU	60H
INRDSPLP EQU	61H
WATDSPLP EQU	62H
WATDSPBLP EQU	63H
LP	EQU	64H
LP1	EQU	65H
LP2	EQU	66H
LP3	EQU	67H
LP4	EQU	68H
IODAT	EQU	69H
RECLP	EQU	6AH
RECWAT	EQU	6BH


;
	ORG	0h
	GOTO	START
	ORG	5h
START
; 1.Port設定
;  (1)PortAの定義
	BCF	STATUS,RP0
	BCF	STATUS,RP1
	CLRF	PORTA		; PORTAの初期化
	BSF	STATUS,RP0
	MOVLW	H'06'
	MOVWF	ADCON1
	MOVLW	B'00010000'	; PORTAのIO設定(注意：PORTAは0-5までしかない)	
	MOVWF	TRISA		; PORTAのIO設定
;  (2)PortBの定義
	BCF	STATUS,RP0
	BCF	STATUS,RP1
	CLRF	PORTB		; PORTBの初期化
	BSF	STATUS,RP0
	MOVLW	B'00000000'	; PORTBのIO設定	
	MOVWF	TRISB		; PORTBのIO設定
;  (3)PortCの定義
	BCF	STATUS,RP0
	BCF	STATUS,RP1
	CLRF	PORTC		; PORTCの初期化
	BSF	STATUS,RP0
	MOVLW	B'00000000'	; PORTCのIO設定	
	MOVWF	TRISC		; PORTCのIO設定
;  (4)PortDの定義
	BCF	STATUS,RP0
	BCF	STATUS,RP1
	CLRF	PORTD		; PORTDの初期化
	BSF	STATUS,RP0
	MOVLW	B'00000000'	; PORTDのIO設定	
	MOVWF	TRISD		; PORTDのIO設定
;  (5)PortEの定義
	BCF	STATUS,RP0
	BCF	STATUS,RP1
	CLRF	PORTE		; PORTEの初期化
	BSF	STATUS,RP0
	MOVLW	B'00000111'	; PORTEのIO設定(注意：PORTEは0-2までしかない)	
	MOVWF	TRISE		; PORTEのIO設定
;
;  (6)初期化
	BCF	STATUS,RP0
	BCF	STATUS,RP1
	BSF	PORTA,5	
	CALL	CLRLED
;
;
	CALL	DEMO00
;
MAIN
; ====================== 16*32表示機の記述 ======================
;	CALL	PRG01
; ======================  8*8表示機の記述  ======================
	CALL	PRG02
; ===============================================================
	GOTO	MAIN

;******************************************************************************************
;   Function Name : PRG01
;   Title         : 16*32 表示関数
;   Input         : 
;   Output        : 
;   Disctiption   : 
;******************************************************************************************
PRG01
	CALL	SERIDAT
	XORLW	H'01'
	BTFSC	STATUS,Z
	CALL	SETFNT
	CALL	WATDSP
	RETURN

;******************************************************************************************
;   Function Name : PRG02
;   Title         : 8*8 表示関数
;   Input         : 
;   Output        : 
;   Disctiption   : 
;******************************************************************************************
PRG02
	CALL	SERIDAT
	XORLW	H'01'
	BTFSC	STATUS,Z
	CALL	SETSFNT
	CALL	WATDSP
	RETURN
;******************************************************************************************
;   Function Name : DEMO00
;   Title         : 電源投入時のデモ表示
;   Input         : 
;   Output        : 
;   Disctiption   : 
;******************************************************************************************
DEMO00
	MOVLW	H'FF'
	MOVWF	DSPCOD
	CALL	SETFNT
	CALL	WATDSPB
;
	MOVLW	H'00'
	MOVWF	DSPCOD
	CALL	SETFNT
	CALL	WATDSPB
;
	MOVLW	H'0A'
	MOVWF	LP
DEMO00C
	MOVLW	H'FD'
	MOVWF	DSPCOD
	CALL	SETFNT
	MOVLW	H'01'
	MOVWF	LP1
DEMO00C1
	CALL	WATDSP
	DECFSZ	LP1,F	
	GOTO	DEMO00C1
	MOVLW	H'FE'
	MOVWF	DSPCOD
	CALL	SETFNT
	MOVLW	H'01'
	MOVWF	LP1
DEMO00C2
	CALL	WATDSP
	DECFSZ	LP1,F	
	GOTO	DEMO00C2
	DECFSZ	LP,F	
	GOTO	DEMO00C
;
	MOVLW	H'00'
	MOVWF	DSPCOD
	CALL	SETFNT
	CALL	WATDSP
;
	RETURN
;******************************************************************************************
;   Function Name : WATDSPB
;   Title         : 文字コードを指定して、画面を1秒程度表示する
;   Input         : DSPCOD
;   Output        : 
;   Disctiption   : 
;******************************************************************************************
WATDSPB
	MOVLW	H'64'
	MOVWF	WATDSPBLP
WATDSPB1
	CALL	DSPLED
	DECFSZ	WATDSPBLP,F	
	GOTO	WATDSPB1 
	RETURN
;******************************************************************************************
;   Function Name : WATDSP
;   Title         : 文字コードを指定して、画面を0.1秒程度表示する
;   Input         : DSPCOD
;   Output        : 
;   Disctiption   : 
;******************************************************************************************
WATDSP
	MOVLW	H'0A'
	MOVWF	WATDSPLP
WATDSP1
	CALL	DSPLED
	DECFSZ	WATDSPLP,F	
	GOTO	WATDSP1 
	RETURN


;******************************************************************************************
;   Function Name : SETSFNT
;   Title         : 文字コードを指定して、フォントをセットする(8*8)
;   Input         : DSPCOD
;   Output        : 
;   Disctiption   : 
;******************************************************************************************
SETSFNT
	CALL	MOVSFNT
;
;=========================================================
;  キャラクタコード(00)
;    記号 ' ' ※何も表示しない
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'00'
	BTFSS	STATUS,Z
	GOTO	FSEND00
	MOVLW	B'00000000'
	MOVWF	DB18
	MOVLW	B'00000000'
	MOVWF	DB19
	MOVLW	B'00000000'
	MOVWF	DB1A
	MOVLW	B'00000000'
	MOVWF	DB1B
	MOVLW	B'00000000'
	MOVWF	DB1C
	MOVLW	B'00000000'
	MOVWF	DB1D
	MOVLW	B'00000000'
	MOVWF	DB1E
	MOVLW	B'00000000'
	MOVWF	DB1F
	RETURN
FSEND00
;=========================================================
;  キャラクタコード(2B)
;    記号 '+'
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'2B'
	BTFSS	STATUS,Z
	GOTO	FSEND2B
	MOVLW	B'00001000'
	MOVWF	DB18
	MOVLW	B'00001000'
	MOVWF	DB19
	MOVLW	B'00001000'
	MOVWF	DB1A
	MOVLW	B'11111111'
	MOVWF	DB1B
	MOVLW	B'11111111'
	MOVWF	DB1C
	MOVLW	B'00001000'
	MOVWF	DB1D
	MOVLW	B'00001000'
	MOVWF	DB1E
	MOVLW	B'00001000'
	MOVWF	DB1F
	RETURN
FSEND2B
;=========================================================
;  キャラクタコード(2D)
;    記号 '-'
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'2D'
	BTFSS	STATUS,Z
	GOTO	FSEND2D
	MOVLW	B'00001000'
	MOVWF	DB18
	MOVLW	B'00001000'
	MOVWF	DB19
	MOVLW	B'00001000'
	MOVWF	DB1A
	MOVLW	B'00001000'
	MOVWF	DB1B
	MOVLW	B'00001000'
	MOVWF	DB1C
	MOVLW	B'00001000'
	MOVWF	DB1D
	MOVLW	B'00001000'
	MOVWF	DB1E
	MOVLW	B'00001000'
	MOVWF	DB1F
	RETURN
FSEND2D
;=========================================================
;  キャラクタコード(FD)
;    記号  ※斑模様パターンA
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'FD'
	BTFSS	STATUS,Z
	GOTO	FSENDFD	
	MOVLW	B'01010101'
	MOVWF	DB18
	MOVLW	B'10101010'
	MOVWF	DB19
	MOVLW	B'01010101'
	MOVWF	DB1A
	MOVLW	B'10101010'
	MOVWF	DB1B
	MOVLW	B'01010101'
	MOVWF	DB1C
	MOVLW	B'10101010'
	MOVWF	DB1D
	MOVLW	B'01010101'
	MOVWF	DB1E
	MOVLW	B'10101010'
	MOVWF	DB1F
	RETURN
FSENDFD
;=========================================================
;  キャラクタコード(FE)
;    記号  ※斑模様パターンB
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'FE'
	BTFSS	STATUS,Z
	GOTO	FSENDFE	
	MOVLW	B'10101010'
	MOVWF	DB18
	MOVLW	B'01010101'
	MOVWF	DB19
	MOVLW	B'10101010'
	MOVWF	DB1A
	MOVLW	B'01010101'
	MOVWF	DB1B
	MOVLW	B'10101010'
	MOVWF	DB1C
	MOVLW	B'01010101'
	MOVWF	DB1D
	MOVLW	B'10101010'
	MOVWF	DB1E
	MOVLW	B'01010101'
	MOVWF	DB1F
	RETURN
FSENDFE
;=========================================================
;  キャラクタコード(FF)
;    記号  ※全点燈
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'FF'
	BTFSS	STATUS,Z
	GOTO	FSENDFE	
	MOVLW	B'11111111'
	MOVWF	DB18
	MOVLW	B'11111111'
	MOVWF	DB19
	MOVLW	B'11111111'
	MOVWF	DB1A
	MOVLW	B'11111111'
	MOVWF	DB1B
	MOVLW	B'11111111'
	MOVWF	DB1C
	MOVLW	B'11111111'
	MOVWF	DB1D
	MOVLW	B'11111111'
	MOVWF	DB1E
	MOVLW	B'11111111'
	MOVWF	DB1F
	RETURN
FSENDFF
;=========================================================
;  キャラクタコード(それ以外)
;    記号  ※エラー表示
;=========================================================
	MOVLW	B'11111111'
	MOVWF	DB18
	MOVLW	B'10011001'
	MOVWF	DB19
	MOVLW	B'10011001'
	MOVWF	DB1A
	MOVLW	B'10011001'
	MOVWF	DB1B
	MOVLW	B'10011001'
	MOVWF	DB1C
	MOVLW	B'10011001'
	MOVWF	DB1D
	MOVLW	B'10011001'
	MOVWF	DB1E
	MOVLW	B'10011001'
	MOVWF	DB1F
	RETURN

;******************************************************************************************
;   Function Name : MOVSFNT
;   Title         : フォントをスクロールする(8*8)
;   Input         : 
;   Output        : 
;   Disctiption   : 
;******************************************************************************************
MOVSFNT
; 1B -> 1A
	MOVF	DA08,W
	MOVWF	DA00
	MOVF	DA09,W
	MOVWF	DA01
	MOVF	DA0A,W
	MOVWF	DA02
	MOVF	DA0B,W
	MOVWF	DA03
	MOVF	DA0C,W
	MOVWF	DA04
	MOVF	DA0D,W
	MOVWF	DA05
	MOVF	DA0E,W
	MOVWF	DA06
	MOVF	DA0F,W
	MOVWF	DA07
; 1C -> 1B
	MOVF	DA10,W
	MOVWF	DA08
	MOVF	DA11,W
	MOVWF	DA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12
	MOVF	DB1B,W
	MOVWF	DB13
	MOVF	DB1C,W
	MOVWF	DB14
	MOVF	DB1D,W
	MOVWF	DB15
	MOVF	DB1E,W
	MOVWF	DB16
	MOVF	DB1F,W
	MOVWF	DB17
;
	RETURN

;******************************************************************************************
;   Function Name : SETFNT
;   Title         : 文字コードを指定して、フォントをセットする(16*32)
;   Input         : DSPCOD
;   Output        : 
;   Disctiption   : 
;******************************************************************************************
SETFNT
;=========================================================
;  キャラクタコード(00)
;    記号 ' ' ※何も表示しない
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'00'
	BTFSS	STATUS,Z
	GOTO	FEND00
	MOVLW	B'00000000'
	MOVWF	DA00
	MOVLW	B'00000000'
	MOVWF	DB00
	MOVLW	B'00000000'
	MOVWF	DA01
	MOVLW	B'00000000'
	MOVWF	DB01
	MOVLW	B'00000000'
	MOVWF	DA02
	MOVLW	B'00000000'
	MOVWF	DB02
	MOVLW	B'00000000'
	MOVWF	DA03
	MOVLW	B'00000000'
	MOVWF	DB03
	MOVLW	B'00000000'
	MOVWF	DA04
	MOVLW	B'00000000'
	MOVWF	DB04
	MOVLW	B'00000000'
	MOVWF	DA05
	MOVLW	B'00000000'
	MOVWF	DB05
	MOVLW	B'00000000'
	MOVWF	DA06
	MOVLW	B'00000000'
	MOVWF	DB06
	MOVLW	B'00000000'
	MOVWF	DA07
	MOVLW	B'00000000'
	MOVWF	DB07
	MOVLW	B'00000000'
	MOVWF	DA08
	MOVLW	B'00000000'
	MOVWF	DB08
	MOVLW	B'00000000'
	MOVWF	DA09
	MOVLW	B'00000000'
	MOVWF	DB09
	MOVLW	B'00000000'
	MOVWF	DA0A
	MOVLW	B'00000000'
	MOVWF	DB0A
	MOVLW	B'00000000'
	MOVWF	DA0B
	MOVLW	B'00000000'
	MOVWF	DB0B
	MOVLW	B'00000000'
	MOVWF	DA0C
	MOVLW	B'00000000'
	MOVWF	DB0C
	MOVLW	B'00000000'
	MOVWF	DA0D
	MOVLW	B'00000000'
	MOVWF	DB0D
	MOVLW	B'00000000'
	MOVWF	DA0E
	MOVLW	B'00000000'
	MOVWF	DB0E
	MOVLW	B'00000000'
	MOVWF	DA0F
	MOVLW	B'00000000'
	MOVWF	DB0F
	MOVLW	B'00000000'
	MOVWF	DA10
	MOVLW	B'00000000'
	MOVWF	DB10
	MOVLW	B'00000000'
	MOVWF	DA11
	MOVLW	B'00000000'
	MOVWF	DB11
	MOVLW	B'00000000'
	MOVWF	DA12
	MOVLW	B'00000000'
	MOVWF	DB12
	MOVLW	B'00000000'
	MOVWF	DA13
	MOVLW	B'00000000'
	MOVWF	DB13
	MOVLW	B'00000000'
	MOVWF	DA14
	MOVLW	B'00000000'
	MOVWF	DB14
	MOVLW	B'00000000'
	MOVWF	DA15
	MOVLW	B'00000000'
	MOVWF	DB15
	MOVLW	B'00000000'
	MOVWF	DA16
	MOVLW	B'00000000'
	MOVWF	DB16
	MOVLW	B'00000000'
	MOVWF	DA17
	MOVLW	B'00000000'
	MOVWF	DB17
	MOVLW	B'00000000'
	MOVWF	DA18
	MOVLW	B'00000000'
	MOVWF	DB18
	MOVLW	B'00000000'
	MOVWF	DA19
	MOVLW	B'00000000'
	MOVWF	DB19
	MOVLW	B'00000000'
	MOVWF	DA1A
	MOVLW	B'00000000'
	MOVWF	DB1A
	MOVLW	B'00000000'
	MOVWF	DA1B
	MOVLW	B'00000000'
	MOVWF	DB1B
	MOVLW	B'00000000'
	MOVWF	DA1C
	MOVLW	B'00000000'
	MOVWF	DB1C
	MOVLW	B'00000000'
	MOVWF	DA1D
	MOVLW	B'00000000'
	MOVWF	DB1D
	MOVLW	B'00000000'
	MOVWF	DA1E
	MOVLW	B'00000000'
	MOVWF	DB1E
	MOVLW	B'00000000'
	MOVWF	DA1F
	MOVLW	B'00000000'
	MOVWF	DB1F
	RETURN
FEND00
;=========================================================
;  キャラクタコード(2B)
;    記号 '+'
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'2B'
	BTFSS	STATUS,Z
	GOTO	FEND2B
	MOVLW	B'10000000'
	MOVWF	DA00
	MOVLW	B'00000001'
	MOVWF	DB00
	MOVLW	B'10000000'
	MOVWF	DA01
	MOVLW	B'00000001'
	MOVWF	DB01
	MOVLW	B'10000000'
	MOVWF	DA02
	MOVLW	B'00000001'
	MOVWF	DB02
	MOVLW	B'10000000'
	MOVWF	DA03
	MOVLW	B'00000001'
	MOVWF	DB03
	MOVLW	B'10000000'
	MOVWF	DA04
	MOVLW	B'00000001'
	MOVWF	DB04
	MOVLW	B'10000000'
	MOVWF	DA05
	MOVLW	B'00000001'
	MOVWF	DB05
	MOVLW	B'10000000'
	MOVWF	DA06
	MOVLW	B'00000001'
	MOVWF	DB06
	MOVLW	B'10000000'
	MOVWF	DA07
	MOVLW	B'00000001'
	MOVWF	DB07
	MOVLW	B'10000000'
	MOVWF	DA08
	MOVLW	B'00000001'
	MOVWF	DB08
	MOVLW	B'10000000'
	MOVWF	DA09
	MOVLW	B'00000001'
	MOVWF	DB09
	MOVLW	B'10000000'
	MOVWF	DA0A
	MOVLW	B'00000001'
	MOVWF	DB0A
	MOVLW	B'10000000'
	MOVWF	DA0B
	MOVLW	B'00000001'
	MOVWF	DB0B
	MOVLW	B'10000000'
	MOVWF	DA0C
	MOVLW	B'00000001'
	MOVWF	DB0C
	MOVLW	B'10000000'
	MOVWF	DA0D
	MOVLW	B'00000001'
	MOVWF	DB0D
	MOVLW	B'10000000'
	MOVWF	DA0E
	MOVLW	B'00000001'
	MOVWF	DB0E
	MOVLW	B'11111111'
	MOVWF	DA0F
	MOVLW	B'11111111'
	MOVWF	DB0F
	MOVLW	B'11111111'
	MOVWF	DA10
	MOVLW	B'11111111'
	MOVWF	DB10
	MOVLW	B'10000000'
	MOVWF	DA11
	MOVLW	B'00000001'
	MOVWF	DB11
	MOVLW	B'10000000'
	MOVWF	DA12
	MOVLW	B'00000001'
	MOVWF	DB12
	MOVLW	B'10000000'
	MOVWF	DA13
	MOVLW	B'00000001'
	MOVWF	DB13
	MOVLW	B'10000000'
	MOVWF	DA14
	MOVLW	B'00000001'
	MOVWF	DB14
	MOVLW	B'10000000'
	MOVWF	DA15
	MOVLW	B'00000001'
	MOVWF	DB15
	MOVLW	B'10000000'
	MOVWF	DA16
	MOVLW	B'00000001'
	MOVWF	DB16
	MOVLW	B'10000000'
	MOVWF	DA17
	MOVLW	B'00000001'
	MOVWF	DB17
	MOVLW	B'10000000'
	MOVWF	DA18
	MOVLW	B'00000001'
	MOVWF	DB18
	MOVLW	B'10000000'
	MOVWF	DA19
	MOVLW	B'00000001'
	MOVWF	DB19
	MOVLW	B'10000000'
	MOVWF	DA1A
	MOVLW	B'00000001'
	MOVWF	DB1A
	MOVLW	B'10000000'
	MOVWF	DA1B
	MOVLW	B'00000001'
	MOVWF	DB1B
	MOVLW	B'10000000'
	MOVWF	DA1C
	MOVLW	B'00000001'
	MOVWF	DB1C
	MOVLW	B'10000000'
	MOVWF	DA1D
	MOVLW	B'00000001'
	MOVWF	DB1D
	MOVLW	B'10000000'
	MOVWF	DA1E
	MOVLW	B'00000001'
	MOVWF	DB1E
	MOVLW	B'10000000'
	MOVWF	DA1F
	MOVLW	B'00000001'
	MOVWF	DB1F
	RETURN
FEND2B
;=========================================================
;  キャラクタコード(2D)
;    記号 '-'
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'2D'
	BTFSS	STATUS,Z
	GOTO	FEND2D
	MOVLW	B'10000000'
	MOVWF	DA00
	MOVLW	B'00000001'
	MOVWF	DB00
	MOVLW	B'10000000'
	MOVWF	DA01
	MOVLW	B'00000001'
	MOVWF	DB01
	MOVLW	B'10000000'
	MOVWF	DA02
	MOVLW	B'00000001'
	MOVWF	DB02
	MOVLW	B'10000000'
	MOVWF	DA03
	MOVLW	B'00000001'
	MOVWF	DB03
	MOVLW	B'10000000'
	MOVWF	DA04
	MOVLW	B'00000001'
	MOVWF	DB04
	MOVLW	B'10000000'
	MOVWF	DA05
	MOVLW	B'00000001'
	MOVWF	DB05
	MOVLW	B'10000000'
	MOVWF	DA06
	MOVLW	B'00000001'
	MOVWF	DB06
	MOVLW	B'10000000'
	MOVWF	DA07
	MOVLW	B'00000001'
	MOVWF	DB07
	MOVLW	B'10000000'
	MOVWF	DA08
	MOVLW	B'00000001'
	MOVWF	DB08
	MOVLW	B'10000000'
	MOVWF	DA09
	MOVLW	B'00000001'
	MOVWF	DB09
	MOVLW	B'10000000'
	MOVWF	DA0A
	MOVLW	B'00000001'
	MOVWF	DB0A
	MOVLW	B'10000000'
	MOVWF	DA0B
	MOVLW	B'00000001'
	MOVWF	DB0B
	MOVLW	B'10000000'
	MOVWF	DA0C
	MOVLW	B'00000001'
	MOVWF	DB0C
	MOVLW	B'10000000'
	MOVWF	DA0D
	MOVLW	B'00000001'
	MOVWF	DB0D
	MOVLW	B'10000000'
	MOVWF	DA0E
	MOVLW	B'00000001'
	MOVWF	DB0E
	MOVLW	B'10000000'
	MOVWF	DA0F
	MOVLW	B'00000001'
	MOVWF	DB0F
	MOVLW	B'10000000'
	MOVWF	DA10
	MOVLW	B'00000001'
	MOVWF	DB10
	MOVLW	B'10000000'
	MOVWF	DA11
	MOVLW	B'00000001'
	MOVWF	DB11
	MOVLW	B'10000000'
	MOVWF	DA12
	MOVLW	B'00000001'
	MOVWF	DB12
	MOVLW	B'10000000'
	MOVWF	DA13
	MOVLW	B'00000001'
	MOVWF	DB13
	MOVLW	B'10000000'
	MOVWF	DA14
	MOVLW	B'00000001'
	MOVWF	DB14
	MOVLW	B'10000000'
	MOVWF	DA15
	MOVLW	B'00000001'
	MOVWF	DB15
	MOVLW	B'10000000'
	MOVWF	DA16
	MOVLW	B'00000001'
	MOVWF	DB16
	MOVLW	B'10000000'
	MOVWF	DA17
	MOVLW	B'00000001'
	MOVWF	DB17
	MOVLW	B'10000000'
	MOVWF	DA18
	MOVLW	B'00000001'
	MOVWF	DB18
	MOVLW	B'10000000'
	MOVWF	DA19
	MOVLW	B'00000001'
	MOVWF	DB19
	MOVLW	B'10000000'
	MOVWF	DA1A
	MOVLW	B'00000001'
	MOVWF	DB1A
	MOVLW	B'10000000'
	MOVWF	DA1B
	MOVLW	B'00000001'
	MOVWF	DB1B
	MOVLW	B'10000000'
	MOVWF	DA1C
	MOVLW	B'00000001'
	MOVWF	DB1C
	MOVLW	B'10000000'
	MOVWF	DA1D
	MOVLW	B'00000001'
	MOVWF	DB1D
	MOVLW	B'10000000'
	MOVWF	DA1E
	MOVLW	B'00000001'
	MOVWF	DB1E
	MOVLW	B'10000000'
	MOVWF	DA1F
	MOVLW	B'00000001'
	MOVWF	DB1F
	RETURN
FEND2D
;=========================================================
;  キャラクタコード(FD)
;    記号  ※斑模様パターンA
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'FD'
	BTFSS	STATUS,Z
	GOTO	FENDFD
	MOVLW	B'01010101'
	MOVWF	DA00
	MOVLW	B'01010101'
	MOVWF	DB00
	MOVLW	B'10101010'
	MOVWF	DA01
	MOVLW	B'10101010'
	MOVWF	DB01
	MOVLW	B'01010101'
	MOVWF	DA02
	MOVLW	B'01010101'
	MOVWF	DB02
	MOVLW	B'10101010'
	MOVWF	DA03
	MOVLW	B'10101010'
	MOVWF	DB03
	MOVLW	B'01010101'
	MOVWF	DA04
	MOVLW	B'01010101'
	MOVWF	DB04
	MOVLW	B'10101010'
	MOVWF	DA05
	MOVLW	B'10101010'
	MOVWF	DB05
	MOVLW	B'01010101'
	MOVWF	DA06
	MOVLW	B'01010101'
	MOVWF	DB06
	MOVLW	B'10101010'
	MOVWF	DA07
	MOVLW	B'10101010'
	MOVWF	DB07
	MOVLW	B'01010101'
	MOVWF	DA08
	MOVLW	B'01010101'
	MOVWF	DB08
	MOVLW	B'10101010'
	MOVWF	DA09
	MOVLW	B'10101010'
	MOVWF	DB09
	MOVLW	B'01010101'
	MOVWF	DA0A
	MOVLW	B'01010101'
	MOVWF	DB0A
	MOVLW	B'10101010'
	MOVWF	DA0B
	MOVLW	B'10101010'
	MOVWF	DB0B
	MOVLW	B'01010101'
	MOVWF	DA0C
	MOVLW	B'01010101'
	MOVWF	DB0C
	MOVLW	B'10101010'
	MOVWF	DA0D
	MOVLW	B'10101010'
	MOVWF	DB0D
	MOVLW	B'01010101'
	MOVWF	DA0E
	MOVLW	B'01010101'
	MOVWF	DB0E
	MOVLW	B'10101010'
	MOVWF	DA0F
	MOVLW	B'10101010'
	MOVWF	DB0F
	MOVLW	B'01010101'
	MOVWF	DA10
	MOVLW	B'01010101'
	MOVWF	DB10
	MOVLW	B'10101010'
	MOVWF	DA11
	MOVLW	B'10101010'
	MOVWF	DB11
	MOVLW	B'01010101'
	MOVWF	DA12
	MOVLW	B'01010101'
	MOVWF	DB12
	MOVLW	B'10101010'
	MOVWF	DA13
	MOVLW	B'10101010'
	MOVWF	DB13
	MOVLW	B'01010101'
	MOVWF	DA14
	MOVLW	B'01010101'
	MOVWF	DB14
	MOVLW	B'10101010'
	MOVWF	DA15
	MOVLW	B'10101010'
	MOVWF	DB15
	MOVLW	B'01010101'
	MOVWF	DA16
	MOVLW	B'01010101'
	MOVWF	DB16
	MOVLW	B'10101010'
	MOVWF	DA17
	MOVLW	B'10101010'
	MOVWF	DB17
	MOVLW	B'01010101'
	MOVWF	DA18
	MOVLW	B'01010101'
	MOVWF	DB18
	MOVLW	B'10101010'
	MOVWF	DA19
	MOVLW	B'10101010'
	MOVWF	DB19
	MOVLW	B'01010101'
	MOVWF	DA1A
	MOVLW	B'01010101'
	MOVWF	DB1A
	MOVLW	B'10101010'
	MOVWF	DA1B
	MOVLW	B'10101010'
	MOVWF	DB1B
	MOVLW	B'01010101'
	MOVWF	DA1C
	MOVLW	B'01010101'
	MOVWF	DB1C
	MOVLW	B'10101010'
	MOVWF	DA1D
	MOVLW	B'10101010'
	MOVWF	DB1D
	MOVLW	B'01010101'
	MOVWF	DA1E
	MOVLW	B'01010101'
	MOVWF	DB1E
	MOVLW	B'10101010'
	MOVWF	DA1F
	MOVLW	B'10101010'
	MOVWF	DB1F
	RETURN
FENDFD
;=========================================================
;  キャラクタコード(FE)
;    記号  ※斑模様パターンB
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'FE'
	BTFSS	STATUS,Z
	GOTO	FENDFE
	MOVLW	B'10101010'
	MOVWF	DA00
	MOVLW	B'10101010'
	MOVWF	DB00
	MOVLW	B'01010101'
	MOVWF	DA01
	MOVLW	B'01010101'
	MOVWF	DB01
	MOVLW	B'10101010'
	MOVWF	DA02
	MOVLW	B'10101010'
	MOVWF	DB02
	MOVLW	B'01010101'
	MOVWF	DA03
	MOVLW	B'01010101'
	MOVWF	DB03
	MOVLW	B'10101010'
	MOVWF	DA04
	MOVLW	B'10101010'
	MOVWF	DB04
	MOVLW	B'01010101'
	MOVWF	DA05
	MOVLW	B'01010101'
	MOVWF	DB05
	MOVLW	B'10101010'
	MOVWF	DA06
	MOVLW	B'10101010'
	MOVWF	DB06
	MOVLW	B'01010101'
	MOVWF	DA07
	MOVLW	B'01010101'
	MOVWF	DB07
	MOVLW	B'10101010'
	MOVWF	DA08
	MOVLW	B'10101010'
	MOVWF	DB08
	MOVLW	B'01010101'
	MOVWF	DA09
	MOVLW	B'01010101'
	MOVWF	DB09
	MOVLW	B'10101010'
	MOVWF	DA0A
	MOVLW	B'10101010'
	MOVWF	DB0A
	MOVLW	B'01010101'
	MOVWF	DA0B
	MOVLW	B'01010101'
	MOVWF	DB0B
	MOVLW	B'10101010'
	MOVWF	DA0C
	MOVLW	B'10101010'
	MOVWF	DB0C
	MOVLW	B'01010101'
	MOVWF	DA0D
	MOVLW	B'01010101'
	MOVWF	DB0D
	MOVLW	B'10101010'
	MOVWF	DA0E
	MOVLW	B'10101010'
	MOVWF	DB0E
	MOVLW	B'01010101'
	MOVWF	DA0F
	MOVLW	B'01010101'
	MOVWF	DB0F
	MOVLW	B'10101010'
	MOVWF	DA10
	MOVLW	B'10101010'
	MOVWF	DB10
	MOVLW	B'01010101'
	MOVWF	DA11
	MOVLW	B'01010101'
	MOVWF	DB11
	MOVLW	B'10101010'
	MOVWF	DA12
	MOVLW	B'10101010'
	MOVWF	DB12
	MOVLW	B'01010101'
	MOVWF	DA13
	MOVLW	B'01010101'
	MOVWF	DB13
	MOVLW	B'10101010'
	MOVWF	DA14
	MOVLW	B'10101010'
	MOVWF	DB14
	MOVLW	B'01010101'
	MOVWF	DA15
	MOVLW	B'01010101'
	MOVWF	DB15
	MOVLW	B'10101010'
	MOVWF	DA16
	MOVLW	B'10101010'
	MOVWF	DB16
	MOVLW	B'01010101'
	MOVWF	DA17
	MOVLW	B'01010101'
	MOVWF	DB17
	MOVLW	B'10101010'
	MOVWF	DA18
	MOVLW	B'10101010'
	MOVWF	DB18
	MOVLW	B'01010101'
	MOVWF	DA19
	MOVLW	B'01010101'
	MOVWF	DB19
	MOVLW	B'10101010'
	MOVWF	DA1A
	MOVLW	B'10101010'
	MOVWF	DB1A
	MOVLW	B'01010101'
	MOVWF	DA1B
	MOVLW	B'01010101'
	MOVWF	DB1B
	MOVLW	B'10101010'
	MOVWF	DA1C
	MOVLW	B'10101010'
	MOVWF	DB1C
	MOVLW	B'01010101'
	MOVWF	DA1D
	MOVLW	B'01010101'
	MOVWF	DB1D
	MOVLW	B'10101010'
	MOVWF	DA1E
	MOVLW	B'10101010'
	MOVWF	DB1E
	MOVLW	B'01010101'
	MOVWF	DA1F
	MOVLW	B'01010101'
	MOVWF	DB1F
	RETURN
FENDFE
;=========================================================
;  キャラクタコード(FF)
;    記号  ※全てのLEDを点燈する
;=========================================================
	MOVF	DSPCOD,W
	XORLW	H'FF'
	BTFSS	STATUS,Z
	GOTO	FENDFF
	MOVLW	B'11111111'
	MOVWF	DA00
	MOVLW	B'11111111'
	MOVWF	DB00
	MOVLW	B'11111111'
	MOVWF	DA01
	MOVLW	B'11111111'
	MOVWF	DB01
	MOVLW	B'11111111'
	MOVWF	DA02
	MOVLW	B'11111111'
	MOVWF	DB02
	MOVLW	B'11111111'
	MOVWF	DA03
	MOVLW	B'11111111'
	MOVWF	DB03
	MOVLW	B'11111111'
	MOVWF	DA04
	MOVLW	B'11111111'
	MOVWF	DB04
	MOVLW	B'11111111'
	MOVWF	DA05
	MOVLW	B'11111111'
	MOVWF	DB05
	MOVLW	B'11111111'
	MOVWF	DA06
	MOVLW	B'11111111'
	MOVWF	DB06
	MOVLW	B'11111111'
	MOVWF	DA07
	MOVLW	B'11111111'
	MOVWF	DB07
	MOVLW	B'11111111'
	MOVWF	DA08
	MOVLW	B'11111111'
	MOVWF	DB08
	MOVLW	B'11111111'
	MOVWF	DA09
	MOVLW	B'11111111'
	MOVWF	DB09
	MOVLW	B'11111111'
	MOVWF	DA0A
	MOVLW	B'11111111'
	MOVWF	DB0A
	MOVLW	B'11111111'
	MOVWF	DA0B
	MOVLW	B'11111111'
	MOVWF	DB0B
	MOVLW	B'11111111'
	MOVWF	DA0C
	MOVLW	B'11111111'
	MOVWF	DB0C
	MOVLW	B'11111111'
	MOVWF	DA0D
	MOVLW	B'11111111'
	MOVWF	DB0D
	MOVLW	B'11111111'
	MOVWF	DA0E
	MOVLW	B'11111111'
	MOVWF	DB0E
	MOVLW	B'11111111'
	MOVWF	DA0F
	MOVLW	B'11111111'
	MOVWF	DB0F
	MOVLW	B'11111111'
	MOVWF	DA10
	MOVLW	B'11111111'
	MOVWF	DB10
	MOVLW	B'11111111'
	MOVWF	DA11
	MOVLW	B'11111111'
	MOVWF	DB11
	MOVLW	B'11111111'
	MOVWF	DA12
	MOVLW	B'11111111'
	MOVWF	DB12
	MOVLW	B'11111111'
	MOVWF	DA13
	MOVLW	B'11111111'
	MOVWF	DB13
	MOVLW	B'11111111'
	MOVWF	DA14
	MOVLW	B'11111111'
	MOVWF	DB14
	MOVLW	B'11111111'
	MOVWF	DA15
	MOVLW	B'11111111'
	MOVWF	DB15
	MOVLW	B'11111111'
	MOVWF	DA16
	MOVLW	B'11111111'
	MOVWF	DB16
	MOVLW	B'11111111'
	MOVWF	DA17
	MOVLW	B'11111111'
	MOVWF	DB17
	MOVLW	B'11111111'
	MOVWF	DA18
	MOVLW	B'11111111'
	MOVWF	DB18
	MOVLW	B'11111111'
	MOVWF	DA19
	MOVLW	B'11111111'
	MOVWF	DB19
	MOVLW	B'11111111'
	MOVWF	DA1A
	MOVLW	B'11111111'
	MOVWF	DB1A
	MOVLW	B'11111111'
	MOVWF	DA1B
	MOVLW	B'11111111'
	MOVWF	DB1B
	MOVLW	B'11111111'
	MOVWF	DA1C
	MOVLW	B'11111111'
	MOVWF	DB1C
	MOVLW	B'11111111'
	MOVWF	DA1D
	MOVLW	B'11111111'
	MOVWF	DB1D
	MOVLW	B'11111111'
	MOVWF	DA1E
	MOVLW	B'11111111'
	MOVWF	DB1E
	MOVLW	B'11111111'
	MOVWF	DA1F
	MOVLW	B'11111111'
	MOVWF	DB1F
	RETURN
FENDFF
;=========================================================
;  キャラクタコード(それ以外)
;    記号  ※エラー表示
;=========================================================
	MOVLW	B'11111111'
	MOVWF	DA00
	MOVLW	B'11111111'
	MOVWF	DB00
	MOVLW	B'11111111'
	MOVWF	DA01
	MOVLW	B'11111111'
	MOVWF	DB01
	MOVLW	B'11111111'
	MOVWF	DA02
	MOVLW	B'11111111'
	MOVWF	DB02
	MOVLW	B'11111111'
	MOVWF	DA03
	MOVLW	B'11111111'
	MOVWF	DB03
	MOVLW	B'11111111'
	MOVWF	DA04
	MOVLW	B'11111111'
	MOVWF	DB04
	MOVLW	B'11111111'
	MOVWF	DA05
	MOVLW	B'11111111'
	MOVWF	DB05
	MOVLW	B'11111111'
	MOVWF	DA06
	MOVLW	B'11111111'
	MOVWF	DB06
	MOVLW	B'11111111'
	MOVWF	DA07
	MOVLW	B'11111111'
	MOVWF	DB07
	MOVLW	B'11111111'
	MOVWF	DA08
	MOVLW	B'11111111'
	MOVWF	DB08
	MOVLW	B'11111111'
	MOVWF	DA09
	MOVLW	B'11111111'
	MOVWF	DB09
	MOVLW	B'11111111'
	MOVWF	DA0A
	MOVLW	B'11111111'
	MOVWF	DB0A
	MOVLW	B'11111111'
	MOVWF	DA0B
	MOVLW	B'11111111'
	MOVWF	DB0B
	MOVLW	B'00001111'
	MOVWF	DA0C
	MOVLW	B'11110000'
	MOVWF	DB0C
	MOVLW	B'00001111'
	MOVWF	DA0D
	MOVLW	B'11110000'
	MOVWF	DB0D
	MOVLW	B'00001111'
	MOVWF	DA0E
	MOVLW	B'11110000'
	MOVWF	DB0E
	MOVLW	B'00001111'
	MOVWF	DA0F
	MOVLW	B'11110000'
	MOVWF	DB0F
	MOVLW	B'00001111'
	MOVWF	DA10
	MOVLW	B'11110000'
	MOVWF	DB10
	MOVLW	B'00001111'
	MOVWF	DA11
	MOVLW	B'11110000'
	MOVWF	DB11
	MOVLW	B'00001111'
	MOVWF	DA12
	MOVLW	B'11110000'
	MOVWF	DB12
	MOVLW	B'00001111'
	MOVWF	DA13
	MOVLW	B'11110000'
	MOVWF	DB13
	MOVLW	B'11111111'
	MOVWF	DA14
	MOVLW	B'11111111'
	MOVWF	DB14
	MOVLW	B'11111111'
	MOVWF	DA15
	MOVLW	B'11111111'
	MOVWF	DB15
	MOVLW	B'11111111'
	MOVWF	DA16
	MOVLW	B'11111111'
	MOVWF	DB16
	MOVLW	B'11111111'
	MOVWF	DA17
	MOVLW	B'11111111'
	MOVWF	DB17
	MOVLW	B'11111111'
	MOVWF	DA18
	MOVLW	B'11111111'
	MOVWF	DB18
	MOVLW	B'11111111'
	MOVWF	DA19
	MOVLW	B'11111111'
	MOVWF	DB19
	MOVLW	B'11111111'
	MOVWF	DA1A
	MOVLW	B'11111111'
	MOVWF	DB1A
	MOVLW	B'11111111'
	MOVWF	DA1B
	MOVLW	B'11111111'
	MOVWF	DB1B
	MOVLW	B'11111111'
	MOVWF	DA1C
	MOVLW	B'11111111'
	MOVWF	DB1C
	MOVLW	B'11111111'
	MOVWF	DA1D
	MOVLW	B'11111111'
	MOVWF	DB1D
	MOVLW	B'11111111'
	MOVWF	DA1E
	MOVLW	B'11111111'
	MOVWF	DB1E
	MOVLW	B'11111111'
	MOVWF	DA1F
	MOVLW	B'11111111'
	MOVWF	DB1F
	RETURN
;******************************************************************************************
;   Function Name : DSPLED
;   Title         : 16*32LEDを表示する
;   Input         : DA00-DA1F,DB00-DB1F
;   Output        : 
;   Disctiption   : 32回のWAIT(10KHz->約300Hz)
;******************************************************************************************
DSPLED
;Initialize
	CALL	CLRLED
;
;
;00(PORTA0)
	BSF	PORTA,0
	MOVF	DA00,W
	MOVWF	PORTC
	MOVF	DB00,W
	MOVWF	PORTD
	BSF	PORTB,0
	CALL	INRDSP
	BCF	PORTB,0	
;01
	MOVF	DA01,W
	MOVWF	PORTC
	MOVF	DB01,W
	MOVWF	PORTD
	BSF	PORTB,1
	CALL	INRDSP
	BCF	PORTB,1
;02
	MOVF	DA02,W
	MOVWF	PORTC
	MOVF	DB02,W
	MOVWF	PORTD
	BSF	PORTB,2
	CALL	INRDSP
	BCF	PORTB,2
;03
	MOVF	DA03,W
	MOVWF	PORTC
	MOVF	DB03,W
	MOVWF	PORTD
	BSF	PORTB,3
	CALL	INRDSP
	BCF	PORTB,3
;04
	MOVF	DA04,W
	MOVWF	PORTC
	MOVF	DB04,W
	MOVWF	PORTD
	BSF	PORTB,4
	CALL	INRDSP
	BCF	PORTB,4
;05
	MOVF	DA05,W
	MOVWF	PORTC
	MOVF	DB05,W
	MOVWF	PORTD
	BSF	PORTB,5
	CALL	INRDSP
	BCF	PORTB,5
;06
	MOVF	DA06,W
	MOVWF	PORTC
	MOVF	DB06,W
	MOVWF	PORTD
	BSF	PORTB,6
	CALL	INRDSP
	BCF	PORTB,6
;07
	MOVF	DA07,W
	MOVWF	PORTC
	MOVF	DB07,W
	MOVWF	PORTD
	BSF	PORTB,7
	CALL	INRDSP
	BCF	PORTB,7
	BCF	PORTA,0
;
;
;08(PORTA1)
	BSF	PORTA,1
	MOVF	DA08,W
	MOVWF	PORTC
	MOVF	DB08,W
	MOVWF	PORTD
	BSF	PORTB,0
	CALL	INRDSP
	BCF	PORTB,0	
;09
	MOVF	DA09,W
	MOVWF	PORTC
	MOVF	DB09,W
	MOVWF	POR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3


	RETURN

;******************************************************************************************
;   Function Name : CLRLED
;   Title         : 16*32LEDを無表示にする
;   Input         : DA00-DA1F,DB00-DB1F
;   Output        : 
;   Disctiption   : 
;******************************************************************************************
CLRLED
	BCF	PORTA,0
	BCF	PORTA,1
	BCF	PORTA,2
	BCF	PORTA,3
	CLRF	PORTB
	CLRF	PORTC
	CLRF	PORTD
	RETURN

;******************************************************************************************
;   Function Name : INRDSP
;   Title         : LEDの１ドッド表示時間
;   Input         : 
;   Output        : 
;   Disctiption   : 2000回程度(20MHz->約10kHz)
;******************************************************************************************
INRDSP
	MOVLW	H'FF'
	MOVWF	INRDSPLP
INRDSP1 
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	DECFSZ	INRDSPLP,F	
	GOTO	INRDSP1
	RETURN 

;******************************************************************************************
;   Function Name : SERIDAT
;   Disctiption   : データ連動
;                   連動データがあればデータ連動を行なう
;   Input         : なし
;******************************************************************************************
SERIDAT
; 1.データフラグをチェックし、連動データがないなら抜ける
	BTFSC 	PORTA,4
	RETLW	H'00'	
; 2.確認OKシグナルを送る(1=>0)
	BCF	PORTA,5
; 3.受信モードにして相手の送信を待つ 
	CALL	REC
; 4.確認OKシグナルを戻す(0=>1)
	BSF	PORTA,5
; 5.データ移動
	MOVF	IODAT,W
	MOVWF	DSPCOD
	RETLW	H'01'

;******************************************************************************************
;   Function Name : REC
;   Title         : ＲＳ２３２Ｃ受信サブルーチン(PORTA 4)
;                   9600BPS OSC;20.000MHz仕様
;   Input         : 
;   Output        :
;******************************************************************************************
REC
; (0)変数初期化
	CLRF	IODAT
; (1)受信データを待つ
	BTFSC	PORTA,4
	GOTO	REC
; (2)1/2ビット分待つ
	MOVLW	H'55'	; 9600BPS,OSC;20MHz
	MOVWF   RECWAT
REC1	DECFSZ	RECWAT,F
	GOTO	REC1
; (3)データ受信(8ビット分)
	MOVLW	8
	MOVWF	RECLP
	NOP
REC2	MOVLW	H'AA'	; 9600BPS,OSC;20MHz
	MOVWF	RECWAT
REC3	DECFSZ	RECWAT,F
	GOTO	REC3
	NOP
	BTFSS	PORTA,4	; ビットデータが0の時, 0を立てる
	BCF	STATUS,C
	BTFSC	PORTA,4	; ビットデータが1の時, 1を立てる
	BSF	STATUS,C
	RRF	IODAT,F	; 変数内でビットをシフトする
	DECFSZ	RECLP,F
	GOTO	REC2
	NOP
	NOP
;
	RETURN

	END
