Jezer Gùtierrez
Jezer Gùtierrez

Reputation: 21

How to convert the uppercase to lowercase character in assembly language 8086

Mam/Sir Somebody can help me!!!!

I did the format that displayed of the horizontal position after input the single character and so that is a requirement of the output

So this is a expected output

The output should be like this: EVEN EVEN

Input: X

xyz

The requirement should be one input character, first problem is, i didn't not displayed of the lowercase letter when you inputting the uppercase letter, and the last problem is validation instead of the typing the single lowercase it converts to displayed of the uppercase, The validation it should be type the uppercase and it converts to displayed the lowercase, when you type the single lowercase letter it should be not displayed the output this is one of the problem!!!!

Here is my code

.model small
.stack
.data
    input db "Input: $"
.code
org 100h

start:

    main proc

        mov ax,03
        int 10h

        mov ax,@data
        mov ds,ax   

        mov ah,9     
        lea dx, input
        int 21h

        mov ah,01
        int 21h

        mov dh,al
                mov ah,02
                mov dl,9
                int 21h
                mov dl,13
                int 21h

        mov cx,11
        W:
            mov dl,10
            int 21h
            LOOP W

        mov al,dh

        mov bl,al

        cmp bl, 'a'
        jb main
        cmp bl, 'z'
        ja main

        mov dl,al
        sub dl,20h

        mov ah,02
        int 21h

        mov cx,26
        mov dh,dl

            letters:

                 mov bx,cx

                 mov dl,dh

                 cmp dl,'Z'
                 je exit

                 inc dl
                 int 21h
                 mov dh,dl
                 mov cx,bx

            loop letters



        mov ah,4ch
        int 21h
    main endp

    down proc
                mov dl,13
                int 21h
                mov dl,10
                int 21h
                ret
            down endp

            exit proc

        mov cx,12
        Q:
            call down
            LOOP Q
            mov ah, 9

                mov ah,4ch
                int 21h
            exit endp

end start

Upvotes: 1

Views: 23412

Answers (3)

Areeba Hamood
Areeba Hamood

Reputation: 1

org 100h

.model small
.data 
     msg1 db 13,10, "Enter an upper case letter: $"
     msg2 db 13,10, "In lower case: $"
.code 
main proc
    
    mov ax,@data
    mov dx,ax
    
    mov dx,offset msg1
    
    mov ah,9
    int 21h

mov ah,1
int 21h 

mov bl,al

add bl,32 ;for lower case to upper case simply sub bl,32

 mov ax,@data
    mov dx,ax
    
    mov dx,offset msg2
    
    mov ah,9
    int 21h

mov dl,bl

mov ah,2
int 21h

mov ah,4ch
int 21h
    
    
  main endp
end main

ret

Upvotes: 0

Mansour Sami
Mansour Sami

Reputation: 1

use xor with 32. But be aware it could change upper to lower and vise versa.

xor al, 32              
mov array[esi], al

Upvotes: 0

Antonin GAVREL
Antonin GAVREL

Reputation: 11259

Assuming that edi contains your character:

lea     edx, [edi - ('A')]     ; we substract the value of the letter A
mov     eax, edi     ; return value set to input value
or      edi, 0x20    ; create a lowercase version
cmp     edx, 'Z'-'A' ; that we will use only if we were facing an upper case character
cmovb   eax, edi     ; if it was, we move value from edi to eax

Credit: Peter Cordes for the shorter code and the bug fix.

You could also use a lookup table.

Upvotes: 1

Related Questions