#include <p16f628.inc>
org 0x00

#define clock PORTA,3 ;i/p clock
index equ 0x10     ;RAM byte for counter
setup     movlw  0x08
          movwf  TRISA
          movlw  0x00
          movwf  TRISB
          movlw  0x80
          movwf  OPTION_REG
          clrf   index
          movlw  0x24
          movwf  PORTB

clocklo   btfss  clock        ;wait for ext clock to go high
          goto   clocklo

change    movf   index,w      ;get next bit pattern from EE
          movwf  EEADR
          call   readee
          movwf  PORTB

          incf   index,f
          movlw  0x06         ;loop for 6 EE locations
          xorwf  index,w
          btfss  STATUS,Z
          goto   clockhi
          clrf   index

clockhi   btfsc  clock        ;wait for clock low
          goto   clockhi
  	      goto   clocklo      ;next clock, next pattern

readee    bsf    STATUS,RP0   ;get next pattern from EEPROM
	
		  movwf 	EEADR          
		  bsf    EECON1,RD
		  movf   EEDATA,W
          bcf    STATUS,RP0
          
          return

end


