#include <p16f628.inc>
org 0x00

#define clock PORTA,3 ;i/p clock

;EEPROM bit patterns

ee1 dbee 0x24 ;100 100
ee2 dbee 0x36 ;110 110
ee3 dbee 0x12 ;010 010
ee4 dbee 0x1b ;011 011
ee5 dbee 0x09 ;001 001
ee6 dbee 0x2d ;101 101

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
          bsf    EECON1,RD
          bcf    STATUS,RP0
          movf   EEDATA,W
          return

end
