Microprocessor Lab Manual SEM IV 2013
Microprocessor Lab Manual SEM IV 2013
Microprocessor Lab Manual SEM IV 2013
Interfacing
Laboratory Manual
CERTIFICATE
This
is
to
certify
that
Mr/Miss
the
subject
140701
Microprocessor
and
interfacing
Date:
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.
5.
6.
7.
8.
9.
Page
No.
Page 3
10.
11.
12.
13.
14.
15.
16.
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
Page 5
MVI A,55
3E,55
Transfer data 55
to accumulator
2002
RST 5
EF
End of program
Page 6
2000
MVI B,44
06,44
2002
MVI C,55
0E,55
2004
MOV A,B
78
2005
ADD C
81
Page 7
2006
MOV D,A
57
2007
RST 5
EF
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
2003
MOV A,M
7E
2004
INX H
23
2005
SUB M
96
2006
INX H
23
2007
MOV M,A
77
2008
RST 5
EF
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
[2] 2100: 54
2101: 53
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Page 8
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
2001
MOV C,A
4F
2002
RST 5
EF
:: 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.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________
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.
Page 11
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.
Page 12
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
MOV B,C
MOV C,A
HLT
; Halt program
Page 13
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:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
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:
_____________________________________________________________________
_____________________________________________________________________
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
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:
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
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
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
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
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Page 24
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
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
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?
Page 27
:: WORKSHEET ::
[1] Write program to arrange an array of data stored in memory location
2100h to 210Fh in descending order
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
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
HL=0
HL = HL + n1
Decrement
Counter C
No
C=0
?
Yes
End
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
HLT
:: WORKSHEET ::
[1] Write program to add series of numbers stored at memory location
2100h to 2105h. Store the result in HL pair
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
____________________________________________________________________
Page 30
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Check your program with following data:
2100: 11h
2101: 12h
2102: 22h
2103: 21h
2104: 33h
2105: 34h
Result: ________
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
2101: 08h
Divisor: 08h
2102: 08h
Result: ____________________________________________________________
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: ____________________________________________________________
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
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
Page 34
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
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
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
2101: _____
2102: _____
2100: FFh
2101: _____
2102: _____
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
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:
2101: _____
2102: _____
2100: e0h
2101: _____
2102: _____
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
Page 38
Explanation:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] Write program to multiply value of accumulator by 16 using rotate
instruction.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
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
CALL CLEAR
CD,47,03
2003
LXI H,2050
21,50,20
2006
XRA A
AF
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
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:
Page 44
Program:
Memory
Address
2000
Label
2002
Mnemonics
MVI B,00h
06,00
LXI H,2100h
21,00,21
2005
START
MVI M,00h
36,00
2007
NEXT
PUSH H
E5
2008
MVI A,01h
3E,01
200A
CALL OUTPUT
CD,D0,05
200D
LXI D,0000h
11,00,00
Delay count
2010
CALL DELAY
CD,BC,03
2013
CALL CLEAR
CD,47,03
2016
POP H
E1
2017
INR M
34
2018
MOV A,M
7E
2019
CPI OAh
FE,0A
201B
JC NEXT
DA,07,20
201E
JMP START
C3,05,20
:: 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 :
TRAP :
RST7.5 :
RST6.5 :
RST5.5 :
SDE
XXX
RST7.5
MSE
M7.5
M6.5
M5.5
=0Bh
Page 47
EI
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
JMP 2050
C3,50,20
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:
+
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
Page 51
D6
0
D5
0
D4
0
D3
0
D2
0
D1
0
D0
0
80H
Connect your LED/seven segment card with 8085 kit connector CN4
Connect power supply with the microprocessor kit & switch on the
unit
Page 52
LABEL
LOOP
Mnemonics
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
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:
D6
D5
D4
D3
D2
D1
D0
01H
0DH
0EH
Procedure:
Page 55
Machine
Code
Remarks
MVI A, 0F H
3E,FF
2002
OUT 03 H
D3,03
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:
:: WORKSHEET ::
[1] Draw waveform and note down on-off time.
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.
Page 58