*Parameters pointers in program memory space

	ORG	$0B00
LOCAT:	DC.B	$37, $A3	;Define the location of data
*				;  and some default data

**** Main routine
	ORG	$0900	; Start program at $0900
START:	LDS	#$900	; initialize stack pointer
	JSR	AVG	; Call subroutine AVG
DAT_AD: DC.W	LOCAT	; Define the location of data
HERE:	BRA	HERE	; Stay Here(endless loop)

*********************************************************
**** Subroutine: AVG
* Get average of two data bytes in program memory at
* location pointed to by the pointer on top of stack
* Output in A
* X affected
* Stack return address corrected
	ORG	$A00
AVG:	PULX		;Get address of pointer to
*			;  data
	INX		;Increment the X index
	INX		;  register twice to point 
*			;   to next instruction 
*			;   upon RTS
	PSHX		;Push the corrected address
*			;  back on stack
	LDX	-2,X	;Put the pointer into X
	LDAA	0,X	;Get first piece of data
	ADDA	1,X	;A=A + (data at DATA2)
	ASRA		;Divide by 2
	RTS
