You are on page 1of 8

Mid Assignment

CSE 331

Microprocessor Interfacing and Embedded System

Section 01

Summer 2020

North South University

Submitted To: Dr. Dihan Md. Nuruddin Hasan (dmh)

Name : Sazid Khandaker

Student ID : 1520347642

Email Address : Sazid.khandaker@NorthSouth.edu

DMH Sec: 1(Microprocessor)


1
Department of Electrical & Computer Engineering (ECE)
North South University
Course Code: 331, Section:1
Course Title: Microprocessor Interfacing & Embedded System
Mid Assessment 1, Summer,2020

Name: SAZID KHANDAKER Marks: 30

Student ID:1520347642

Please read the questions very carefully and answer accordingly. All the answers should be written in
the answer script that has been provided. Calculators/pens/pencils are allowed. You must surrender
any textbook/notebook/cell-phone. Adopting any unfair means during the exam will automatically
result in expulsion without any prior/post notice. You must return back your question paper with your
answer script. Answer any 3 of the 4 sets of the questions given. Clearly indicate the number of the
questions being answered (Example: Answer to the question: 3 (a)(i)

1. Answer all the questions given below. [10]

(a) In the given 8086 block diagram, write down the sizes of the (i) registers (ii) segments
(iii) data bus and (iv) address bus How many instructions can be stored in the queue?
(CO1) [1+1+1+1+1]

DMH Sec: 1(Microprocessor)


2
ANSWER: The size of the register, segments, data bus, address bus are given below,

⦁ Register: 8086 registers are -(a)general purpose registers


(b)special purpose registers

All of them are 16-bits registers. These registers can be used as either 8-bits
registers or 16-bits registers.
⦁ Segments: 8086 has four segments registers actually contain the upper 16-bits.
⦁ Data bus: It has a 16-bits data bus .it can read data from or write data to
memory
⦁ Address bus: It has 20-bits address bus .it can access up to 220 memory locations.

6 instructions bytes can be stored in the queue.

(b) Construct the assembly code for 8086 in order to find the maximum in a given array
using LEA. You may take the given algorithm into account. Use comments where
needed [CO2] [5]

a DB 10h, 5h, 25h, 65h, 02h

DMH Sec: 1(Microprocessor)


3
Answer:
org 100h
lea si,a
mov al,[si] ; move value of array A to AL reg.

mov large_value,al ;assume the first value as largest


inc si ;incrementing the index value
mov cx,5 ;loop will execution 5 times
FOR:
mov al,[si]
cmp large_value,al ;comparing array value
jg next_index ;if LARGEST has greater value no change
mov large_value,al ;if AL has greater value move to LARGEST
next_index:
inc si ; increment SI the index value
loop FOR
ret
a db 10H, 5H, 25H, 65H, 02H
large_value db ?

2. Answer all the questions given below. [10]

(a) -For the given code segment , find the value of ax [CO2] [2.5+2.5]
(i)
mov ax, 5Ah
mov cx, 20h
mul cx
DAA

Answer: After the code execution, the value of the ax is 0B40


ax=0B40

(ii) Show the mathematical operation involved in hexadecimal multiplication

Answer: Given below,


1
5 A 20 = 1 X 16 + 4
X 2 0
0 0
0 B4 X
0 B4 0

DMH Sec: 1(Microprocessor)


4
(b) Construct the code to transfer 50H to the end of the segment. Use comments where
necessary. Use direct addressing mode, i.e., MOV AX, [Address]
[CO1 , CO2] [5]

Answer: The code is given below:

org 100h
mov dl,50h
mov cx,2000h
mov ds,cx
mov bx,0FFFFh
mov [bx],dl
ret

3. Answer all the questions given below. [10]

(a) Consider LIFO and FIFO algorithm as below, [CO2]

DMH Sec: 1(Microprocessor)


5
Using PUSH-POP command and stack segment only, show how the value of AX and BX can be
exchanged [3]

Answer:
MOV Ax,1212h ;store 1212h in AX.
MOV BX,3434H ;store 3434h in BX.
PUSH AX ;store value of AX in the stack
PUSH BX ;store value of BX in the stack
POP AX ;set AX to original value of BX
POP BX ;set AX to original value of AX

The exchange happens because stack uses LIFO (Last In First Out) algorithm, so when we
push 1212h and then 3434h, on pop we will first get 3434h and only after it 1212h.

(b) Write a delay loop which produces a delay of 500 μs on an 8086 with a 5 MHz clock [7]
Hints: MOV-4 cycles ; NOP-3 cycles ; Loop – 17 cycles if return, 5 cycles if exit

Answer:

Delay Loop design:


Time for one clock cycle = 1 / 5MHz = 0.2 μs
Number of clock cycles required = 500 μ sec / 0.2 μ sec = 2500

The following code is used for the delay loop:

DMH Sec: 1(Microprocessor)


6
LOOP:

MOV CX, N ;4 clock cycles


KIIL_TIME:
NOP ; 3 clock cycles
LOOP KILL_TIME ; 17 or 5 clock cycles

NOW, From this loop,


Co = overhead cycles = 4
Cl = number of cycles in loop = 20
CT = total number of cycles wait = 2500
D = difference between LOOP executing or not = 17 – 5 = 12

Formula, N = (CT – Co + D) / Cl

using those value in the formula:


N = (2500 -4 + 12) / 20 = 125.4 = 07DH

4. Answer all the questions below , [CO4] [10]

An array of LEDs as connected below, is needed to be accessed by the 8255a interfacing.

DMH Sec: 1(Microprocessor)


7
(a) Find the value of A0 to A7 in order to address port A and control register
(b) Find the logic circuit in order to keep chip select low while accessing control register and
port A
(c) Construct the code segment in order to keep the LED array blinking on and off in an infinite
loop. Initialize the 8255a as needed. Use 99h as the control word. Provide comments
wherever necessary

DMH Sec: 1(Microprocessor)


8

You might also like