In the program below Convert the character in R0 from upperc
In the program below. Convert the character in R0 from upper-case to lower-case by operating on it, NOT replacing it. The lower-case converted character should stay in R0. Hint: See ASCII table and the difference between ‘A’ and ‘a’
AREA Upper2LowerCase, CODE, READONLY
ENTRY
EXPORT __main
__main
MOV R0, #\'A\'
; write your code here
stop B stop
END
Please write a code
Solution
AREA Upper2LowerCase, CODE, READONLY
ENTRY
EXPORT __main
__main
MOV R0, #\'A\'
MOV A, R0
add A, 20H (Since the difference between the ASCII value of \'A\' and \'a\' is 20H
ASCII of A = 41 = 0100 0001
ASCII of a = 61 = 0110 0001
There for to convert uppercase to lowercase we can add 20 to ASCII of A to get \'a\')
MOV R0, A
stop B stop
END
