XDEF ToUpperTest       
            ABSENTRY ToUpperTest   
            ORG $0800     
MEMSTART    DC.B "This is a TEST to Convert an ASCII STRING TO all Upper Case Characters",0
NR_LOWERCASE 
            DS.W 1       
            ;Note: after the program below has been run to location "STOP_HERE", location NR_LOWERCASE
            ;should contain the value 35 (in decimal), since there are 35 lower case letters that must 
            ;be converted to upper case.  Also, the null-terminated ASCII string at location
            ;MEMSTART will be converted to all upper case letters.
            ORG $4000       
ToUpperTest:
            LDS #$1000
            LDX #MEMSTART
            PSHX
            LDX #NR_LOWERCASE
            PSHX
            BSR ToUpper
            LEAS 6,SP
STOP_HERE:  BRA STOP_HERE
            
ToUpper:    PSHD
            PSHX
            PSHY
            LDX 10,SP
            LDY #0
BACKAGN:    LDAA 0,X
            BEQ DONE_STRING            
NOT_DONE:   CMPA #$61
            BLO  LC_NOT_FOUND
            CMPA #$7A
            BHI  LC_NOT_FOUND
            SUBA #$20
            STAA 0,X 
            INY           
LC_NOT_FOUND:
            INX
            BRA BACKAGN
DONE_STRING:STY [8,SP]
            PULY
            PULX
            PULD
            RTS

            ORG $FFFE
            DC.W ToUpperTest