**********
* Program MEM_OUT (6811)
*
* Sequentially displays the content of memory locations 
* $E000 - $E0FF on LEDs with brief time delay.
*
* Illustrates use of indexed addressing, use of CPX and PUL and PSH.
*
* P. H. Anderson, MSU, 20 Sept 90; 15 Jan 93
**********

PSCT	EQU  $C000
DSCT	EQU  $D000
IDSCT	EQU  $D300

REG_BASE	EQU  $1000
STACKTP		EQU  $0045

PORTB	EQU  $04
PORTC	EQU  $03
DDRC	EQU  $07

	ORG PSCT

	LDS #STACKTP
	LDY #REG_BASE
	CLR DDRC,Y	* port c configured as 8-bit input
*			* although switches not used in this program

	LDX #$E000	* index reg points to first location
L1
	LDAA 00,X	* get the value
	STAA PORTB,Y	* output it
	BSR DELAY	* brief time delay
	CLR PORTB,Y	* blank the LEDs
	BSR DELAY	* brief delay
	INX		* next location
	CPX #$E100	* done?
	BNE L1		* if not repeat

	SWI		* otherwise return control to monitor

DELAY
* subroutine provides brief time delay
	PSHX		* save X on stack
	LDX #$FFFF	* load index with big number
AGN
	DEX		* keep decrementing until 0
	BNE AGN
	PULX		* restore X
	RTS		* back to main program


