0% found this document useful (0 votes)
32 views6 pages

Lab 6

This program performs the following tasks in 3 sentences or less: The program takes a string as input from the user and prints out only the capital letters from A to Z and small letters from a to z, skipping other characters. It uses loops to iterate through the input string, compare each character, and print matching characters until reaching the terminating '$' character.

Uploaded by

ashiqirfanaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views6 pages

Lab 6

This program performs the following tasks in 3 sentences or less: The program takes a string as input from the user and prints out only the capital letters from A to Z and small letters from a to z, skipping other characters. It uses loops to iterate through the input string, compare each character, and print matching characters until reaching the terminating '$' character.

Uploaded by

ashiqirfanaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Q1)

.8086
.model small
.stack 100h
.data
msg1 db 13,10, "Enter the number of digits $"
msg3 db 13,10, "The number is a harshad number $"
msg4 db 13,10, "The number is not a harshad number $"
msg5 db 13,10, "Enter the number $"
digit db 0
number dw 0
.code
mov ax,@data
mov ds,ax

mov ah,09h
lea dx,msg1
int 21h

mov ah,01h
int 21h
sub al,30h
mov cl,al ;cl stores the number of digits

mov bl,0 ;stores the sum of digits

mov ah,09h
lea dx,msg5
int 21h

mov ah,0
mov ch,0
loop1:
mov dx,10
mov ah,01h
int 21h
sub al,30h
add bl,al
mov digit,al
mov ax,number
mul dx
mov dl,digit
add ax,dx
mov number,ax
inc ch
cmp ch,cl
jne loop1

;Now the sum of digits is stored in bl


;number is stored in the number variable
mov ax,number
div bl
cmp ah,0
je har
jmp nothar

har:
mov ah,09h
lea dx,msg3
int 21h
jmp exitt

nothar:
mov ah,09h
lea dx,msg4
int 21h
jmp exitt

exitt:
mov ax,4c00h
int 21h

PRINT PROC

mov cx,0
mov dx,0
loop2:
cmp ax,0
je print1
mov bx,10
div bx
push dx
inc cx
xor dx,dx
jmp loop2
print1:
cmp cx,0
je exit
pop dx
add dx,48
mov ah,02h
int 21h
dec cx
jmp print1
exit:
ret
PRINT ENDP
end
OUTPUT:-

Q2)

.8086
.model small
.stack 100h
.data
msg1 db 13,10, "The largest number is: $"
msg2 db 13,10, "Enter the number of numbers: $"
msg3 db 13,10, "Enter the number: $"
x db 20 dup(?)
counter1 db 0
counter2 db 0
.code
mov ax,@data
mov ds,ax

mov ah,09h
lea dx, msg2
int 21h

mov ah,01h
int 21h
sub al,30h
mov cl,al;cl stores the length of the array

mov si, offset x


mov di, offset x

mov bl,0
mov ch,0

;get inputs
loop1:
mov ah,09h
lea dx, msg3
int 21h
mov ah,01h
int 21h
mov [si],al
inc si
inc ch
cmp ch,cl
jne loop1

mov ch,0
loop2:
cmp [di],bl
jge loop3
inc di
inc ch
cmp ch,cl
je exitt
jmp loop2

loop3:
mov bl,[di]
inc di
inc ch
cmp ch,cl
je exitt
jmp loop2

exitt:
mov ah,09h
lea dx, msg1
int 21h
mov dl,bl
mov ah,02h
int 21h

mov ax,4c00h
int 21h
end
OUTPUT:-

Q3)

.8086
.model small
.stack 100h
.data
msg1 db 13,10, "Enter the string: $"
x db 20 dup(?)
.code
mov ax,@data
mov ds,ax

mov ah,09h
lea dx,msg1
int 21h

mov si, offset x


mov di, offset x

loop1:
mov ah,01h
int 21h
mov [si],al
cmp al,'$'
je loop2
inc si
jmp loop1

loop2:
mov bl,[di]
cmp bl,'$'
je exitt
mov bl,[di]
cmp bl,'A'
jge loop3
inc di
jmp loop2

loop3:
mov bl,[di]
cmp bl,'z'
jle loop4
inc di
jmp loop2

loop4:
mov dl,[di]
mov ah,02h
int 21h
inc di
jmp loop2

exitt:
mov ax,4c00h
int 21h
end

OUTPUT:-

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy