Sei sulla pagina 1di 58

Microprocessor and

Interfacing
Laboratory Manual

Enrollment No. _______________


Name of the student:_________________________________

Government Engineering College, Rajkot

GOVERNMENT ENGINEERING COLLEGE, RAJKOT

CERTIFICATE

This

is

to

certify

that

Mr/Miss

____________________________________Enrollment No. _____________


of B.E. (E.C.) SEM-V has satisfactorily completed the term work
of

the

subject

140701

Microprocessor

and

interfacing

prescribed by Gujarat Technological University during the


academic term January-2013 to April-2013.

Date:

Lab Manual of Microprocessor and Interfacing

Signature of the faculty

Page 2

INDEX
Sr.
No.
1.

2.

3.

Name of Experiment
To become familiar with 8085 microprocessor training kit
and execute following programs on microprocessor kit
Add two 8 bit numbers stored in register B & C store
result in register D
Subtract 8 bit data stored at memory location 4021h
from data stored at memory location 4020h. Store
result at memory location 4022h
To perform OR operation between accumulator and
register B. Store result in register C
To become familiar with 8085 microprocessor simulator and
simulate following programs using simulator
Write a program to interchange content of register B
and C
Subtract content of register E from register B.
Complement content of accumulator and display
result on output port PORT2.
Perform logical OR operation between register B and
C, logical AND operation between accumulator and
register B.
Write a program to transfer set of data from memory location
2050-205Fh to 2060-206Fh

4.

Write a program to find smallest number from given set of


data stored at location 2040h to 205Fh

5.

Write a program to find negative numbers in given set of


data stored at the location 2050h to 205Fh
Write program to arrange an array of data in ascending
order
Write a program to multiply two 8 bit numbers stored at the
location 2100 and 2101. Store result at memory location
2102h
Write program to divide 16 bit number stored at memory
location 2100h and 2101h by 8 bit number stored at
memory location 2102h. Store quotient in memory locations
2110h and 2111h, remainder at memory location 2112h
Write a program to separate out (unpack) two digit BCD
number and pack (combine) two digit BCD number into one

6.
7.

8.

9.

Page
No.

E.C. Department, Government Engineering College, Rajkot

Page 3

10.

Write a program to convert hexadecimal number into


equivalent BCD number

11.

Write a program to check parity of data stored at memory


location 2100. Move content EEh to register B, if parity is
even and 00h if parity is Odd.

12.

Write and execute program to display count value 0 to 9 on


the seven segment display using standard subroutine for
display output

13.

Write program to use vector interrupt (VI) RST 7.5 to switch


from up counter to down counter

14.

Write program to flash message EC LAB on address and


data field of display

15.

To interface Programmable peripheral interface (PPI) IC-8255


with 8085 Microprocessor in Mode 0

16.

To generate square wave on port pin PC7 of 8255 in BSR


mode

Instructions to the students:

Solve exercise given at end of each practical, write answers and


execute it

Test your all programs with 8085 microprocessor kit or simulator

Get signature of staff regularly after completion of practical and


exercise regularly

Prepare separate notebook for the assignments given in the classroom


by faculty

Separate interfacing card to interface with the Microprocessor kit


which will be useful in experiment number 15 and 16. At least one
circuit per one batch. Connector detail is given in experiment 15.

Get circuit diagram of interfacing card from faculty

Use simulator GNU8085 or 8085 Simulator IDE which comes in CD


along with Book by Ramesh Gaonkar

Lab Manual of Microprocessor and Interfacing

Page 4

EXPERIMENT NO. 1
AIM: To become familiar with 8085 microprocessor training kit and execute
following programs on microprocessor kit
Add two 8 bit numbers stored in register B & C store result in register
D
Subtract 8 bit data stored at memory location 4021h from data stored
at memory location 4020h. Store result at memory location 4022h
To perform OR operation between accumulator and register B. Store
result in register C
Introduction of 8085 Kit:
8085 Kit allows you to enter hex code of the program and run the
program. You can observe content of registers and memory locations
after and before execution of assembly language program.
8085 Kit has 8Kbyte CMOS RAM chip 6264 and 8Kbyte EPROM.
8085 Kit has various input-output devices such as 8279 (Keyboarddisplay interface), 8255 (Programmable peripheral interface), 8155
(Programmable I/O port and timer), 8253 (Programmable interval
timer)
8085 has following keys to enter, execute and observe result of the
program.
RESET: To reset the system
VI: To provide hardware interrupt
SHIFT: To give second level command (Alternate function)
GO: To execute program
SI: To execute program in single step mode
EXMEM: Examine or modify memory locations
EXREG: Examine or modify CPU registers
PRE: Used with EXMEM to decrement content of PC
(Intermediate terminator)
NEXT: Increment PC value. Used while examining memory
locations and contents of registers
. (DOT): It is terminator to terminate command and write data in
the data field at the location displayed in address field
DEL: Delete part of the program or data
INS: Inserts the part of the program or data with relocation by
one or more bytes
BM: Allows user to move block of memory to any other RAM
area
FILL: Allows user to fill RAM area with a constant

E.C. Department, Government Engineering College, Rajkot

Page 5

REL: Relocates a program written for some memory area and


transfer to other memory area
INSDATA: Inserts one or more data bytes in user program data
area
DELDATA: Deletes one or more data bytes from the user
program/data
MEMC: Compares two blocks of memory
0-F: Hexadecimal keys to enter program and data
8085 kit has six digit seven segment display. First four digits are
called address field and last two digits are called data field.
Memory map for the kit is as follow:
EPROM: 0000 to 1FFF (Used to store in built monitor
program)
RAM: 2000 to 3FFF (Used to enter program code in the kit)
Scratch Pad RAM used by monitor program: 2770 to 27FF
(Students should not use this area to store their program)
Steps for entering and executing assembly language program in the Kit
Let us understand how to enter and execute following program in the kit
Memory
Label
Mnemonics
Hex Codes Comment
Address
2000

MVI A,55

3E,55

