RESET ORG 0x0000 ; processor reset vector
PAGESEL START
GOTO START ; go to beginning of program
;------------------------------------------------------------------------------
; MAIN PROGRAM
;------------------------------------------------------------------------------
START
clrf CONTADOR
banksel TRISB
clrf TRISB ;Value used to
;initialize data direction
;Set RB<7:0> as outputs
banksel PORTB ;Select bank of PORTB
movlw b'10000000' ;Encendemos Led en PB7
movwf DATO ;Guardamos el código en un Registro
SEGUIR1 movf DATO,W ;Transferimos la información del registro DATO
movwf PORTB ;al Puerto B
incf CONTADOR ;Incrementamos CONTADOR
call Retardo_200ms ;LLamamos a subrutina
movf CONTADOR,W ;Preguntamos si CONTADOR=8
xorlw 0x08
btfsc STATUS,Z
goto SEGUIR2
SEGUIR4 bcf STATUS,C ;Si CONTADOR <> 8 ponemos el Cy=0
rrf DATO,F ;y rotamos hacia la derecha el registro DATO
goto SEGUIR1 ;Seguimos hacia la derecha
SEGUIR2 clrf CONTADOR ;Si CONTADOR=8 ponemos el CONTADOR=0, Cy=0
SEGUIR3 bcf STATUS,C ;y rotamos hacia la izquuierda el registro DATO
rlf DATO,F
movf DATO,W ;Transferimos la informacion del registro DATO
movwf PORTB ;al PuertoB
call Retardo_200ms ;LLamamos a subrutina de retardo
incf CONTADOR ;Preguntamos si CONTADOR=7
movf CONTADOR,W
xorlw 0x07
btfss STATUS,Z
goto SEGUIR3 ;Seguimos hacia la izquierda
movlw 0x01 ;Ponemos el CONTADOR=1 y volvemos hacia la izquierda
movwf CONTADOR
goto SEGUIR4
#INCLUDE <Retardo_200ms.inc>
END