;=======================================================================
;TITLE:         RETW_Table.src
;
;PURPOSE:       This SX28 code demonstrates the creation and use of an
;               8-bit data table with the RETW command.
;
;AUTHOR:        Parallax, Inc.
;
;REVISIONS:
;  08/12/99 -   Initial release.
;  09/17/04 -   Updated to support SASM.
;
;CONNECTIONS:
;  None.
;
;DETAILS:
;  Use Run -> Debug option to program SX chip.  After it has downloaded and
;  the Debug screens appear, use the Hop or Step buttons to step one
;  instruction at a time.  Watch the Data register in the Watch window
;  after the call to the Table for the value returned from the table
;=======================================================================


;-------------------------- DEVICE DIRECTIVES --------------------------

		DEVICE		SX28,OSC4MHZ,TURBO

IFDEF	__SASM  ;SASM Directives
		DEVICE		STACKX,OPTIONX
		IRC_CAL		IRC_SLOW
		
ELSE		;Parallax Assember Directives
		DEVICE		STACKX_OPTIONX
ENDIF

		RESET		Initialize

;------------------------------ CONSTANTS ------------------------------
		ORG	0

Table		jmp	PC+W			;(3)Jump into lookup table
		retw	'ABCDEFG'		;(3)Store text
		retw	10,100,255,0		;(3)Store numbers

;------------------------------ VARIABLES ------------------------------

		Idx	EQU	$08
		Data	EQU	$09

;---------------------------- DEBUG SETTINGS ---------------------------

		FREQ	4_000_000
	
		WATCH	Data,1,FSTR

;------------------------ INITIALIZATION ROUTINE -----------------------

Initialize
		mov	Idx,#$FF		;Reset Table Index

;---------------------------- MAIN PROGRAM -----------------------------

Main
		inc	Idx			;(1)Increment table index
		mov	w,Idx			;(1)
		call	Table			;(3)Retrieve data
		mov	Data,W
		cjne	Data,#0,Main
		END