You are on page 1of 7

Question 1: Write an assembly code to input an uppercase letter and output the

letter in lowercase form.

Solution

.model small
.stack
.data
          Adb 0dh,0ah, “ENTER an INPUT...”, 0dh, 0ah, “$”
          Bdb0dh,0ah, “The OUTPUT is...”,0dh,0ah, “$”
.code
 main proc
          mov ax,@data
          mov ds,ax

          lea dx, A


          mov ah,09h
          int 21h

          mov ah,01h


          int 21h
          add al,20h
          mov bl,al

          lea dx,B


          mov ah,09h
          int 21h

          mov dl,bl


          mov ah,02h
          int 21h

          mov ah,4ch


          int 21h
main endp
end main

Question 2: Write an assembly code to input a word consisting of uppercase and


lowercase letters. If there is no uppercase letter the program will output, “No
uppercase letters”. And if there is uppercase letter the program will output the first
and last uppercase letter.

Question 3: Write an assembly code to input two numbers and output the product
by applying booth’s multiplication.

Solution
.model small
.stack 100h
.data
num db 2 dup(0)

.code

main proc

mov ax, @data


mov dx, ax

mov ah, 1
int 21h ;get a number from user
mov num, dl ;store number in num[0]

int 21h ;get number from user

mov ah, 2
int 21h

mov ah, 4ch


int 21h

main endp
end main

Question 4. Write an assembly code to input a word consisting of uppercase letter


and output the total number of vowels and consonants in the given word.

Solution
.model small
.stack
print macro p
            lea dx,p
            mov ah,09h
            int 21h
endm

display macro g
            mov dl,g
            mov bh,0ah
            mov ah,00h
            mov al,dl
            div bh
            mov ch,ah
            mov dl,al
            add dl,30h
            mov ah,02h
            int 21h
            mov dl,ch
            add dl,30h
            mov ah,02h
            int 21h
endm
.data
            m1 db 0ah,0dh,"Enter the String: $"
            m2 db 0ah,0dh,"Vowels= $"
            m3 db 0ah,0dh,"Consonants= $"
            m4 db 0ah,0dh,"No of Vowels= $"
            m5 db 0ah,0dh,"No of Consonants= $"
            a db 20h dup("$")
            b db "aeiouAEIOU"
            v db 20h dup("$")
            co db 20h dup("$")
            k dw 0
            f dw 0
            g db 0
            z db 0
.code
            mov ax,@data
            mov ds,ax
            mov es,ax
            mov si,0000h
            print m1

loop1:  mov ah,01h
            int  21h
            mov a[si],al
            inc si
            cmp al,0dh
            jne loop1
           
            mov cx,si
            mov di,0000h
            mov si,0000h
            dec cx

loop3:  mov bh,a[si]
loop4:  mov bl,b[di]
            cmp bh,bl
            jne loop2
            mov dx,0000h
            mov dx,si
            mov si,k
            inc k
            mov v[si],bh
            inc g
            mov si,dx
loop6:  inc si
            mov di,0000h
            cmp si,cx
            jne loop3
            jmp loop5

loop2:  inc di
            cmp di,0ah
            jl loop4
            mov dx,0000h
            mov dx,si
            mov si,f
            inc f
            mov co[si],bh
            inc z
            mov si,dx
            jmp loop6
           

loop5:  print m2
            print v
            print m4
            display g
            print m3
            print co
            print m5
            display z
            mov ah,4ch
            int 21h
end

You might also like