
; TOUPPER_STR function: replaces lowecase character in the string with uppercase characters; string address is passed in R1

LOWER_A:        byte 61              ; 61h = 97
UPPER_A:        byte 41              ; 41h = 65
LOWER_Z:        byte 7A              ; 7Ah = 122
UPPER_Z:        byte 5A              ; 5Ah = 90 (unused; see TOLOWER)

TOUPPER_STR:    LDBA R2 LOWER_A      ; void toupper_str (char *s)
                LDBA R3 LOWER_Z
                LDBA R4 UPPER_A

TOUPSTR_L1:     LDBR R5 R1
                JMPZ TOUPSTR_END
                MV R5 R10
                SUB R2 R10
                JMPN TOUPSTR_NOLOW   ; s[i] < 'a'?
                MV R3 R10
                SUB R5 R10
                JMPN TOUPSTR_NOLOW   ; s[i] > 'z'?
                SUB R2 R5
                ADD R4 R5
                STBR R5 R1
TOUPSTR_NOLOW:  INC R1
                JMP TOUPSTR_L1

TOUPSTR_END:    RET
