	
	;Blank12F629.asm
	;  3-5-2010 


	list	p=12F629
	radix	dec   
	;Decimal number are shown as:  .10     .255    or d'10'
	;Hex numbers are shown as:   0Ch   0ffh  or 0x2F   0x0ff 
	;Binary numbers are shown as  b'00000000'    or b'11110001'
	
	
	include	"p12f629.inc"
	
		errorlevel	-302	; Don't complain about BANK 1 Registers 

	__CONFIG	_MCLRE_OFF & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT  ;Internal osc.

	
			; globals
aaaa	equ 	20h		;this is the first available file
bbbb	equ 	21h
ccc		equ 	22h
ddd		equ 	23h
eee		equ 	24h
fff		equ		25h

fileA	equ		26h
fileB	equ		27h	
fileC	equ		28h	

filezz	equ		5Fh		;this is the last available file



status		equ	03h
option_reg	equ	81h


						; bits on GPIO
				
pin7		equ	0	;GP0  
pin6	 	equ	1	;GP1
pin5		equ	2	;GP2 and T0CkI
pin4		equ	3	;GP3 input only
pin3		equ	4	;GP4 
pin2		equ	5	;GP5 


						;bits
				
rp0		equ	5			;bit 5 of the status register
		

Start	org	0x00		;program starts at location 000
		nop
		nop
		nop
		nop		;NOPs to get past reset vector address
		nop
		nop




SetUp	bsf		status, rp0 	;Bank 1	
		movlw	b'10000110'		;Turn off T0CKI, prescale for TMR0 = 1:128
		movwf	option_reg
		movlw	b'00001000'		;Set GP0,1,2,4,5, as output
		movwf	TRISIO	   	    ;enable outputs	
		bcf		status, rp0		;bank 0  
		movlw   07h      	    ;Set up W to turn off Comparator ports
        movwf   CMCON    	    ;must be placed in bank 0            
		clrf 	GPIO       		;Clear GPIO of junk		
		goto 	Main	
		
	

Table1	addwf	02,1			;Add W to the Program Counter to create a jump
		retlw  	0ffh			;any value from 0h to 0ffh (hex)
		retlw  	0ffh			
			or	
		retlw  	87				;decimal is the default radix (as provided above)
		retlw	b'00001000' 	;binary "08"
	
 
	
	;Delay 0.51 sec

Del_1	movlw 	02h
		movwf 	fileC	
DelX	decfsz 	fileA,1		; ,1 denotes the result of the decrement 
		goto 	DelX	
		decfsz 	fileB,1		;     is placed in the file	
		goto 	DelX
		decfsz 	fileC,1
		goto 	DelX
		retlw 	00
		
	
Main	movlw	0ffh
		movwf	GPIO
		call 	Del_1
		clrf	GPIO
		call 	Del_1
		goto 	Main

			;oscillator calibration


		call 	03ffh
		movwf	OSCCAL	
		

	end
		

	
	