Transfer data 55
to accumulator

2002

RST 5

EF

End of program

Steps to enter program in the kit:


Above program transfers data value 55 into accumulator. Use following
steps to enter program in the kit.
Switch ON 8085 Kit. Message SCb 85 will be displayed on the seven
segment display
To enter HEX code of the program press EXMEM key
Dot . will be displayed on the screen. Enter start memory address
for example 2000
Press NEXT key
Enter HEX code. In our program, first hex code is 3E. It will be
displayed on data field.
Press NEXT key
Enter next HEX code i.e. 55
Press NEXT key
Enter next HEX code i.e. EF
Press NEXT key
Lab Manual of Microprocessor and Interfacing

Page 6

Steps to execute the program:


After entering program, now let us understand how to execute this program.
Press RESET key. Message SCb 85 will be displayed on the seven
segment display
Press GO key
Enter start memory address of the program i.e. 2000
Press . Key. Program will execute
Steps to examine result after execution of the program:
After entering and executing program, we wish to examine result of the
program. In our program, we want to examine content of Accumulator. Use
following steps to observe content of accumulator.
Press SHIFT Key
Press EXREG Key, Dot . Will be displayed on seven segment
display.
Press A to examine content of accumulator
Note:
To observe content of other registers like B,C,D,E,H,L,PCL,PCH,SPL, SPH
etc. press NEXT key. Or to observe content of any register press
corresponding key from the keyboard after displaying . with above steps.
To observe data at memory location use following steps:
Press RESET key
Press EXMEM key
Enter address (for example 2010), press NEXT key, data at location
2010 will be displayed on data field.
Assembly language programs:
Program 1: Add two 8 bit numbers stored in register B & C store
result in register D
Memory Label
Mnemonics
Hex Codes Comment
Address

2000

MVI B,44

06,44

Store data 44 in register B

2002

MVI C,55

0E,55

Store data 55 in register C

2004

MOV A,B

78

Transfer content of register B


in A

2005

ADD C

81

Add data stored in register C


in Accumulator

E.C. Department, Government Engineering College, Rajkot

Page 7

2006

MOV D,A

57

Store result in register D

2007

RST 5

EF

Software interrupt (End of


program)

Enter hex codes of the program in the kit. Observe result stored in register
D.
Program 2: Subtract 8 bit data stored at memory location 2100h from data
stored at memory location 2101h. Store result at memory location 2102h
Memory Label
Mnemonics
Hex Codes Comment
Address
2000

LXI H,2100

21,00,21

Set HL register pair as a


memory pointer

2003

MOV A,M

7E

Get data from memory


location 2100

2004

INX H

23

Increment memory location

2005

SUB M

96

Subtract from accumulator

2006

INX H

23

Increment memory location

2007

MOV M,A

77

Store result at 2102

2008

RST 5

EF

Software interrupt (End of


program)

Store some values at memory location 2100 and 2101. Execute above
program and observe result at memory location 2102.
Example data:
[1] 2100: 45

2101: 33

Note down result at 2102: _____

[2] 2100: 54

2101: 53

Note down result at 2102: _______

Write your comment for the second result:

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

Lab Manual of Microprocessor and Interfacing

Page 8

Program 3: To perform OR operation between accumulator and register B.


Store result in register C
Memory
Address

Label

Mnemonics

Hex Codes

Comment

2000

MVI A,55

3E,55

Transfer data 55 to A

2002

MVI B,33

06,33

Transfer data 33 to B

ORA B

B0

Perform logical OR operation


between accumulator and
register B

2001

MOV C,A

4F

Store result in register C

2002

RST 5

EF

SWI (End of program)

Initially store some data in register A (accumulator) and B. Execute above


program and verify result.
Example data:
[1] A: 55
B: 33
C: _______
[2] A: 55
B: 22
C: ________
[3] A: 25
B: 55
C: ________

:: WORKSHEET ::
Write and execute following programs in microprocessor kit
[a] Write a program to add two 8 bit numbers stored at memory locations
2100h and 2101h. Store result at memory location 2102h.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
E.C. Department, Government Engineering College, Rajkot

Page 9

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[b] Write a program to subtract 8 bit data stored in register B from the data
stored in register C. Store result in register D.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________
[c] To perform AND operation between register B and C. Store result in
register D.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________

Lab Manual of Microprocessor and Interfacing

Page 10

EXPERIMENT NO. 2
AIM: To become familiar with 8085 microprocessor simulator and simulate
following programs using simulator
Write a program to interchange content of register B and C
Subtract content of register E from register B. Complement content of
accumulator and display result on output port PORT2.
Perform logical OR operation between register B and C, logical AND
operation between accumulator and register B.
There are so many simulators available to write, assemble and execute
assembly language program. Advantage of using assemblers is that we need
not worry about writing hex codes of the program. Assembler will generate
hex code from the mnemonics written in the program.
We will use two types of simulator for 8085 [1] Linux based GNU8085
simulator and [2] 8085 Simulator IDE which comes in CD along with book
on Microprocessor Architecture, Programming and Applications with the
8085 by Ramesh Gaonkar. We will write, run and simulate assembly
language program.
[1] GNU8085 Simulator:
GNU8085 provides IDE (Integrated Development Environment) to write,
assemble and execute assembly language program. Screen shot of GNU8085
simulator is shown in the following figure.

GNU8085 Microprocessor simulator allows you to write assembly language


program in the editor space. You dont need to write or enter hex codes. Hex
E.C. Department, Government Engineering College, Rajkot

Page 11

codes will be generated automatically when you assemble your program.


You can save your program, get print out of the program.
Steps to use GNU8085 Simulator:

Click on File-->New to open new file and write assembly language


program

Click on Assembler-->assemble (Short cut F8) to assemble your


program

Click on Assembler-->Execute (Short cut F9) to execute your program

