Microprocessor Programming Solution

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 39

IOE – 8085 8086 Microprocessor Old Question Solution

Write an ALP in 8085 to transfer 20 bytes of data in a table to another table by interchanging
D1 and D4 bits of each byte. [2075 Baishakh]

LXI H, 9000H

LXI D, 9020H

MVI C, 14H

LOOP: MOV A, M

ANI 00010010B

CPI 00010010B

JZ NOCHANGE

CPI 00000000B

JZ NOCHANGE

MOV A, M

XRI 00010010B

STAX D

JMP SKIP

NOCHANGE: MOV A, M

STAX D

SKIP: INX H

INX D

DCR C

JNZ LOOP

HLT

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

Write an assembly language program for 8085 to find the square of ten 8-bit numbers which
are less than or equals to 0FH, stored from memory location C090H. Store the result from the
end of the source table. [2073 Magh]
LXI H, C090H

LXI D, C09AH

LOOP: MOV A, M

MOV B,A

MOV C,A

XRA A

MULTIPLY: ADD B ;A<-A+B

DCR C

JNZ MULTIPLY

STAX D

SKIP: INX H

INX D

MOV A, L

CPI 9AH

JNZ LOOP

HLT

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

Write a program in 8085 to sort the 10 data bytes stored in a table in descending order. The
data bytes are stored in a table from memory address 8920H. [2076 Bhadra]

MVI C, 09H

LOOP2: LXI H, 8920H

MVI D, 09H

LOOP1: MOV A, M

INX H

CMP M

JNC OKAY

JZ OKAY

MOV B,M

MOV M, A

DCX H

MOV M, B

INX H

OKAY: DCR D

JNZ LOOP1

DCR C

JNZ LOOP2

HLT

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

Write a program in 8085 to find the largest and smallest bytes from the list of 20 bytes stored
starting from memory location C050H. Store the largest byte and smallest byte in C070H and
C071H respectively. [2076 Baisakh]

LXI H, C050H

MVI C, 13H

MOV D,M ;Max

MOV E,M ;Min

LOOP:INX H

MOV A, D

CMP M ;D-M

JNC SKIP1

MOV D, M

SKIP1: MOV A, E

CMP M ;E-M

JC SKIP2

MOV E, M

SKIP2: DCR C

JNZ LOOP

MOV A, D

STA C070H

MOV A, E

STA C071H

HLT

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

Write a program in 8085 to count the odd and even parity numbers of 150 data stored in the
memory location starting from C050H. Stores the counts at memory locations D000H and
D001H. [2077 Chaitra]

MVI C, 96H ;150

MVI D, 00H ;ODD

MVI E, 00H ;EVEN

LXI H, C050H

LOOP: XRA A

ADD M

JPE EVEN

INR D

JMP EXIT

EVEN: INR E

EXIT: INX H

DCR C

JNZ LOOP

MOV A, D

STA D000H

MOV A, E

STA D001H

HLT

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

There are 40 8-bit numbers in a table with address starting from 9090H. WAP in 8085 to
transfer these numbers to another table with address from A010H if lower nibble of a number
is greater than higher nibble. Otherwise transfer by setting bit D2 and resetting bit D6. [2078
Baishakh]

MVI C, 28H ;40

LXI H, 9090H

LXI D, A010H

LOOP: MOV A, M

ANI 0FH

MOV B, A

MOV A,M

RRC

RRC

RRC

RRC

ANI 0FH

CMP B ;Higher-Lower

JNC SETRESET

MOV A, M

STAX D

JMP EXIT

SETRESET: MOV A, M

ORI 00000100B

ANI 10111111B

STAX D

EXIT: INX H

INX D

DCR C

JNZ LOOP

HLT

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

There are two tables holding 20 data whose starting address is 9000H and 9020H
respectively. WAP to add the content of first table with the content of second table having
same array index. Store sum and carry into the 3rd and 4th table indexing from 9040H and
9060H respectively. [2074 Bhadra]

LXI SP, 9100H

LXI D, 9000H

LXI H, 9020H

LXI B, 9040H

START: LDAX D

ADD M

STAX B

JNC SKIP

PUSH H

LXI H, 9060H

MOV A, L

ADD E

MOV L, A

MVI M, 01H

POP H

SKIP:INX H

INX B

INX D

MOV A, E

CPI 14H

JNZ START

HLT

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

8086
WAP to read a string from the user, convert it to uppercase, count the number of words and
display each word in each line.

.model small

.stack 64

.data
maxchar db 255
actlen db ?
input db 255 dup(?)

.code

