* Pass the parameter using global memory.

	ORG	$0B00
* The below constants could also be variables (DS.B) with 
* there values defined or calculated elsewhere
DATA1	DC.B	$37
DATA2	DC.B	$A3
	
**** Main routine
	ORG	$0900	;Start program at $0900
START:	LDS	#$900	;initialize stack pointer
	JSR	AVG	;Call subroutine AVG
*			; to get the average
HERE:	BRA	HERE	;Stay here (endless loop)

*********************************************************
**** Subroutine: AVG
* Get the average of (DATA1) & (DATA2)
* Output in accumulator A
AVG:	LDAA	DATA1 	;Load data in the A
	ADDA	DATA2	;Add it to the data at DATA2
	ASRA		;Shift A right by 1 bit
*			;  (divide by 2) keeping
*			;  bit 7 (for sign extension)  
	RTS