You can also execute your program step by step (one by one instruction) by
using Debug-->step in (Short cut key F5) to see execution of instructions
one by one. It is good practice for debugging your program. This assembler
is user friendly.
It allows you to examine content of CPU registers A,B,C,D,E,H,L,PC,SP,
Program status word (PSW) , I/O ports, memory.
It is having keypad to insert mnemonics while writing the program. It is
having decimal to hex and hex to decimal conversion facility.
[2]8085 Simulator IDE(Comes in CD with Book written by Ramesh Gaonkar)
8085 Microprocessor simulator IDE (Integrated Development Environment)
allows to write, assemble and execute assembly language program. Screen
shot of this simulator is given in following figure.

Lab Manual of Microprocessor and Interfacing

Page 12

This simulator allows us to write and execute programs. It also allows to


simulate peripherals, input-output devices. It also allows interrupt
execution. It has memory editor to display hex codes, peripheral devices
window to display status of I/O port.
Steps to use 8085 Simulator IDE

Start 8085 Simulator IDE.


Click on Tools\Assembler.
Click on File\New.
Write program by giving TAB (First column is for LABEL)
After writing program, Save it giving file name let us say test.asm
Click on Tools\Assemble.
Assembler will generate two files: test.lst (assembler listing with assembled
opcodes) and test.obj (binary image of assembled routine ready to be loaded
into memory). The output listing file test.lst will be displayed.
Click on Tools\Load. That will load the program file test.obj into 8085
Simulator IDE memory.
Close assembler window.
Select the option Options\Enable logging.
Click on Tools\Memory Editor. That will open the Memory Editor
Reposition the windows on the screen to get better view, if necessary
Check that Options\HLT Stops Simulation option is selected.
Check that Rate\Fast simulation rate is selected. You can change the
simulation rate even when the simulation is running.
Click on Simulation\Start. The simulation will start immediately.

Execute following programs on the simulator and note down results after
execution of the program:
Program 1: Write a program to interchange content of register B and C
MVI B,75h ;Load initial content 45h in register B
MVI C,89h ;Load initial content 56h in register C
MOV A,B

; Copy value of register B in accumulator

MOV B,C

; Copy content of register C in register B

MOV C,A

; Copy accumulator into register C

HLT

; Halt program

Write result after execution of the program:


B=
C=
A=

E.C. Department, Government Engineering College, Rajkot

Page 13

Program 2: Write and execute program to add two hexadecimal numbers


stored in register B and C. Add numbers, complement result and display it
on LEDs connected at output port PORT0 (Consider PORT0 address 00h)
MVI B,33h
MVI C,22h
MOV A,B
ADD C
OUT 00h
CMA
OUT 00h
HLT
Write result after execution of the program:
B=
C=
A=
PORT0 =
Get Results on LEDs of peripheral windows in Microprocessor 8085 IDE
Program 3: Write and execute program in single step mode for logical OR
operation between register B and C, logical AND operation between
accumulator and register B.
MVI B,91h
MVI C,0A8h
MOV A,B
ORA C
ANA B
HLT
Write result after execution of the program:
B=
C=
After ORA instruction, content of A=
After ANA instruction, content of A=

Lab Manual of Microprocessor and Interfacing

Page 14

:: WORKSHEET ::
[1] Write and simulate program to subtract content of register E from
register B. Complement content of accumulator and display result on
output port PORT2. Assume PORT2 address 02h. Write results after
execution of the program.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Result:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] Write and simulate program to logical EX-OR operation between register
H and L. Store result in register D. Use single stepping mode to execute
program.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Result:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

E.C. Department, Government Engineering College, Rajkot

Page 15

[3] Write program to increment content of register B from value 00h to 10h
and decrement register C from 10h to 00h. Use single stepping mode to
observe content of register B and C after every increment and decrement.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Result:
_____________________________________________________________________
_____________________________________________________________________
[4] Write a program to load value 21h to register H, 00h to register L.
Transfer data 55h to memory location 2100h using instruction MVI M,55h.
Check content of location 2100h. Transfer content of memory location
2100h to port address 00h.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Result:
_____________________________________________________________________
_____________________________________________________________________

Lab Manual of Microprocessor and Interfacing

Page 16

EXPERIMENT NO. 3
AIM: Write a program to transfer set of data from memory location
2050-205Fh to 2060-206Fh
Program:

NEXT:

LXI H,2050h
LXI D,2060h
MVI C,10h
MOV A,M
STAX D
INX H
INX D
DCR C
JNZ NEXT
HLT

;Set HL as memory pointer for source location


;Set DE as a pointer for destination location
;Set register C as counter for sixteen data
;Get data byte from source memory
;Store accumulator at the address pointed by
;DE register pair i.e. destination location
;Increment memory pointer
;Increment destination location
;Decrement counter value
;Next data if counter in not zero

Execute this program on simulator and test.


Execute same program in microprocessor kit and check result.

For microprocessor kit use following hex codes


Memory Label
Mnemonics
Hex Codes
Address
2000
LXI H,2050h
21,50,20
2003

LXI D,2060h

11,60,20

2006

MVI C,10h

0E,10

MOV A,M

7E

2008

STAX D

12

2009

INX H

23

200A

INX D

13

200B

DCR C

0D

200C

JNZ NEXT

C2,07,20

200F

RST 5

EF

2007

NEXT:

E.C. Department, Government Engineering College, Rajkot

Comment
Set HL as memory pointer for
source location
Set DE as a pointer for
destination location
Set register C as counter for
sixteen data
Get data byte from source
memory
Store accumulator at
destination location
Increment memory pointer
Increment destination
location
Decrement counter value
Next data if counter in not
zero (Zero flag not set)
Software interrupt (Halt)

Page 17

:: WORKSHEET ::
[1] Write a program to transfer set of data from memory location
2050-205Fh to 2060-206Fh in reverse order i.e. content at location
2050h should be copied into 206F, 2051h should be copied into 206E
and so on content of 205Fh into 2060h.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Lab Manual of Microprocessor and Interfacing

Page 18

[2] Draw flow chart of the program given in this experiment.

E.C. Department, Government Engineering College, Rajkot

Page 19