newline macro
mov ah, 02h
mov dl, 0ah
int 21h
mov dl, 0dh
int 21h
endm

mov ax, @data


mov ds, ax

main proc far

mov ah, 0ah


lea dx, maxchar
int 21h

lea si, input


mov cl, actlen
mov ch, 0
mov bl, 1
Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)
[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

newline
newline

again: mov dl, [si]

cmp dl, 32
jne skipnewline
newline
inc bl
jmp skip

skipnewline: cmp dl, 91


jb skipupper
sub dl, 32

skipupper: mov ah, 02h


int 21h
skip: inc si
loop again

newline
newline

add bl, 30h


mov dl, bl
mov ah, 02h
int 21h

mov ax, 4c00h


int 21h

main endp
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

Write an ALP in 8086 to read a word and display all the alphabets in alternate case (first
alphabet in lower case, second in upper case, third in lower case and soon ) in a clear
window. [2075 Baisakh]

.model small

.stack 64

.data
maxchar db 255
actlen db ?
input db 255 dup(?)

.code

clr macro
mov ax, 0600h
mov cx, 0000h
mov dx, 1950h
mov bh, 4fh
int 10h
endm

mov ax, @data


mov ds, ax

main proc far

mov ah, 0ah


lea dx, maxchar
int 21h

clr

lea si, input


mov cl, actlen
mov ch, 0
mov ah, 02h

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

mov bl, 0 ;alternate flag

again: mov dl, [si]


cmp dl, 32
je space

cmp bl, 0
je makelower
sub dl, 32
int 21h
mov bl, 0
jmp skip

makelower: mov bl, 1


space: int 21h
skip: inc si
loop again

mov ax, 4c00h


int 21h

main endp
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

Write an assembly program to read a string from the user and display vowels and consonants
separately. [2072 Ashwin]

.model small
.stack 64

.data
maxchar db 255
actlen db ?
input db 255 dup(?)

vowel db 255 dup('$')


cons db 255 dup('$')

.code

newline macro
mov ah, 02h
mov dl, 0ah
int 21h
mov dl, 0dh
int 21h
endm

mov ax, @data


mov ds, ax

main proc far

mov ah, 0ah


lea dx, maxchar
int 21h

lea si, input


lea di, vowel
lea bx, cons

mov cl, actlen


mov ch, 0

newline

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

newline

again: mov dl, [si]

cmp dl, 32
je skip
cmp dl, 'a'
je s_vowel
cmp dl, 'e'
je s_vowel
cmp dl, 'i'
je s_vowel
cmp dl, 'o'
je s_vowel
cmp dl, 'u'
je s_vowel
mov [bx], dl
inc bx
jmp skip

s_vowel: mov [di], dl


inc di

skip: inc si
loop again

newline
newline

mov ah, 09h


lea dx, vowel
int 21h
newline
mov ah, 09h
lea dx, cons
int 21h

mov ax, 4c00h


int 21h
main endp
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

Write a program to read a string and display only the alphabetic characters from the string in
a clear screen. [2071 Magh]

.model small
.stack 64
.data
maxchar db 255
actlen db ?
input db 255 dup('$')

.code
main proc far
mov ax, @data
mov ds, ax

;input string
mov ah, 0ah
lea dx, maxchar
int 21h

lea si, input


mov cl, actlen
mov ch,0

;clear screen
mov ax, 0003h
int 10h

mov ah, 02h ;subfunction number for character print

again: mov dl, [si]


cmp dl, 'A'
jl skip
cmp dl, 'z'
jg skip

cmp dl, 'Z'


jl okay
cmp dl, 'a'
Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)
[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

jl skip

okay: int 21h


skip: inc si
loop again

mov ax, 4c00h


int 21h
main endp
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

Write a program to find the largest and smallest numbers of an array having 10 numbers.
Display the found numbers in the cleared screen. [2073 Bhadra]

.model small
.stack
.data
arr db 12, 15, 10, 18, 24, 08, 19, 20, 11, 14
max db ?
min db ?

.code
main proc far
mov ax, @data
mov ds, ax

lea si, arr


mov cx, 9

mov al, arr[si]

mov max, al
mov min, al
inc si

again: mov al, arr[si]


cmp al, max
jl skip1
mov max, al
skip1:cmp al, min
jg skip
mov min, al
skip: inc si
loop again

mov ah,0
mov al, max
call print_num

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

mov ah,0
mov al, min
call print_num

mov ah, 4ch


int 21h
main endp

print_num proc
mov cx,0
mov dx,0
label1: cmp ax,0
je print1
mov bx,10
div bx ;extract the last digit
push dx ;push it in the stack
inc cx ;increment the count
xor dx,dx ;set dx to 0
jmp label1
print1: cmp cx,0 ;check count
je exit
pop dx ;pop the top of stack
add dx,48 ;for ascii

mov ah,02h
int 21h
dec cx
jmp print1
exit: ret
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE IOE 2078 Baishakh

.model small

.stack 64

.data

.code

mov ax, @data

mov ds, ax

main proc far

mov ah, 01h ;read digit in ascii

int 21h

mov bl, al ;save first digit

mov ah, 01h

int 21h

sub bl, 30h ;ascii to digit

sub al, 30h

mov ah, 00

mov bh, 00

mul bl

call print_num

mov ax, 4c00h

int 21h

main endp

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE IOE 2077 Chaitra

.model small

.stack 64

.data

maxchar db 255

actlen db ?

input db 255 dup('$')

.code

newline macro

mov ah, 02h

mov dl, 0ah

int 21h

mov dl, 0dh

int 21h

endm

main proc far

mov ax, @data

mov ds, ax

;input string

mov ah, 0ah

lea dx, maxchar

int 21h

lea si, input

mov cl, actlen

mov ch,0

again: mov dl, [si]


Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)
[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

;skip if non-alphabetic character

cmp dl, 'A'

jl skip

cmp dl, 'z'

jg skip

cmp dl, 'Z'

jg check_lower

inc bh ;upper counter

check_lower: cmp dl, 'a'

jl skip ;skip if non-alphabetic character i.e between 'Z' and 'a'

inc bl ;lower counter

skip: inc si

loop again

newline

mov ah, 02h

mov dl, bh ;upper count

add dl, 30h

int 21h

newline

mov dl, bl ;lower count

add dl, 30h

int 21h

mov ax, 4c00h

int 21h

main endp

;insert print_num subroutine here

end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE IOE 2076 Baisakh

;Assuming user enters only alphabetical characters.

.model small

.stack 64

.data

maxchar db 255

actlen db ?

input db 255 dup('$')

.code

newline macro

mov ah, 02h

mov dl, 0ah

int 21h

mov dl, 0dh

int 21h

endm

main proc far

mov ax, @data

mov ds, ax

;input string

mov ah, 0ah

lea dx, maxchar

int 21h

lea si, input

mov cl, actlen

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

mov ch,0

mov bl,1 ;first flag

mov ah, 02h ;subfunction number for character print

newline

again: mov dl, [si]

cmp dl, 32

jne skip_first_flag

mov bl,1 ;set first flag

jmp print ;skip space character

skip_first_flag: cmp bl, 1 ;check first character or not?

jne print_lower

mov bl, 0 ;clear first flag

cmp dl, 91

jl print

sub dl, 20h

jmp print

print_lower: cmp dl, 96

jg print

add dl, 20h

print: int 21h

inc si

loop again

mov ax, 4c00h

int 21h

main endp

end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE IOE 2076 Bhadra & 2068 Magh


;Assuming user gives only the number less than 10

.model small
.stack 64
.data
num dw ?
counter dw ?
sum dw ?

.code

;insert newline macro here

mov ax, @data


mov ds, ax
main proc far
mov ah, 01h ;read digit in ascii
int 21h

sub al, 30h ;ascii to digit


mov ah, 0 ;clear higher part of ax
mov num, ax
mov counter, 11 ;counter
mov sum, 0 ;temp sum

;clear screen
mov ax, 0003h
int 10h

again: mov ax, num ;since 'add sum, num' is illigal so we need a register
for add operation.
add sum, ax
newline

mov ax, sum ;number to be printed should be in ax register.


call print_num
dec counter

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

mov cx, counter ;counter should explicitly assigned because subroutine


alters its value.
loop again

mov ax, 4c00h


int 21h

main endp

;insert print_num subroutine here

end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE IOE 2074 Bhadra

.model small

.stack

.data

.code

main proc far

mov ax, @data

mov ds, ax

mov ax, 0

mov bx,02

mov cx, 100

again: add ax, bx

inc bx

inc bx

loop again

call print_num

mov ah, 4ch

int 21h

main endp

;insert print_num subroutine here

End

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

Write a program to find the largest and smallest numbers of an array having 10 numbers.
Display the found numbers in the cleared screen. [2073 Bhadra]

.model small
.stack
.data
arr db 12, 15, 10, 18, 24, 08, 19, 20, 11, 14
max db ?
min db ?

.code
main proc far
mov ax, @data
mov ds, ax
lea si, arr
mov cx, 9
mov al, arr[si]
mov max, al
mov min, al
inc si

;insert clear screen code

again: mov al, arr[si]


cmp al, max
jl skip1
mov max, al
skip1:cmp al, min
jg skip
mov min, al
skip: inc si
loop again

mov ah,0

mov al, max


call print_num

mov ah,0

mov al, min


call print_num

mov ah, 4ch


int 21h
main endp
;insert print_num subroutine here
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE 2070 Magh


.model small
.stack
.data
arr dw 1000, 1111, 2222, 3333, 4444, 55555, 6666, 7777, 8888, 9999
maxval dw ?
minval dw ?

.code
main proc far
mov ax, @data
mov ds, ax

lea si, arr


mov cx, 9
mov ax, arr[si]
mov maxval, ax
mov minval, ax
inc si
inc si
again: mov ax, arr[si]
cmp ax, maxval
jl skip_update_max
mov maxval, ax
skip_update_max:cmp ax, minval
ja skip_update_min
mov minval, ax
skip_update_min: inc si
inc si ;word means 2bytes increment
loop again

;this section is only to verify answer by displaying the values, question


has not asked for display.
mov ax, maxval
call print_num
mov ax, minval
call print_num

mov ax, 4c00h


int 21h
main endp
;insert print_num subroutine here
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE 2070 Bhadra & 2071 Bhadra (Merged solution)

.model small

.stack

.data

maxchar db 255

nchars db ?

actstr db 255 dup (?)

.code

;insert newline macro here

main proc

mov ax, @data

mov ds, ax

mov bl, 01h ;no of words

mov ah, 0ah ;subfunction for input string

mov dx, offset maxchar

int 21h

newline_m

lea si, actstr

mov ch, 00h ;clear upper part of cx

mov cl, nchars ;no of iteration

;clear screen

mov ax, 0003h

int 10h

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

again: mov al, [si] ;mov each characters to al

cmp al, 32 ;check space or not

jne sk_nln ;don't go for newline if not space

newline_m ;print newline if space

inc bl ;increment word counter

sk_nln:cmp al, 91 ;ascii of a character just above 'Z'

jb skip ;skip convert if already uppercase

sub al, 32 ;otherwise subtract 32 to make uppercase

skip: mov dl, al ;mov to dl as an argument for character print DOS

mov ah, 02h ;character print subfunction

int 21h

inc si

loop again

newline_m

mov dl, bl ;word count character

add dl, 30h ;ascii conversion

mov ah, 02h ;character print subfunction

int 21h

end: mov ax, 4C00h

int 21h

main endp

end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE 2072 Magh (Approx Solution, See class note for full solution)

;Here Approx. center is assumed as row = 25/2-2=10


;Full Screen (default )= 80 x 25 characters

.model small
.stack
.data
maxchar db 255
nchars db ?
actstr db 255 dup(?)
row db 10 ;approx center for row.

.code

center macro
inc row
mov ah, 02h
mov bh, 00
mov dh, row
mov dl, 40
int 10h
center endm

main proc
mov ax, @data
mov ds, ax
mov bl, 01h
mov ah, 0ah
mov dx, offset maxchar
int 21h
center
lea si, actstr
mov ch, 00h
mov cl, nchars

again: mov al, [si]


cmp al, 32

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

jne sk_nln ;skip newline if not space


center
jmp skip_print ;skip space character print
sk_nln: mov dl, al
mov ah, 02h
int 21h
skip_print: inc si
loop again

end: mov ah, 4ch


int 21h
main endp
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE 2073 Magh


.model small
.stack
.data
table1 dw 1000h, 1111h, 2222h, 3333h, 4444h, 5555h, 6666h, 7777h, 8888h, 9999h
table2 dw 9999h, 8888h, 7777h, 6666h, 5555h, 4444h, 3333h, 2222h, 1111h, 1000h
table3 dw 10 dup(?)

.code
main proc far
mov ax, @data
mov ds, ax

;assign memory pointers for each table


lea si, table1
lea bx, table2
lea di, table3

;counter
mov cx, 10

again: mov ax, [si]


cmp ax, [bx]
ja store0
mov [di], 1fffh
jmp skip
store0:
mov [di], 0000h
skip: inc si
inc si ;word means 2bytes increment
inc bx
inc bx
inc di
inc di
loop again

mov ax, 4c00h


int 21h
main endp
;insert print_num subroutine here
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE 2069 Bhadra


;Solved assuming user enters only the lowercase albhabetic characters (to
reduce complexity to understand core logic, you can try to handle every
cases.

.model small
.stack 64
.data
maxchar db 255
actlen db ?
input db 255 dup(?)

final_string db 255 dup('$')

.code

;insert newline macro here

mov ax, @data


mov ds, ax

main proc far

mov ah, 0ah


lea dx, maxchar
int 21h

;pointer define
lea si, input
lea di, final_string

mov cl, actlen


mov ch, 0

newline

again: mov dl, [si]

cmp dl, 32 ;check if space

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

je skip_convert_upper ;store without doing anything if space

cmp dl, 'a'


je s_vowel
cmp dl, 'e'
je s_vowel
cmp dl, 'i'
je s_vowel
cmp dl, 'o'
je s_vowel
cmp dl, 'u'
je s_vowel
mov [di], dl ;store consonant here
jmp skip

s_vowel: cmp dl, 91


jb skip_convert_upper ;skip if alredy upper
sub dl, 20h
skip_convert_upper: mov [di], dl ;store converted vowel upper here

skip: inc si
inc di
loop again

mov ah, 09h


lea dx, final_string
int 21h

newline

;count number of uppercase letter (assumed number is less than 9 else you
have to use 'num_print' subroutine)

lea di, final_string ;reassign pointer from starting


mov dl, 0 ;uppercase counter

;reassign counter value


mov cl, actlen
mov ch, 0

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

count: mov al, [di]


cmp al, ' ' ;check if space
je skip_count_upper
cmp al, 96 ;check lowercase?
ja skip_count_upper ;ja=jump if above i.e lowercase
inc dl
skip_count_upper: inc di
loop count

add dl, 30h ;ascii convert to print


mov ah, 02h ;character print subfunction number
int 21h

mov ax, 4c00h


int 21h

main endp
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

TITLE 2069 Bhadra


.model small

.stack 64

.data
vow_c db ?
con_c db ?
num_c db ?
oth_c db ?
maxchar db 255
actlen db ?
input db 255 dup(?)

.code

newline macro
mov ah, 02h
mov dl, 0ah
int 21h
mov dl, 0dh
int 21h
endm

mov ax, @data


mov ds, ax

main proc far

;string read
mov ah, 0ah
lea dx, maxchar
int 21h

;pointer define
lea si, input

;counter define

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

mov cl, actlen


mov ch, 0

newline

mov vow_c, 0 ;vowel counter


mov con_c, 0 ;consonant counter
mov num_c, 0 ;numerals counter
mov oth_c, 0 ;other characters

again: mov dl, [si]

;firstly check alphabetic characters


cmp dl, 'A'
jl other_characters
cmp dl, 'z'
jg other_characters

cmp dl, 'Z'


jl okay
cmp dl, 'a'
jl other_characters

;vowel check
okay: cmp dl, 'a'
je c_vowel
cmp dl, 'e'
je c_vowel
cmp dl, 'i'
je c_vowel
cmp dl, 'o'
je c_vowel
cmp dl, 'u'
je c_vowel
cmp dl, 'A'
je c_vowel
cmp dl, 'E'
je c_vowel
cmp dl, 'I'
Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)
[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

je c_vowel
cmp dl, 'O'
je c_vowel
cmp dl, 'U'
je c_vowel
inc con_c ;increment consonant count if non of the above condition matched
i.e this character must be consonant
jmp skip

c_vowel: inc vow_c ;increment vowel count if any of the condition matched
above and jumped here
jmp skip

;numerals check
other_characters: cmp dl, '0'
jb skip_numeral_count
cmp dl, '9'
ja skip_numeral_count
inc num_c
jmp skip

skip_numeral_count: inc oth_c ;increment other count if the character is


not alphabetic and not numeric

skip: inc si
loop again

;vowel count print


newline
mov dl, vow_c
add dl, 30h ;ascii convert to print
mov ah, 02h ;character print subfunction number
int 21h

;consonant count print


newline
mov dl, con_c
add dl, 30h ;ascii convert to print
mov ah, 02h ;character print subfunction number

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]
IOE – 8085 8086 Microprocessor Old Question Solution

int 21h

;numerals count print


newline
mov dl, num_c
add dl, 30h ;ascii convert to print
mov ah, 02h ;character print subfunction number
int 21h

;other count print


newline
mov dl, oth_c
add dl, 30h ;ascii convert to print
mov ah, 02h ;character print subfunction number
int 21h

mov ax, 4c00h


int 21h

main endp
end

Prepared By: Baikuntha Acharya (Lecturer, DHoD, Sagarmatha Engineering College)


[email protected]

You might also like