Upper To Lower n vice versa
AIM:-Write a program to convert the string from upper case to lower case and vice versa.
.model small
.data
str1 db 25 , ? , 25 dup(‘$’)
str2 db 25 , ? , 25 dup(‘$’)
str3 db 25 , ? , 25 dup(‘$’)
msg1 db 0ah,0dh,’menu $’
msg21 db 0ah,0dh,’accept the string $’
msg6 db 0ah,0dh,’string is : $’
msg7 db 0ah,0dh,’ $’
.code
mov ax,@data
mov ds,ax
mov ah,0ah
lea dx,str1
int 21h
endd: mov ah,4ch
int 21h
lea si,str1+2 ; source string
lea di,str2+2 ; destination string
mov cl,str1+1
back: mov al,byte ptr[si]
cmp al,41h ; check if letter
jge bigg
jmp stop
smal : cmp al,61h ; check if letter is lower case
jge subb
bigg : cmp al,5ah ; check if letter is upper case
jge smal ; if greater letter is small case
add al,20h ; make letter lower case
branc: mov byte ptr[di],al ; move letter to destination
inc di
inc si
dec cl ; decrememt count
cmp cl, 00h
jne back ; check next character
jmp stop
subb: cmp al,7ah ; if small case letter
jge stop ; if not letter display as is
sub al,20h ; make letter upper case
jmp branc
stop:
mov ah,09h ; display result
lea dx,str2+2
int 21h
end