EXPERIMENT NO. 4
AIM: Write a program to find smallest number from given set of data stored
at location 2040h to 205Fh. Store smallest number in accumulator
Program:

NEXT:

SKIP:

LXI H,2040h
MVI C,20h
MOV A,M
INX H
CMP M
JC SKIP
MOV A,M
DCR C
JNZ NEXT
HLT

;Set HL register as memory pointer


;Set counter for 32 data
;Transfer first data stored at location 2040h to A
;Increase memory pointer for next data
;Compare with accumulator
;Skip if accumulator is already small
;Transfer small data to accumulator
;Decrement counter value
;Get next data for comparison

Execute this program on GNU8085 simulator and test.


Execute same program in microprocessor kit and check result.
Write HEX codes for above program
Memory Label
Mnemonics
Hex Codes Comment
Address

Lab Manual of Microprocessor and Interfacing

Page 20

:: WORKSHEET ::
[1] Draw flow chart and write a program to find largest number from given
set of data stored at location 2050h to 205Fh. Store largest number at
the memory location 2060h

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
E.C. Department, Government Engineering College, Rajkot

Page 21

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Lab Manual of Microprocessor and Interfacing

Page 22

EXPERIMENT NO. 5
AIM: Write a program to find negative numbers in given set of data stored
at the location 2050h to 205Fh. Store all negative numbers starting
from memory location 2060h
Program:

NEXT:

SKIP:

LXI H,2050h
LXI D,2060h
MVI C,10h
MOV A,M
RAL
JNC SKIP
STAX D
INX D
INX H
DCR C
JNZ NEXT
HLT

;Set HL register as memory pointer


;Set DE register as memory location for destination
;Counter for sixteen data
;Get data from memory to accumulator
;Transfer sign bit into carry flag to check sign bit
;If number is positive skip next instructions
;If number is negative, store it at destination location
; Increment destination memory location
; Increment HL pair for next memory location
; Decrement counter register C
; Repeat process if counter is not ZERO.

Execute this program on GNU8085 simulator and test.


Execute same program in microprocessor kit and check result.
Write HEX codes for above program
Memory Label
Mnemonics
Hex Codes Comment
Address

E.C. Department, Government Engineering College, Rajkot

Page 23

:: WORKSHEET ::
[1] Draw flow chart and write a program to find positive number from given
set of data stored at location 2050h to 206Fh. Store positive numbers at
the memory location starting from 2070h

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

Lab Manual of Microprocessor and Interfacing

Page 24

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

E.C. Department, Government Engineering College, Rajkot

Page 25

EXPERIMENT NO. 6
AIM: Write program to arrange an array of data stored in memory location
2100h to 210Fh in ascending order
Algorithm 1:
1. Initialize memory pointer at location 2100h by HL register pair
2. Initialize register C as a counter for number of data
3. Reset register D to use as a indicator
4. Get first value in accumulator
5. Compare value of accumulator with content of next memory location
6. If A>content of next memory location, exchange contents, set indicator
7. Decrements register C and repeat steps 5 and 6 until register C
becomes zero.
8. If indicator (Register D) is set in step 6, repeat step 1 to 7 else stop
Program (method 1):
START:

NEXT:

SKIP:

LXI H, 2100h
MVI D,00h
MVI C,10h
MOV A,M
INX H
CMP M
JC SKIP
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
MVI D,01h
DCR C
JNZ NEXT
MOV A,D
RRC
JC START
HLT

Check program for following data:


2100: 33 2101: 55 2102: 77 2103: 99 2103: 76 2104: 12 2105: 02
2106: 44 2107: 66 2108: 88 2109: 08 210A: 09 210B: 82 210C: 25
210D: 75 210E: 86 210F: 91
Result:

Lab Manual of Microprocessor and Interfacing

Page 26

Algorithm 2:
1. Initialize memory pointer at location 2100h by HL register pair
2. Initialize register C as a counter for number of data first loop
3. Initialize register D for second loop
4. Get first value in accumulator
5. Compare value of accumulator with content of next memory location
6. If A>content of next memory location, exchange contents,
7. Decrements register D and repeat steps 5 and 6 until register D
becomes zero.
8. Decrement register C (loop2) repeat steps 3 to 7 until C becomes 0
Program (method 2):
MVI C,10h
DCR C
REPEAT: MOV D,C
LXI H,2100h
LOOP:

MOV A,M
INX H
CMP M
JC SKIP
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H

SKIP:

DCR D
JNZ LOOP
DCR C
JNZ REPEAT
HLT

Exercise:
Which method executes fast?

E.C. Department, Government Engineering College, Rajkot

Page 27

:: WORKSHEET ::
[1] Write program to arrange an array of data stored in memory location
2100h to 210Fh in descending order

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

Lab Manual of Microprocessor and Interfacing

Page 28

EXPERIMENT NO. 7
AIM: Write a program to multiply two 8 bit numbers stored at the location
2100h and 2101h. Store result at memory location 2102h
Algorithm:
There is no multiplication instruction available in 8085 instruction set.
Multiplication can be done by repetitive addition.
Steps:
Load first 8 bit number (n1) from memory location 2100h in
accumulator
Copy it in some register (let us say register E)
Load second 8 bit number (n2) from memory location 2101h
Copy second number n2 in register C
We will perform addition of first number n1 which is stored in register
E, n2 times to get multiplication of numbers n1 and n2. Result is
stored in HL register pair. Store HL pair at memory location 2102-03h
Flow chart:
Start

Get first
number n1

Initialize second number


n2 as counter in register C

HL=0

HL = HL + n1

Decrement
Counter C

No

C=0
?
Yes
End

E.C. Department, Government Engineering College, Rajkot

Page 29

Programs:

NEXT:

LDA 2100h
MOV E,A
MVI D,00
LDA 2201h
MOV C,A
LXI H,0000h
DAD D
DCR C
JNZ NEXT
SHLD 2102h

;Load accumulator from 2100h


