;Homework #3 Bubble Sort & Passing Parameters via Stack
       		XDEF Entry                
        		ABSENTRY Entry   
        		ORG $0400
RESULT_RAM:	RMB 10	;Reserve 10 RAM bytes where data list to be sorted 
                      		;will be placed. Sorted data will reside here as well
                     		;once the sorting subroutine has run.
SWAP_FLAG:    	RMB 1  	;Used to keep track of whether a swap was made
			ORG $4000
DATLIST:		FCB $2C,$84,$55,$00,$A5,$FE,$72,$84,$32,$2C   ;Data List in ROM
NR_ELEMENTS:	EQU 10
Entry:		LDS #$1000		;Initialize the Stack at 1 location above where RAM ends	
			LDX #RESULT_RAM
			LDY #DATLIST
			LDAA #NR_ELEMENTS-1
MOVE_NXT:		
      		MOVB A,Y, A,X  		;copy data to be sorted to RESULT_RAM array
			DECA
			BPL MOVE_NXT
      		LDAA #10	
			PSHA			;Push number of bytes to sort.
			LDD #RESULT_RAM
			PSHD			;Push starting addr of data list.
			JSR UNSIGNED_SORT
			LEAS 3,SP		;Clean input arguments off stack (Increment SP by 3)      
DYNHLT:		BRA DYNHLT		;by adding 3 to SP.  
;******** Start of Your Subroutine "UNSIGNED_SORT" ***************
UNSIGNED_SORT:   *****YOU MUST WRITE THIS SUBROUTINE!*****
RTS