; TUTA3.ASM  27SEP07

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 
; Configuration data 
; PICmicro MCU type: 16F1937 
; Oscillator: Oscillator: XTAL mode
; LCD display: off 
; 7-segment display: off 
; Version 3 board settings: J14 links: Digital 
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
; The following lines embed configuration data into the PICmicro
	LIST P=16F1937
  __CONFIG H'8007', H'FE4'  ; Internal osc mode
   __CONFIG H'8008', H'1EFF' 
 #DEFINE   BANK0   MOVLB 0
 #DEFINE   BANK1   MOVLB 1
 #DEFINE   BANK2   MOVLB 2

;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 
	DLY	EQU	H'20'	


; using names to ease writing of TUTA2
				

	PORTB	EQU	H'0D'		; name program location 13 as PORTB
	LATB    EQU	H'10D'
				
	ORG	0		; Reset vector
	GOTO	5		; Goto start of program
	ORG	4		; Interrupt vector
	GOTO	5		; Goto start of program
	ORG	5		; Start of program memory
	CLRF	PORTB		; clear Port B data pins
	BANK1		; Page 1
	MOVLW	0x07
	MOVWF	H'99'		; Setup the OSCCON register to set int osc at 31KHz
	CLRF	H'9E'		; Setup the ADCON1 register
	CLRF	PORTB		; set all Port B as output via Page 1
	BANK2		
				
LOOPIT	BSF	LATB,0		; set Port B pin 0 to logic 1	
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. 
	BSF	LATB,1		; set Port B pin 1 to logic 1
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. 	
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. 
	BSF	LATB,2		; set Port B pin 2 to logic 1
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. 
	BSF	LATB,3		; set Port B pin 3 to logic 1
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. 
	BSF	LATB,4		; set Port B pin 4 to logic 1
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. 
	BSF	LATB,5		; set Port B pin 5 to logic 1
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. 
	BSF	LATB,6		; set Port B pin 6 to logic 1
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. oto	Delay_6
	BSF	LATB,7		; set Port B pin 7 to logic 1
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. 
	CLRF LATB		; clear all PORTB pins
	CALL DELAY          ;Goto the DELAY subroutine then when reaches a RETURN command goto next line down. 
	GOTO	LOOPIT		; goto address LOOPIT

DELAY					;Label address
	CLRF DLY			;Clear DLY user register (Vairable).
Delay_0
 	DECFSZ	DLY, f
 	GOTO	Delay_0	
	RETURN	        ;Return to the next line from CALL command		
	END			; final statement