;Copy accumulator to register E
;Clear register D
; Load accumulator from 2101h
;Initialize counter
;Clear HL to store Result
;Add content of HL and DE
;Decrement counter
;Check whether counter is 0 or not?
;Store result at memory location 2102h
and 2103h

HLT

Write Result of execution for following data:


Data: 2100h30h 210105h
Result: HL: ___________

2102h: _______ 2103h: ________

Data: 2100h55h 21010Ah


Result: HL: ___________

2102h: _______ 2103h: ________

:: WORKSHEET ::
[1] Write program to add series of numbers stored at memory location
2100h to 2105h. Store the result in HL pair

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________

Lab Manual of Microprocessor and Interfacing

Page 30

[2] Write program to add series of numbers stored at memory location


2100h to 2105h. Store the result in HL pair

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Check your program with following data:
2100: 11h

2101: 12h

2102: 22h

2103: 21h

2104: 33h

2105: 34h

Result: ________

E.C. Department, Government Engineering College, Rajkot

Page 31

EXPERIMENT NO. 8
AIM:
Write program to divide 16 bit number stored at memory location 2100h and
2101h by 8 bit number stored at memory location 2102h. Store quotient in
memory locations 2110h and 2111h, remainder at memory location 2112h
Program:

NEXT:

LHLD 2100h
LDA 2102h
MOV C,A
LXI D,0000h
MOV A,L
SUB C
MOV L,A
JNC SKIP
DCR H

SKIP:

INX D
MOV A,H
CPI 00h
JNZ NEXT
MOV A,L
CMP C
JNC NEXT
SHLD 2112h
XCHG
SHLD 2110h
HLT

;Get 16 bit number in HL pair


;Get 8 bit divisor in accumulator
;Set counter equal to divisor number
;Clear DE pair to store quotient
;Get lower byte of 16 bit number in A
;Subtract 8 bit number
;Store result of subtraction in L
; SKIP next instruction of carry does not
; occur
;Decrement higher byte if borrow occurs in
; subtraction operation
; Get total number of subtraction in register
; pair DE
; Copy content of H in accumulator
; Compare value of A (hence H) with 0
; Perform subtraction again if
dividend >divisor

;Store remainder at 2112h and 2113h


; Exchange HL pair with DE pair
; Store result at 2110h and 2111h

Check your program with following data:


16 bit number: 0108h
2100: 01h

2101: 08h

Divisor: 08h
2102: 08h

Result: ____________________________________________________________

Lab Manual of Microprocessor and Interfacing

Page 32

:: WORKSHEET ::
[1] Write program to divide one 8 bit number stored at memory location
2100h by other 8 bit number stored at memory location 2101h. Store
quotient at memory location 2102h and remainder at memory location
2103h

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
___________________________________________________________________
Check your program with following data:
16 bit number: 0108h
2100: 01h

2101: 08h

Divisor: 08h
2102: 08h

Result: ____________________________________________________________

E.C. Department, Government Engineering College, Rajkot

Page 33

EXPERIMENT NO. 9
AIM: Write a program to separate out (unpack) two digit BCD number
stored at memory location 2100h. Store tow digits at memory locations
2101h and 2102h.
Program:
LXI H,2100h
MOV A,M
MOV B,A
ANI 0Fh
INX H
MOV M,A
MOV A,B
ANI F0h
RRC
RRC
RRC
RRC
INX H
MOV M,A
HLT

;Memory pointer for location 2100h


; Get two digit BCD number in A
;Copy number in register B
;Mask upper four bits (higher nibble)
;Increment memory pointer
;Store digit at memory location 2101h
;Get original two digit BCD number in A
;Mask lower nibble
;Rotate four times to get LSB from MSB

;Increment memory pointer


;Store second digit at 2102h

Check with following data:


2100: 85h

2101: _____

2102: _____

Write a program to combine (pack) two BCD digits and form one two digit
BCD number. Consider that two BCD digits are stored at location 2110h
and 2111h. Store packed BCD number at location 2112h.
Program:
LDA 2110h ;Get first digit
ANI FOh
; Mask lower nibble
RLC
; Rotate left four times to make it MSB
RLC
RLC
RLC
MOV C,A
; Copy in register C
LDA 2111h ; Get second digit
ADD C
; Combine both digits
STA 2112h ; Store result at location 2112h
HLT

Lab Manual of Microprocessor and Interfacing

Page 34

Check with following data:


2110: 06h

2111: 07h

2112: _____

:: WORKSHEET ::
[1] Write a program to find 1s complement of 16 bit number stored at
memory locations 2100h and 2101h. Store result at 2110h and 2111h

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] Write a program to find 2s complement of 16 bit number stored at
memory locations 2100h and 2101h. Store result at 2110h and 2111h

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

E.C. Department, Government Engineering College, Rajkot

Page 35

EXPERIMENT NO. 10
AIM: Write a program to convert hexadecimal number into equivalent BCD
number
Algorithm 1:
Set HL pair as a memory pointer
Clear register D and accumulator to get BCD number
Get hexadecimal data in register C
Increment content of accumulator and adjust for decimal in a loop
until register C becomes zero
If accumulator exceeds 99, increment register D by one
Store accumulator and register D at memory location 2101h and
2102h
Program 1:

LOOP2:

LOOP1:

LXI H,2100h
MVI D,00H
XRA A
MOV C,M
ADI 01
DAA
JNC LOOP1
INR D
DCR C
JNZ LOOP2
STA 2101h
MOV A,D
STA 2102h
HLT

Check with following data:


2100: 55h

2101: _____

2102: _____

2100: FFh

2101: _____

2102: _____

Lab Manual of Microprocessor and Interfacing

Page 36

Algorithm 2:
Prepare subroutine BINBCD and BCD
Set HL pair as a memory pointer
Call BINBCD function
Algorithm for BINBCD subroutine:
Subtract 100 from Hex number until carry occurs
Count number of times 100 subtracted in some register and store
it
Subtract 10 from remainder until carry occurs
Count number of times 10 is subtracted in some register and store
it
Call function BCD subroutine within BINBCD subroutine for
subtraction operation by 10 and 100.
Program 2:
LXI H,2100h
MOV A,M
INX H
CALL BINBCD
HLT

