LIST P=PIC16F84A INCLUDE "P16F84A.INC" tm1 EQU 0CH ; tm2 EQU 0DH ; tm3 EQU 0EH ; org 0 goto start org 4 goto start org 5 start bsf STATUS,RP0 clrf TRISA clrf TRISB bsf TRISA,0 bsf TRISA,1 bcf STATUS,RP0 movlw 1 movwf portb main call tim100 goto main1 main1 call tim100 bcf status,C btfsc portb,7 bsf status,C ;C(キャリービット) rlf portb,F ;F(レジスタに直接書き込む) btfss porta,0 goto main2 goto main1 main2 call tim100 bcf status,C btfsc portb,0 bsf status,C rrf portb,F btfss porta,1 goto main1 goto main2 ;以下0.5秒ルーチン tim05 movlw 063H movwf tm1 wait1 nop nop decfsz tm1,F goto wait1 return tim100 movlw 0c7H movwf tm2 wait2 call tim05 decfsz tm2,F goto wait2 return wait05 movlw 5 movwf tm3 wait3 call tim100 decfsz tm3,F goto wait3 return end