Interfacing Solved Problems
Interfacing Solved Problems
INTERFACING SOLVED
PROBLEMS
Final part
For all 4th year electrical and computer engineering streams except power stream.
1) Write an assembly programming for 8086 microprocessor to find the sum, largest, and
smallest number from a given arrays.
Arrays: 08h,92h,32h,16h,00h,78h,90h,02h,0ffh,78h,02h
Sum: 0363h
Largest: 0ffh
Smallest: 00h
largest1: mov al,arr1[si]
.model small
.stack cmp al,largest
.data
jb no_change
count db 10
arr1 db mov largest,al
mov ah,09h
.model small
mov dx,offset newlin
.stack
int 21h
.data
mov dx,offset msg2
msg1 db "ENTER THE FIRST NUMBER IN HEX(00-FF): ",'$'
int 21h
msg2 db "ENTER THE SECOND NUMBER IN HEX(00-FF): ",'$'
call accept_input
msg3 db "THE SUM OF TWO HEX NUMBER IS: ",'$'
mov num2,al
newlin db 13, 10, "$"
add al,num1
dig1 db ? ; TO ACCEPT THE FIRST DIGIT FROM USER
mov sum,al
dig2 db ? ; TO ACCEPT THE SECOND DIGIT FROM USER
mov ah,09h
num db ? ; TO STORE THE COMBIND VALUE OF DIGITES
mov dx,offset newlin
num1 db ? ; THE FIRST NUMBER IN HEX
int 21h
num2 db ? ; THE SECOND NUMBER IN HEX
mov ah,09h
sum dB ? ; THE SUM OF THE FIRST AND THE SECOND
NUMBERS mov dx,offset msg3
asc db ? ; use to store the changed num to ascii letter (A-F) int 21h
representation
mov ax,word ptr sum
let db ? ; use to store letter representation to hex num
mov cx,00h
.code
mov bl,10h
main proc
split: div bl
mov ax,@data
mov dx,00h
mov ds,ax
mov dl,ah
mov ah,9h
push dx
mov dx,offset msg1
inc cl
int 21h
mov ah,00h
call accept_input
cmp al,00h
mov num1,al
ja split
print: pop dx mov bl,10h ret
mov al,dig1
3) Write an ALP program to print the below pattern by asking the user number of rows:
i db 0 mov al,i
j db 0 mov bl,2
k db 0 mul bl
call pre_inc
mov y,bl
mov b,al
mov ax,4c00h
int 21h
main endp
pos_inc proc
mov bl,al
inc bl
ret
7) Interface an 8255 with 8086 at 00H as an I/O address of Port A. Interface 7 segment
displays with the 8255. Write an ALP to display 0-9 over the 7 segment displays (cathode
type) continuously as per their positions starting with 0 at the least significant position.
.MODEL SMALL
.STACK
Solution:
To generate 100 KHz square wave at OUT0, No. of count: X×100 KHz = 8 MHz;
≫X=80=50H
Control Word:
To generate 200 KHz continuous pulse at OUT1, No. of count, X ×200 𝐾𝐻𝑧 = 8𝑀𝐻𝑧; ≫ X =
40 = 28𝐻
Control Word:
Address: As address pins A0 and A1 of 8254 are directly connected to A0 and A1 of 8086 and
̅̅̅̅ of 8254 through an inverter. So,
A15 of 8086 is connected to 𝐶𝑆 Subroutine:
OUT CNTR, AL
Address of Control Register = 8003H
MOV AL, 50H
OUT CNT0, AL
OUT CNTR, AL
OUT CNT1, A