;transfer hex data from memory to A


;Increment memory pointer to save result

BINBCD:
MVI B,64h ;load 100 into register B
CALL BCD ;call conversion for BCD3
MVI B,0Ah ;load 10 into register B
CALL BCD ;call conversion for BCD2
MOV M,A ;store BCD1
RET
BCD:
STORE:

MVI M,0FFH ;load buffer with -1


INR M ;clear buffer first and increment for each subtraction
SUB B ;subtract power of ten from binary number
JNC STORE ;if number is larger than power of ten, go back and
; add 1 to buffer
ADD B ;if no, add power of ten to get back remainder
INX H ;go to next buffer location
RET

Check with following data:


2100: 64h

2101: _____

2102: _____

2100: e0h

2101: _____

2102: _____

E.C. Department, Government Engineering College, Rajkot

Page 37

:: WORKSHEET ::
[1] Write program to convert ASCII code stored in register B to hex number
and store result in register C

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] Explain and execute following program:

MVI B,55h
MOV A,B
ANI 0Fh
CALL ASCII
STA 2100h
MOV A,B
ANI 0F0h
RLC
RLC
RLC
RLC
CALL ASCII
STA 2101h
HLT
ASCII:

SKIP:

CPI 0Ah
JC SKIP
ADI 07h
ADI 30h
RET

Lab Manual of Microprocessor and Interfacing

Page 38

Explanation:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] Write program to multiply value of accumulator by 16 using rotate
instruction.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

E.C. Department, Government Engineering College, Rajkot

Page 39

EXPERIMENT NO. 11
AIM: Write a program to check parity of data stored at memory location
2100. Move content EEh to register B, if parity is even and 00h if
parity is Odd.
Program:
LXI H,2100h
MOV A,M
ORA A
JPO ODD
MVI B,EEh
JMP STOP
ODD:
MVI B,00h
STOP:
HLT

:: WORKSHEET ::
[1] Write explanation of above program:

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] Write a program to calculate number of 1s in given data stored in
register D. Calculate number of 1s and store count value in register C

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Lab Manual of Microprocessor and Interfacing

Page 40

EXPERIMENT NO. 12
AIM: Write program to flash message EC LAB on address and data field of
display
In this practical, we will use standard subroutines for various functions.
These standard subroutines are stored in EPROM of the kit. Addresses of
subroutines are fixed. We will call these routine in our program. Details of
standard subroutine used in this program are given below:
[1] CALL OUTPUT (To call output subroutine)
This routine (OUTPUT) is stored at memory location 05D0
This routine display characters on data and address field
If A=0, it display characters on address field
A=1, it display characters on data field
This routine displays characters which are stored at memory location
defined by HL pair. Memory location of characters should be
transferred to HL pair before calling this routine.
Before calling this routine, if B=0: Dot will not display and if B=1, dot
will display.
[2] CALL CLEAR (To call clear subroutine)
This routine is stored at memory location 0347
This routine clears seven segment display in data and address field
[3] CALL DELAY (To call delay subroutine)
This routine is stored at memory location 03BC
This routine provides delay depending on value stored in DE register
Value stored in the DE register pair is decremented until it becomes
zero. Once it becomes zero, RET is executed
Total delay provided by the routine is (24N+17)*T
Crystal frequency used in the kit is 6.14 MHZ, it is internally divided
by two, so clock frequency is 3.07 MHZ. T=0.33S
If we load 0000h in DE pair, we will get highest delay, N=65536
Delay =(24*65536+17)*0.33 S 0.5 Second
Program:
Memory Label
Address
2000
Start:

Mnemonics

Hex Codes Comment

CALL CLEAR

CD,47,03

2003

LXI H,2050

21,50,20

2006

XRA A

AF

E.C. Department, Government Engineering College, Rajkot

Call standard subroutine to


clear the display
Load memory pointer, from
where data will be displayed
Ex-OR accumulator with
itself to clear it
Page 41

2007

CALL OUTPUT

CD,D0,05

200A

MVI A,01

3E,01

200C

LXI H,2054

21,54,20

200F

CALL OUTPUT

CD,D0,05

2012

LXI D,0000

11,00,00

2015

CALL DELAY

CD,BC,03

2018

CALL CLEAR

CD,47,03

201B

LXI D,0000

11,00,00

201E

CALL DELAY

CD,BC,03

2021

JMP Start

C3,00,20

Call standard subroutine to


display in address field
A=01, output subroutine
display in data field
Memory pointer for data to
display it in data field
Call standard subroutine to
display in address field
Counter for 0.5 second delay
Call standard delay
subroutine
Call standard subroutine to
clear the display
Counter for 0.5 second delay
Call standard delay
subroutine for 0.5 sec. blank
Display message again
(Flashing of message)

Store following data from memory location 2050h and execute the
program
2050h: 0Eh 2051h: 0Ch 2052h: 16 (code for Blank)
2053h: 11h 2054h: 0Ah 2055h: 0Bh

:: WORKSHEET ::
[1] Instead of calling standard DELAY routine, write your own delay routine
using register pair DE and write above program again. Execute program
to display HELLO on the display. (Hint: Code for H: 10 E:0E L:11 0:00)

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________
Lab Manual of Microprocessor and Interfacing

Page 42

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_________________________________________________________________
E.C. Department, Government Engineering College, Rajkot

Page 43

EXPERIMENT NO. 13
AIM: Write and execute program to display count value 0 to 9 on the seven
segment display using standard subroutine for display output
Algorithm:
1. Load initial count value 0 in accumulator
2. Display count value at output
3. Increment count value
4. Call delay routine
5. Compare count value with 0A, if it is less than 0Ak repeat steps 2 to 4
else repeat steps 1 to 4.
Program:
START:
NEXT:

MVI A,00h ; Load count value in accumulator


