	title	"18F Table Example"

; **************************************
; 18F Table Example
; By PEK ´2004
;
; Version: 1.0.0
;
; MCU: PIC18F248
;
; **************************************

	list P=18F248, R=DEC

	include "P18F248.INC"

	__CONFIG _CONFIG1H, _HS_OSC_1H
	__CONFIG _CONFIG2L, _BOR_ON_2L & _BORV_42_2L & _PWRT_ON_2L
	__CONFIG _CONFIG2H, _WDT_OFF_2H


; **************************************
; Definitions
; **************************************


; **************************************
; RAM locations
; **************************************
readPos		EQU	0x0000			; Bytes to read in table


; **************************************
; Vectors
; **************************************
	org	0x00000				; Reset vector
	goto	Start
	

; **************************************
; Start of Program
; ************************************** 
Start
	clrf	PORTB
	clrf	TRISB				; Port B as output

	movlw	UPPER(Table)			; Initialize table pointers
	movwf	TBLPTRU
	movlw	HIGH(Table)
	movwf	TBLPTRH
	movlw	LOW(Table)
	movwf	TBLPTRL

	movlw	4
	movwf	readPos				; Read four bytes

ReadLoop
	tblrd*+					; Read and post increment pointer
	movff	TABLAT,PORTB
	
	decfsz	readPos
	goto	ReadLoop	

	goto	$


Table
	DB  0x01,0x03,0x05,0x07

	END

