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