OUT 00h
; Considering output address 00h
CALL DELAY ; Call delay between two counts
INR A
; Increment count value
CPI 0Ah
;Compare with 0Ah
JC NEXT
;Display incremented count value
JMP START : Continue
We will use standard subroutine for display count value and delay in our
program, so Execute following program in the kit:
Algorithm:
1. Use standard subroutine OUTPUT to display count value on data field
2. Clear register B for no dot to be displayed
3. Load initial count value in memory
4. Display count value
5. Move 01h to accumulator to display count value in data field
6. Call output subroutine
7. Call delay subroutine
8. Clear display using clear display subroutine
9. Increment count value
10.

Compare count value with 9. If it is less than or equal to 9, repeat


steps 4 to 9 else repeat steps 3 to 9.

Lab Manual of Microprocessor and Interfacing

Page 44

Program:
Memory
Address
2000

Label

2002

Mnemonics

Hex Codes Comment

MVI B,00h

06,00

Do not display dot

LXI H,2100h

21,00,21

HL as Memory pointer for


count value
Count value=0

2005

START

MVI M,00h

36,00

2007

NEXT

PUSH H

E5

2008

MVI A,01h

3E,01

Store HL pair (Memory


pointer) in stack
Use data field

200A

CALL OUTPUT

CD,D0,05

Call output subroutine

200D

LXI D,0000h

11,00,00

Delay count

2010

CALL DELAY

CD,BC,03

Call Delay subroutine

2013

CALL CLEAR

CD,47,03

Clear the display

2016

POP H

E1

2017

INR M

34

Get back memory pointer


from stack
Increment count value

2018

MOV A,M

7E

2019

CPI OAh

FE,0A

Get count value in


accumulator for comparison
Compare with 0Ah

201B

JC NEXT

DA,07,20

Display next count if A<0Ah

201E

JMP START

C3,05,20

Start again from count 0

:: WORKSHEET ::
[1] Modify program for down counter (count value from 9 to 0). (Hint: Load
initial count value 09h in memory, Use DCR M instead of INR M, use JNZ
instead of JC). Write program again and execute in the kit.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
E.C. Department, Government Engineering College, Rajkot

Page 45

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Lab Manual of Microprocessor and Interfacing

Page 46

EXPERIMENT NO. 14
Aim: Write program to use vector interrupt (VI) RST 7.5 to switch from
up-counter to down counter
Introduction:
When interrupt occurs, microprocessor completes current instruction, save
current program counter value in stack, and executes program stored at
interrupt vector location.
8085 has five interrupts:
INTR :

Receives address of subroutine from external device

TRAP :

Vector location: 0024h

RST7.5 :

Vector location: 003Ch

RST6.5 :

Vector location: 0034h

RST5.5 :

Vector location: 002Ch

We will use RST7.5 interrupt in our program. In microprocessor kit, key VI


generates RST7.5 interrupt.
We will use instruction SIM to enable the interrupt
SIM is multipurpose instruction used for serial communication and
interrupts. Bit D7 is serial output data, SDE is serial data enable,
RST7.5: If this bit is 1, RST7.5 flip-flop is reset
MSE: Mask set enable. If this bit is set, it enables use of M5.5 to M7.5
It is master control for bits M7.5, M6.5 and M5.5
M7.5: If this bit=0, RST7.5 enabled and if it is 1 (set) RST7.5 disabled
M6.5: If this bit=0, RST6.5 enabled and if it is 1 (set) RST6.5 disabled
M5.5: If this bit=0, RST5.5 enabled and if it is 1 (set) RST5.5 disabled
We want to use RST 7.5, so bit configurations will be as under:
SOD

SDE

XXX

RST7.5

MSE

M7.5

M6.5

M5.5

E.C. Department, Government Engineering College, Rajkot

=0Bh

Page 47

To add use of VI (vector interrupt) in counter program add following


instructions in program of experiment 13.
MVI A, 0Bh
SIM

;Code to enable RST7.5 interrupt


;Set interrupt mask

EI

;Set Enable interrupts flip-flop

Once you add these instructions at the beginning of program, program will
recognize press of VI key. When you press VI key program will jump to
vector location 002Ch. In microprocessor kit, it is EPROM location where
you can not write any instruction but there is already jump instruction
written at this location which takes jump to another memory location
27BDh. You can take further jump from that location.
If you write down counter program from the location 2050h. You can simply
write following instruction at location 27BDh to take a jump for down
counter program.
27BD

JMP 2050

C3,50,20

:: WORKSHEET ::
[1] Write up-counter and down-counter programs of experiment no. 13 at
memory location 2004h and 2050h respectively. Add following three
instructions from memory location 2000h.
2000 MVI A, 0Bh

3E, 0B

2002 SIM

30

2003 EI

FB

;Code to enable RST7.5 interrupt


;Set interrupt mask
;Set Enable interrupts flip-flop

2004 to 2025 Up counter program


2050 . Down counter program
27BD

JMP 2050

C3,50,20

Execute program, up-counting will start, press VI to start down-counting.


Note: Most of the code is same for up-counter and down-counter, you can
use block move facility to copy entire code of up-counter to down-counter
locations and do minor modifications.
For block move, use BM key on microprocessor kit. Press BM, enter source
start location, next, source end location, next, destination start location,..
Lab Manual of Microprocessor and Interfacing

Page 48

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
E.C. Department, Government Engineering College, Rajkot

Page 49

EXPERIMENT NO. 15
AIM: To interface Programmable peripheral interface (PPI) IC-8255 with
8085 Microprocessor in Mode 0
Objectives:

Interface IC-8255 with microprocessor 8085 in mode 0

Interface LEDs to the ports of IC-8255

Display data on LED and read input from the switches


Introduction:
The programmable peripheral interface (PPI) IC-8255 is widely used parallel
input output device. It can be programmed to transfer data under various
conditions. It has three 8 bit ports named as Port A, Port B & Port C. Pin
diagram of IC-8255 is as shown in the Fig. 1 and block diagram is as shown
in the Fig. 2

