#include <p16f690.inc>
  __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
 
 c1 equ 20  ; counter for delay
 c2 equ 21  ; counter for delay
 c3 equ 22  ; incremented byte for transfer
 
 org 0

Start
 bcf STATUS,RP0  ;sets bank 1 registers
 movlw b'10010000' ;enables serial port, continuous receive  
 movwf RCSTA
 BSF   STATUS,RP0  ;sets bank 2 registers 
 movlw  b'00100100' ;sets serial transfer parameters
 movwf TXSTA
 movlw b'00011001' ;sets baud rate to 9600 BAUD
 movwf SPBRG     
 bcf STATUS,RP0 ;set bank 1 registers
 bcf PIR1,RCIF ;sets receive interupt flag
 movlw 0
 movwf c3    ;start c3 at 0
loop
 bcf STATUS,RP0  ;set bank 0 registers
 incf c3,1 ; add 1 to c3
 bsf STATUS,RP0 ;set bank 1 registers
 btfss TXSTA,TRMT ;check if txreg is empty
 goto $-1
 bcf STATUS,RP0 ;set bank 0 registers
 movf c3,0  ; move c3 into w
 movwf TXREG ;put W data into txreg
 call delay1
 GOTO loop

delay1
 movlw b'11111111'
 bcf STATUS,RP0
 movwf c2
lc0
 movlw b'11111111'
 movwf c1
lc1
 decfsz c1,1
 goto lc1
 decfsz c2,1
 goto lc0
 return

 end
