; ***************************************************
; Port Usage
;
; PORT	B			Incrememting output
; PORT	A			Increments every 256 incrememnts of B
; ***************************************************

; This code is targeted to the PIC 16F628
;
		list		p=16F628
		include		"p16f628.inc"

; ***************************************************
; PIC Configuration
;
; Modify as required for your keyboard matrix circuit.
; Though, obviously you still need 15 IO pins free.
;
; Configuration:
;		Code protect disabled
;		Watchdog disabled
;		MCLR disabled (as I can't be bothered tying the line!)
;		LVP disabled
;		Brown out detect disabled
;		Power up timer enabled (in case keyboard takes time)
;		Internal oscillator (no clock out)
; ***************************************************
		__config	_BODEN_OFF&_CP_OFF&_DATA_CP_OFF&_PWRTE_ON&_WDT_OFF&_LVP_OFF&_MCLRE_OFF&_INTRC_OSC_NOCLKOUT

        ; File registers
        ;
        cblock 0x20
        	VAL_A
        	VAL_B
        endc

        org     0x0000                  ;org sets the origin, 0x0000 for the 16F628,
main: 
        movlw   0x07
        movwf   CMCON                   ;turn comparators off (make it like a 16F84)

        bsf     STATUS,         RP0     ; Select bank 1
        clrf	TRISB					; Note that one bit in
        clrf	TRISA                   ; Port A will not output
        bcf     STATUS,         RP0     ; Select bank 0
        
        clrf	VAL_A
        clrf	VAL_B
        
loop:
		incfsz	VAL_B,1
		goto	noinc
		incf	VAL_A,1
noinc:
		movfw	VAL_B
		movwf	PORTB
		movfw	VAL_A
		movwf	PORTA
		
		goto	loop

        end