+
Fig. 1 Pin diagram of 8255A
Pins available on connector CN4 of 8085 Kit:
PC5 PC3 PC1 PB7 PB5 PB3 PB1 PA7 PA5
2
4
6
8
10
12
14
16
18
1
3
5
7
9
11
13
15
17
PC4 PC2 PC0 PB6 PB4 PB2 PB0 PA6 PA4
Lab Manual of Microprocessor and Interfacing

PA3
20
19
PA2

PA1 PC7 Vcc


22
24
26
21
23
25
PA0 PC6 GND
Page 50

Fig. 2 Block diagram of 8255A


In this experiment, we will understand mode 0 that is simple input output
mode Control word format is shown in the Fig. 3
In simple I/O mode,

Outputs are latched

Inputs are not latched

Ports do not have handshaking or interrupt facility

Port A,B & C can be used as an input or output port


Depending upon required operation, control word is decided from the
specified format & written into control register. Port A, Port B, Port C &
control register (CR) can be selected with chip select signal and Address
lines A0, A1.

E.C. Department, Government Engineering College, Rajkot

Page 51

Fig. 3 Control word format


Control word for Mode 0, Port A, B & C output port:
D7
1

D6
0

D5
0

D4
0

D3
0

D2
0

D1
0

D0
0

80H

Addresses of 8255 for Microprocessor Kit:


PORT A: 00h
PORT B: 01h
PORT C: 02h
Control Word: 03h
Procedure:

Connect your LED/seven segment card with 8085 kit connector CN4

Connect power supply with the microprocessor kit & switch on the
unit

Enter software code and execute program

Observe Flashing of LEDs

If you have not prepared card, measure voltage carefully

Change the delay and execute program again

Lab Manual of Microprocessor and Interfacing

Page 52

Program to flash LEDs connected at Port A alternately:


Memory
Address
2000
2002
2004
2006
2008
200B
200E
2010
2012
2015
2018

LABEL

LOOP

Mnemonics

Machine Code Remarks

MVI A, 80H
OUT 03H
MVI A, 55H
OUT 00H
LXI D,0000h
CALL DELAY
MVI A, AAH
OUT 00H
LXI D,0000h
CALL DELAY
JMP LOOP

3E,80
D3,03
3E,55
D3,00
11,00,00
CD,BC,03
3E,AA
D3,00
11,00,00
CD,BC,03
C3,04,20

Send control word 80h


to control register
Send data 55h to Port
A.
Call standard delay
routine for 0.5 second
Send data AAh to Port
A
Call delay 0.5 second

Program to read data from port C and display it on Port B:


Control word for Mode 0, Port C input & Port B output:
D7
1

D6
0

Memory
Address
C000
C002
C004
C00E
C010

D5
0

D4
X

Mnemonics
MVI A, 80H
OUT 03H
IN 02H
OUT 01H
HLT

D3
1

D2
0

D1
0

Machine
Code
3E,89
D3,03
DB,02
D3,01
76

D0
1

89H

Remarks
Send control word 80h to
control register
Read data from port C and
Display it on port B.
End of the Program

:: WORKSHEET ::
[1] Find out control word for following configuration
Port A as output port
Port B & C as in input port

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
E.C. Department, Government Engineering College, Rajkot

Page 53

_____________________________________________________________________
[2] Write assembly language program to read status of the switches
connected to port A and display status on Port B.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] Write assembly language program to flash 8 LEDs connected to port A on
& off continuously at the interval of 0.5 second.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[4] Why Ic-8255 is known as programmable device?

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Lab Manual of Microprocessor and Interfacing

Page 54

EXPERIMENT NO. 16
AIM: To generate square wave on port pin PC7 of 8255 in BSR mode
The bit set reset (BSR) mode is used to set or reset eight bit of port C.
Individual bits of port C can be made 1 (set) or 0 (reset) to control devices
connected with port pins. The control word bit D7 is 0 for BSR mode. It does
not affect any previously transmitted control word of I/O mode (i.e. mode
with bit D7=1)
Control word for Bit Set Reset (BSR) mode:

Some examples of control words:


D7

D6

D5

D4

D3

D2

D1

D0

To set bit PC0

01H

To set bit PC6

0DH

To reset bit PC7

0EH

Procedure:

Connect Logic Interface Card with 8085 Kit


Connect power supply with the microprocessor kit & switch on the
unit
Enter software code and execute program
Connect CRO between port pin PC7 & ground terminal
Observe waveform on the C.R.O.
Measure ON-OFF time of the square wave.
Calculate theoretical delay and compare it with practical measured
value.
Draw your own conclusion.

E.C. Department, Government Engineering College, Rajkot

Page 55

Memory LABEL Mnemonics

Machine
Code

Remarks

MVI A, 0F H

3E,FF

2002

OUT 03 H

D3,03

Send control word


to Set bit PC7

2003

NOP

00

2004

NOP

00

2005

NOP

00

2006

NOP

00

2007

NOP

00

2008

MVI A, 0EH

3E,0E

200A

OUT 03 H

D3,03

200C

NOP

00

200D

NOP

00

200E

NOP

00

200F

NOP

00

2010

NOP

00

2011

JMP start

C3,00,20

Address
2000

Start:

Send control word


to Reset bit PC7

:: WORKSHEET ::
[1] Draw waveform and note down on-off time.

Lab Manual of Microprocessor and Interfacing

Page 56

[2] Calculate theoretical on-off time & compare it with practical value

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] Modify program to generate square wave on pin PC4 & PC2.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
E.C. Department, Government Engineering College, Rajkot

Page 57

[4] Draw an interfacing circuit so that 100 W Lamp can made ON & OFF
using port pin PC7. Write program to make Lamp ON and OFF
continuously at the interval of 1 second

[5] Draw an interfacing circuit to control electrical appliance (AC load) using
port pin PC0. Interfacing circuit should provide optical isolation.

Lab Manual of Microprocessor and Interfacing

Page 58

Potrebbero piacerti anche