8086 or MASM PROGRAM to input 9 digits and display the second biggest number that can be formed using those digits
stack1 segment
store1 db 10,0,10 dup('$')
stack1 ends
data1 segment
msg db 0ah,0dh,'enter the 9 digit number$'
number db 12,0,12 dup('$')
msg1 db 0ah,0dh,'the rearranged order is=$'
data1 ends
stack1 segment
store db 10,0,10 dup('$')
stack1 ends
code1 segment
start;mov ax,seg data1
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
lea dx,number
mov ah,0ah
int 21h
mov cx,0008h
pass:push cx
mov cx,0008h
lea dx,number+2
mov si,dx
again:mov al,[si]
cmp al,[si+1]
jnc down
xchg al,[si+1]
xchg al,[si]
down:
inc si
loop again
pop cx
loop pass
mov al,[si]
xchg al,[si-1]
xchg al,[si]
lea dx,msg1
mov ah,09h
int 21h
lea dx,number+2
mov ah,09h
int 21h
mov ah,4ch
int 21h
code1 ends
end start
__________________________________________
8086 or MASM PROGRAM to display the multiplication table (first 10 values) for a number N(<10d)
data1 segment
msg db 0ah,0dh,'enter the number$'
number db 2,0,2 dup('$')
decimal db '0','1','2','3','4','5','6','7','8','9'
ans db 0ah,'0','*','0','=','0','0','$'
data1 ends
code1 segment
start;mov ax,seg data1
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov cx,000ah
mov dl,0ah
mov ah,02h
int 21h
lea dx,number
mov ah,0ah
int 21h
lea dx,number
inc dx
inc dx
mov di,dx
mov bl,[di]
and bl,0fh
lea dx,ans
inc dx
mov si,dx
mov dl,[di]
mov [si],dl
lea dx,ans
inc dx
mov di,dx
lea dx,decimal
mov si,dx
again:lea dx,ans
inc dx
mov di,dx
mov al,[si]
inc di
inc di
mov [di],al
mov bh,[si]
mov ax,0000h
and bh,0fh
mov al,bh
mul bl
aam
add ax,03030h
inc di
inc di
mov [di],ah
inc di
mov [di],al
lea dx,ans
mov ah,09h
int 21h
inc si
loop again
mov ah,4ch
int 21h
code1 ends
end start
_________________________________________________
8086 OR MASM PROGRAM TO CONVERT THE Given temperature in Centigrade(<100°C) to Fahrenheit and Kelvin and display it (i/p and o/p as Decimal numbers)
data1 segment
msg db 0ah,0dh,'enter the temperature in degree celsius',0ah,'$'
msg1 db 0ah,0dh,'error! enter a temperature less than 99 degree C$'
msg2 db 0ah,0dh,'the temperature in kelvin scale is=$'
msg3 db 0ah,0dh,'the temperature in farenheit scale is approximately=$'
msg4 db 0ah,0dh,'the temperature in celsius scale is=$'
temp db 6,0,6 dup('$')
result db 20,0,20 dup('$')
data1 ends
code1 seg
start:mov ax,seg data1
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov ch,02h
ask:
lea dx,temp
mov ah,0ah
int 21h
lea dx,msg4
mov ah,09h
int 21h
lea dx,temp+2
mov ah,09h
int 21h
do:
lea bx,temp+1
mov cl,[bx]
inc bx
mov ah,[bx]
dec cl
jz down
mov al,[bx+1]
dec cl
jz down1
lea dx,msg1
mov ah,09h
int 21h
jmp ask
down:
mov al,ah
mov ah,00h
down1:
and ax,0f0fh
aad
dec ch
jz second
add ax,0111h;273 addition
call display
lea dx,msg2
call show
jmp do
second:
mov cl,09h
mul cl
mov cl,05h
div cl
mov ah,00h
add al,20h;hex equivalent of 32
call display
lea dx,msg3
call show
jmp over
display:lea bx,result+4
mov dl,03h
mov cl,0ah
again:
div cl
add ah,30h
mov [bx],ah
dec bx
mov ah,00h
dec dl
jnz again
ret
show:
mov ah,09h
int 21h
lea dx,result+2
mov ah,09h
int 21h
ret
over:
mov ah,4ch
int 21h
code1 ends
_________________________________
8086 OR MASM PROGRAM TO Count and display the number of occurrances of (i) vowels (ii) a given word from a given string
data1 segment
msg db 0ah,0dh,'enter the word in small letters',0ah,'$'
msg1 db 0ah,0dh,'the number of vowels in the given string is=$'
msg2 db 0ah,0dh,'the number of occurance of the word in the given string is=$'
vowel db 'a','e','i','o','u'
enter db 'is is is$'
get db 20,0,20 dup('$')
data1 ends
code1 segment
start:mov ax,seg data1
mov ds,ax
lea dx,msg1
mov ah,09h
int 21h
lea bx,enter
mov si,bx
mov bl,00h
check:
lea dx,vowel
mov di,dx
mov dx,0005h
mov al,[si]
repeat1:cmp al,[di]
jz down
inc di
dec dl
jnz repeat1
jmp have
down:inc bl
have:inc si
mov dh,'$'
cmp [si],dh
jnz check
mov dl,bl
add dl,30h
mov ah,02h
int 21h
lea dx,msg
mov ah,09h
int 21h
lea dx,get
mov ah,0ah
int 21h
lea dx,msg2
mov ah,09h
int 21h
lea dx,enter
mov si,dx
mov dx,0000h
again:
lea bx,get+1
mov cl,[bx]
inc bx
mov di,bx
again1:
mov al,[si]
cmp al,[di]
jnz under
inc si
inc di
loop again1
mov bl,20h
cmp [si],bl;ASCII OF SPACE
jz found
mov bl,24h
cmp [si],bl;ASCII of $
jz found
under:inc si
mov bl,20h
cmp [si],bl
jz do
mov bl,24h
cmp [si],bl
jz over
jmp under
found:
inc dl
do:inc si
mov bl,24h
cmp [si],bl
jz over
jmp again
over:add dl,30h
mov ah,02h
int 21h
mov ah,4ch
int 21h
code1 ends
______________________________
8086/MASM PROGRAM TO CHECK WHETHER THE MOBILE NUMBER ENTERED THROUGH KEYBOARD IS DIVISIBLE BY NINE
data segment
msg db 0ah,0dh,'enter the mobile number$'
number db 20,0,20 dup('$')
yes db 0ah,0dh,'YES$'
no db 0ah,0dh,'NO$'
data ends
code segment
start:mov ax,seg data
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
lea dx,number
mov ah,0ah
int 21h
lea dx,number
mov sl,dx
inc si
inc si
mov cx,000ah
again:mov al,[si]
and al,0fh
mov [si],al
inc si
loop again
lea dx,number
mov si,dx
inc si
inc si
mov cx,0009h
mov ax,0000h
mov ai,[si]
adding:add al,[si+1]
inc si
loop adding
mov bl,03h
div bl
and ah,0ffh
jz yess
lea dx,no
mov ah,09h
int 21h
jmp down
yess:lea dx,yes
mov ah,09h
int 21h
down: mov ah,4ch
int 21h
code ends
______________________________
8086 PROGRAM TO CONVERT THE TEMPERATURE IN DEGREE CELCIUS TO FAHRENHEIT AND KELVIN SCALE
assume ds:data1,cs:code1
data1 segment
msg db 0ah,0dh,'enter the temperature in degree celsius',0ah,'$'
msg1 db 0ah,0dh,'error! enter a temperature less than 99degree C$'
msg2 db 0ah,0dh,'the temperature in kelvin scale is=$'
msg3 db 0ah,0dh,'the temperature in farenheit scale is approximately=$'
msg4 db 0ah,0dh,'the temperature in celsius scale is=$'
temp db 6,0,6 dup('$')
result db 20,0,20 dup('$')
data1 ends
code1 segment
start:mov ax,seg data1
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov ch,02h
ask:
lea dx,temp
mov ah,0ah
int 21h
lea dx,msg4
mov ah,09h
int 21h
lea dx,temp+2
mov ah,09h
int 21h
do:
lea bx,temp+1
mov cl,[bx]
inc bx
mov ah,[bx]
dec cl
jz down
mov al,[bx+1]
dec cl
jz down1
lea dx,msg1
mov ah,09h
int 21h
jmp ask
down:
mov al,ah
mov ah,00h
down1:
and ax,0f0fh
aad
dec ch
jz second
add ax,0111h;273 addition
call display
lea dx,msg2
call show
jmp do
second:
mov cl,09h
mul cl
mov cl,05h
div cl
mov ah,00h
add al,20h;hex equivalent of 32
call display
lea dx,msg3
call show
jmp over
display:lea bx,result+4
mov dl,03h
mov cl,0ah
again:
div cl
add ah,30h
mov [bx],ah
dec bx
mov ah,00h
dec dl
jnz again
ret
show:
mov ah,09h
int 21h
lea dx,result+2
mov ah,09h
int 21h
ret
over:
mov ah,4ch
int 21h
code1 ends
end start
_________________________________
8086 MASM PROGRAM TO Read in a binary string through keyboard and Display it in the reverse order.Also display its Parity.
data1 segment
msg db 0ah,0dh,'enter the binary number$'
number db 20,0,20 dup('$')
msg2 db 0ah,0dh,'the number in reversed order is$',0ah,0dh
odd db 0ah,0dh,'the number has odd parity$'
evenpar db 0ah,0dh,'the number has even parity$'
data1 ends
code1 segment
start:mov ax,seg data1
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
lea dx,number
mov ah,0ah
int 21h
mov bx,0000h
mov cx,bx
mov cl,number+1
lea si,number+2
again:mov ax,0001h
and al,[si]
jz skip
inc bx
skip:inc si
loop again
lea dx,msg2
mov ah,09h
int 21h
mov cx,0000h
mov cl,number+1
dec si
do:
mov dl,[si]
mov ah,02h
int 21h
dec si
loop do
mov ax,bx
mov bl,02h
div bl
and ah,01h
jnz oddpar
lea dx,evenpar
mov ah,09h
int 21h
jmp down
oddpar:
lea dx,odd
mov ah,09h
int 21h
down: mov ah,4ch
int 21h
code1 endsend start
_______________________________
8086 PROGRAM TO CONVERT THE TEMPERATURE IN DEGREE CELCIUS TO FAHRENHEIT AND KELVIN SCALE
assume ds:data1,cs:code1
data1 segment
msg db 0ah,0dh,'enter the temperature in degree celsius',0ah,'$'
msg1 db 0ah,0dh,'error! enter a temperature less than 99degree C$'
msg2 db 0ah,0dh,'the temperature in kelvin scale is=$'
msg3 db 0ah,0dh,'the temperature in farenheit scale is approximately=$'
msg4 db 0ah,0dh,'the temperature in celsius scale is=$'
temp db 6,0,6 dup('$')
result db 20,0,20 dup('$')
data1 ends
code1 segment
start:mov ax,seg data1
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov ch,02h
ask:
lea dx,temp
mov ah,0ah
int 21h
lea dx,msg4
mov ah,09h
int 21h
lea dx,temp+2
mov ah,09h
int 21h
do:
lea bx,temp+1
mov cl,[bx]
inc bx
mov ah,[bx]
dec cl
jz down
mov al,[bx+1]
dec cl
jz down1
lea dx,msg1
mov ah,09h
int 21h
jmp ask
down:
mov al,ah
mov ah,00h
down1:
and ax,0f0fh
aad
dec ch
jz second
add ax,0111h;273 addition
call display
lea dx,msg2
call show
jmp do
second:
mov cl,09h
mul cl
mov cl,05h
div cl
mov ah,00h
add al,20h;hex equivalent of 32
call display
lea dx,msg3
call show
jmp over
display:lea bx,result+4
mov dl,03h
mov cl,0ah
again:
div cl
add ah,30h
mov [bx],ah
dec bx
mov ah,00h
dec dl
jnz again
ret
show:
mov ah,09h
int 21h
lea dx,result+2
mov ah,09h
int 21h
ret
over:
mov ah,4ch
int 21h
code1 ends
end start
___________________________
8086 MASM PROGRAM TO Read in a binary string through keyboard and Display it in the reverse order.Also display its Parity.
data1 segment
msg db 0ah,0dh,'enter the binary number$'
number db 20,0,20 dup('$')
msg2 db 0ah,0dh,'the number in reversed order is$',0ah,0dh
odd db 0ah,0dh,'the number has odd parity$'
evenpar db 0ah,0dh,'the number has even parity$'
data1 ends
code1 segment
start:mov ax,seg data1
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
lea dx,number
mov ah,0ah
int 21h
mov bx,0000h
mov cx,bx
mov cl,number+1
lea si,number+2
again:mov ax,0001h
and al,[si]
jz skip
inc bx
skip:inc si
loop again
lea dx,msg2
mov ah,09h
int 21h
mov cx,0000h
mov cl,number+1
dec si
do:
mov dl,[si]
mov ah,02h
int 21h
dec si
loop do
mov ax,bx
mov bl,02h
div bl
and ah,01h
jnz oddpar
lea dx,evenpar
mov ah,09h
int 21h
jmp down
oddpar:
lea dx,odd
mov ah,09h
int 21h
down: mov ah,4ch
int 21h
code1 endsend start
______________________________
8086 MASM PROGRAM TO FIND OUT WHETHER THE GIVEN YEAR IS A LEAP YEAR OR NOT
data1 segment
msg db 0ah,0dh,'enter the year$'
number db 6,0,6 dup('$')
ys db 0ah,0dh,'yes,it is a leap year$'
n db 0ah,0dh,'no,it is not a leap year$'
data1 ends
code1 segment
start:mov ax,seg data1
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
lea dx,number
mov ah,0ah
int 21h
lea bx,number+4
mov ah,[bx]
mov al,[bx+1]
aad
mov bl,04h
div bl
and ah,0ffh
jz yes
lea dx,n
mov ah,09h
int 21h
jmp down
yes:lea dx,ys
mov ah,09h
int 21h
down: mov ah,4ch
int 21h
code1 ends
end start