Sie sind auf Seite 1von 21

SUBJECT: TITLE:

Introduction to basic concepts of programming and 1


Microprocessor &
Programming model of 8085.
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 01 DATE :
REV. NO.: 2.00/JAN-2012

(1) Define microprocessor. With a neat sketch explain microprocessor based


system.
(2) Define following
a) Wordlength
b) Machine language Program
c) Mnemonics
d) Assembly language program
(3) State clearly the difference between low-level programming language and high-
level programming language.
(4) Discuss merits and demerits of assembly language programming and high-level
language programming.
(5) What is the role of assembler and complier in programming?
(6) With a neat sketch discuss programming model of 8085.

GRADE LAB-INCHARGE H.O.D

Darshan Institute of Engineering And Technology , Rajkot


SUBJECT: TITLE:
1
Microprocessor & Study Data Transfer Instruction of 8085.
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 02 DATE :
REV. NO.: 2.00/JAN-2012

AIM: - To study Data Transfer instructions of 8085.

THEORY: -
Data transfer instructions performs the primary function of copying data, from a register or
I/O or memory, which is called the source, to another register or I/O or memory, which is
called the destination.

Data transfer (copy) instructions can be used to copy data


 From register to register.
 Load an 8 bit number in a register.
 Between memory and register.
 Between I/O and accumulator.
 Load 16 bit number in a register pair.

DATA TRANSFER INSTRUCTION SET:-

The following notations are used in the description of the instructions.


R = 8-bit register (A, B, C, D, E, H, L)
M = memory register (location)
Rs = register source (A, B, C, D, E, H, L)
Rd = register destination (A, B, C, D, E, H, L)
Rp = register pair (BC, DE, HL)
OF = Opcode Fetch machine cycle (4 T-States)
MR= Memory Read machine cycle (3 T-States)
MW=Memory Write machine cycle (3 T-States)
I/O R = I/O Read machine cycle (3 T-states)
I/O W = I/O Write machine cycle (3 T-states)

Sr. Instruction No. of Description Addressing Machine


No. Opcode Operand Bytes Mode Cycles
1 MOV Rd,Rs 1 Copy data from RS to RD. Register OF
2 MOV M,R 1 Copy the data byte from register Indirect OF,MW
R into memory location whose
address is stored in HL register
pair.

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
2
Microprocessor & Study Data Transfer Instruction of 8085.
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 02 DATE :
REV. NO.: 2.00/JAN-2012

3 MOV R,M 1 Copy the data byte from a Indirect OF,MR


memory location whose address
is stored in HL register pair into
a register R.
4 MVI R, 8-bit 2 Load 8-bit data into a register R. Immediate OF, MR
5 MVI M, 8-bit 2 Load 8-bit data into memory Immediate OF, MR,
location whose address is stored MW
in HL register pair.
6 LXI Rp, 16-bit 3 Load 16 bit of data in register Immediate OF, MR,
pair RP MR
7 LDA 16-bit 3 Copy the data byte into the Direct OF, MR,
address accumulator from the memory MR, MR
location indicated by 16-bit
address.
8 STA 16-bit address 3 Copy the data byte of the Direct OF, MR,
accumulator into the memory MR,
location indicated by 16-bit MW
address.
9 LDAX Rp 1 Copy the data byte into the Register OF, MR
accumulator from the memory Indirect
location indicated by a register
pair Rp. (Rp = BC or DE)
10 STAX Rp 1 Copy the data byte from the Register OF, MW
accumulator into the memory indirect
location indicated by a register
pair Rp. (Rp = BC or DE)
11 LHLD 16-bit add. 3 Copy the contents of memory Direct OF, MR,
location indicated by 16-bit MR, MR,
address in register L & copy the MR
contents of next memory
location in register H.
12 SHLD 16-bit add. 3 Store the contents of register L Direct OF, MR,
in memory location indicated by MR,
16-bit address & the contents of MW,
H register are stored in next MW
consecutive memory location.

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
3
Microprocessor & Study Data Transfer Instruction of 8085.
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 02 DATE :
REV. NO.: 2.00/JAN-2012

13 PCHL 1 Store the contents of registers Register OF


pair HL into the program
counter.
14 SPHL 1 Loads the contents of register Register OF
pair HL into the stack pointer.

15 XCHG 1 The contents of register H are Register OF


exchanged with the contents of
register D, & the contents of
register L are exchanged with
the contents of register E.
16 XTHL 1 The contents of L register are Register OF, MR,
exchanged with the stack indirect MR,
location pointed out by stack MW,
pointer. The contents of the H MW
register are exchanged with the
next stack location (SP+1).
17 IN 8 bit add. 2 Accept data byte from an i/p -- OF, MR,
device & place it in the I/O R
accumulator.
18 OUT 8 bit add. 2 Send data byte from the -- OF, MR,
accumulator to an o/p device. I/O W

Note: No flags are affected in data transfer instructions.

Example Program: Write an assembly language program (ALP) to load register B with data
38H & transfer the contents of register B to the contents of register C and to memory
location F000H.

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
4
Microprocessor & Study Data Transfer Instruction of 8085.
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 02 DATE :
REV. NO.: 2.00/JAN-2012

Memory Mnemonics M/C code No.of Comments


Address bytes
E000H MVI B,38H 06 2 Load register B with data 38H.
E001H 38
E002H MOV C,B 48 1 Copy the data from B to C.
E003H MOV A,B 78 1 Copy the data from B to A.
E004H STA F000H 32 3 Copy the data from A to memory
E005H 00 location F000H.
E006H F0
E007H HLT 76 1 End of program.

Program Documentation:
Contents before execution:
B = XX C = XX F000H = XX
Contents after execution:
B = 38H C = 38H F000H = 38H
Example Program 2: Write an assembly language program to store the data 32H into
memory location 2025H.

Memory Mnemonics M/C code No. of Comments


Address bytes
E000H LXI H,2025H 21 3 Load HL with 2025H
E001H 25
E002H 20
E003H MVI M,32H 36 2 Store 32H in memory location
E004H 32 pointed by HL register pair.
E005H HLT 76 1 Stop

Program Documentation:
Contents before execution:
2025H = XX
Contents after execution:
2025H=32H

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
5
Microprocessor & Study Data Transfer Instruction of 8085.
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 02 DATE :
REV. NO.: 2.00/JAN-2012

Example Program 3: Write an assembly language program to interchange the data content
stored at memory location 4000H and 4001H.

Let the content of 4000H location is 10H and 4001H memory location is 20H

Memory Mnemonics M/C code No. of Comments


Address bytes
2000H LDA 4000H 3A 3 Load data from m/m location
2001H 20 4000H to accumulator
2002H 00
2003H MOV B,A 47 1 Store data in B register
2004H LDA 4001H 3A 3 Load data from m/m location
2005H 20 4001H to accumulator
2006H 01
2007H STA 4000H 32 3 Load data to memory location
2008H 20 4000H from accumulator.
2009H 00
200AH MOV A,B 78 1
200BH STA 4001H 32 3 Reload data in A from B register
200CH 20 Load data to m/m location 4001H
200DH 01
200EH HLT 76 1 Stop

EXERCISE

1) Write single equivalent instruction for the following programs.


a) MVI D, F0H b) MOV A, L
MVI E, 00H STA F000H
XCHG MOV A, H
MOV M, A STA F001H

2) Write an assembly language program to interchange the 16-bit data stored in


register BC and register DE (with and without XCHG instruction).

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
6
Microprocessor & Study Data Transfer Instruction of 8085.
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 02 DATE :
REV. NO.: 2.00/JAN-2012

3) A two 16-bit data are stored in consecutive memory location starting from F000H
with lower bytes stored first. Write an assembly language program to copy this data
in four consecutive memory locations starting from D000H.

4) Write an assembly language program to load register pair BC and DE with 16-bit of
data F0F1H and E0E1H respectively and copy this data in consecutive memory
location starting with lower bytes first.

5) Write and A.L.P. to delete the data byte (i.e. make 00H) stored at memory location
whose address is stored at DE register pair.

GRADE LAB-INCHARGE H.O.D

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Arithmetic and Logic Instruction of 1
Interfacing 8085.
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 03 DATE :
REV. NO.: 1.00/JAN-2012

AIM: - To study Arithmetic and Logic instructions of 8085.

THEORY: -
Arithmetic and logic instruction performs various arithmetic and logical operations.

Arithmetic instruction performs


Addition of two 8-bit data.
Subtraction of two 8 bit data.
Increment/Decrement of 8-bit and 16-bit data.
Addition of two 16-bit data.
BCD addition.

Logic instruction performs


Logical AND of two 8-bit data.
Logical OR of two 8 bit data.
Logical Ex-OR of two 8 bit data.
Complement 8-bit data.
Rotate data Right/Left.
Set/Complement Carry flag.
Compare two 8-bit data.

Arithmetic instruction

Sr. No. Instruction


No. of Addressing Machine Flags
Opcode Description
Bytes Mode Cycles Affected
Operand
Add the contents of register
to the contents of
1 ADD R 1 Register OF All
accumulator. Store result in
accumulator.
Add the contents of memory
location, whose address is
2 ADD M 1 Indirect OF,MR All
stored in HL register pair, to
the contents of accumulator.
Add 8-bit data to the
3 ADI 8-bit 2 Immediate OF,MR All
contents of the accumulator.
4 ADC R 1 Add the register & Carry flag Register OF, MR All

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Arithmetic and Logic Instruction of 2
Interfacing 8085.
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 03 DATE :
REV. NO.: 1.00/JAN-2012

to the contents of the


accumulator.
Add the content of memory
5 ADC M 1 & Carry flag to the contents Indirect OF, MR All
of the accumulator
Add the 8-bit data & Carry
6 ACI 8-bit 2 flag to the contents of the Immediate OF, MR All
accumulator.
Subtract the contents of
1
7 SUB R register from the contents of Register OF All
accumulator.
SUB M Subtract the contents of
memory location, whose
1
8 address is stored in HL Indirect OF,MR All
register pair, from the
contents of accumulator.
SUI 8-bit 2 Subtract 8-bit data from the
9 Immediate OF,MR All
contents of the accumulator.
The contents of register &
SBB R 1 the borrow flag are
10 Register OF All
subtracted from the
accumulator.
The contents of memory
location whose address is
SBB M 1 stored in HL register pair &
11 Indirect OF, MR, All
the borrow flag are
subtracted from the
accumulator.
The 8-bit data & the borrow
SBI 8-bit
12 2 are subtracted from the Immediate OF, MR, All
contents of the accumulator.
Increment the contents of a All
INR R
13 1 register. Register OF except
CY
Increment the contents of a
All
memory location, whose OF, MR,
14 INR M 1 Indirect except
address is stored in HL MW
CY
register pair.
15 INX RP 1 Increment the contents of a Register OF None

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Arithmetic and Logic Instruction of 3
Interfacing 8085.
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 03 DATE :
REV. NO.: 1.00/JAN-2012

register pair.
All
DCR R Decrement the contents of a
16 1 Register OF except
register.
CY
Decrement the contents of a
All
DCR M 1 memory location, whose OF, MR,
17 Indirect except
address is stored in HL MW
CY
register pair.
Decrement the contents of a
18 DCX Rp 1 -- OF None
register pair.
The 16-bit contents of
DAD Rp register pair are added to the
OF, BI,
19 1 contents of HL register & the Register Only CY
BI
sum is saved in the HL
register.
The contents of accumulator
are changed from a binary
DAA value to its equivalent two,
20 1 Implied OF All
4-bit binary coded
decimal(BCD). Used in BCD
arithmetic

Logical instruction

Instruction
Sr. No. of Addressing Machine Flags
Opcode Description
No. Bytes Mode Cycles Affected
Operand
Logically AND the
CY=0, AC=1,
contents of register with
S,Z,P as per
1 ANA R 1 the contents of the Register OF
result
accumulator.

Logically AND the


contents of memory
CY=0, AC=1,
location, whose address
2 ANA M 1 Indirect OF, MR S,Z,P as per
is stored in HL, with the
result
contents of the
accumulator.
3 ANI 8-bit 2 Logically AND the 8- Immediate OF, MR CY=0, AC=1,

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Arithmetic and Logic Instruction of 4
Interfacing 8085.
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 03 DATE :
REV. NO.: 1.00/JAN-2012

bitdata with the S,Z,P as per


contents of the result
accumulator
Logically OR the
contents of register with
4 ORA R 1 Register OF
the contents of the
accumulator.
Logically OR the
contents of memory
CY=0, AC=0,
location, whose address
5 ORA M Indirect OF, MR S,Z and P as
is stored in HL, with the
per
contents of the
result
accumulator.
Logically OR the 8-bit
6 ORI 8-bit 2 data with the contents Immediate OF, MR
of the accumulator
Logically EXCLUSIVE-OR
the contents of
7 XRA R 1 register/memory with Register OF
the contents of the
accumulator.
Logically EXCLUSIVE-OR
the contents of memory CY=0, AC=0,
location, whose address S,Z and P as
8 XRA M 1 Indirect OF, MR
is stored in HL, with the per
contents of the result
accumulator.
Logically EXCLUSIVE-OR
the 8-bit data with the
9 XRI 8-bit 2 Immediate OF, MR
contents of the
accumulator
Complement the
10 CMA 1 contents of the Implicit OF None
accumulator
Rotate each bit in the
11 RLC 1 accumulator to the left Implicit OF CY
position.
Rotate each bit in the
12 RAL 1 Implicit OF CY
accumulator including

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Arithmetic and Logic Instruction of 5
Interfacing 8085.
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 03 DATE :
REV. NO.: 1.00/JAN-2012

carry to the left position.


(9 bit rotation)
Rotate each bit in the
13 RRC 1 accumulator to the right Implicit OF CY
position
Rotate each bit in the
accumulator including
14 RAR 1 carry to the right Implicit OF CY
position. (9 bit rotation)

The carry flag is


15 CMC 1 -- OF CY
complemented
16 STC 1 The carry flag is set to 1 -- OF CY
Compare the contents of
register with the
contents of the
17 CMP R 1 Register OF
accumulator for less
than, equal to or more
A<R/M/Data
than.
CY=1,Z=0
Compare the contents of
memory, whose address
A=R/M/data
is stored in HL, with the
CY=0,Z=1
18 CMP M 1 contents of the Indirect OF, MR
accumulator for less
A>R/M/data
than, equal to or more
CY=0,Z=0
than.
Compare the 8-bit data
with the contents of the
19 CPI 8-bits 2 accumulator for less Immediate OF, MR
than, equal to; or more
than.

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Arithmetic and Logic Instruction of 6
Interfacing 8085.
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 03 DATE :
REV. NO.: 1.00/JAN-2012

Example Program 1: Add two 8 bit numbers stored in register B & C store result in register D

Memory Mnemonics M/C code No. of Comments


Address bytes
2000 MOV A,B 78 1 Transfer content of register B in A
2001 ADD C 81 1 Add data stored in register C in A
2002 MOV D,A 57 1 Store result in register D
2003 HLT 76 1 End of program
Example data:
B: 20H, C: 23H.D:_______
B: 12H, C: FAH.D:_______ (Observe how carry flag is affected as per data conditions)

Example 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 Mnemonics M/C code No. of Comments


Address bytes
2000 LXI H,2100 21,00,21 3 Set HL register pair as a memory pointer
2003 MOV A,M 7E 1 Get data from memory location 2100
2004 INX H 23 1 Increment memory location
2005 SUB M 96 1 Subtract from accumulator
2006 INX H 23 1 Increment memory location
2007 MOV M,A 77 1 Store result at 2102
2008 HLT 76 1 End of program

Example data:
[1] 2100: 45 2101: 33 Note down result at 2102: _____
[2] 2100: 53 2101: 54 Note down result at 2102: _______ (Observe how negative answer is
represented)

Example Program 3: Implement the Boolean equation D = (B+C)E, where B,C, D and E represents
data in various registers of 8085

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Arithmetic and Logic Instruction of 7
Interfacing 8085.
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 03 DATE :
REV. NO.: 1.00/JAN-2012

Memory Mnemonics M/C code No. of Comments


Address bytes
2000 MOV A,B 78 1 Transfer content of register B in A
2001 ORA C B1 Perform logical OR operation
between A and register C
2002 ANA E A0 1 Perform logical AND operation
between A and register E
2003 MOV D,A 4F 1 Store result in register D
2004 HLT 76 1 End of program
Example data:
[1] B: 55 C: 33 E: FF D: _______
[2] B: 55 C: 22 E: 00 D: ________
[3] B: 25 C: 55 E: FO D: ________

Example Program 4: Add the contents of memory locations 40001H and 4001H and place the lower
byte of result in the memory locations 4002Hand higher byte in 4003H.
Memory Mnemonics M/C code No.of Comments
Address bytes
4000H LXI H, 4000H 21,00,40 3 Set HL register pair as a memory pointer
4003H MOV A, M 7E 1 Get data from memory location 4000
4004H INX H 23 1 Increment memory location
4005H ADD M 86 1 Add to accumulator
4006H INX H 23 1 HL Points 4002H
4007H MOV M,A 77 1 Store the lower byte of result at 4002H
4008H MVI A,00 3E,00 2 Initialize higher byte result with 00H
400AH ADC A 8F 1 Add carry in the high byte result
400BH INX H 23 1 HL Points 4003H
400CH MOV M, A 77 1 Store the higher byte of result at 4003H
400DH HLT 76 1 Terminate program execution
Example Data:
(4000H) = 7FH
(400lH) = 89H
Result = 7FH + 89H = 108H
(4002H) = 08H
(4003H) = 0lH

Example Program 5: Subtract the 16-bit number in memory locations 9002H and 9003H from the
16-bit number in memory locations 9000H and 9001H. The most significant eight bits of the two
numbers are in memory locations 9001H and 9003H. Store the result in memory locations 9004H

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Arithmetic and Logic Instruction of 8
Interfacing 8085.
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 03 DATE :
REV. NO.: 1.00/JAN-2012

and 9005H with the most significant byte in memory location 9005H

Memory Mnemonics M/C code No. of Comments


Address bytes
2000 LHLD 9000H 2A,00,90 3 Get first 16-bit number in HL
2003 XCHG EB 1 Save first 16-bit number in DE
2004 LHLD 9002H 2A,02,90 3 Get second 16-bit number in HL
2005 MOV A, E 7B 1 Get lower byte of the first number
2006 SUB L 95 1 Subtract lower byte of the second number
2007 MOV L, A 6F 1 Store the result in L register
2008 MOV A, D 7A 1 Get higher byte of the first number
2009 SBB H 9C 1 Subtract higher byte of second number
with borrow
200A MOV H, A 67 1 Store l6-bit result in memory locations
9004H and 9005H.
200B SHLD 9004H 22,04,90 3 Store l6-bit result in memory locations
9004H and 9005H.
200E HLT 76 1 Terminate program execution
Example Data:
(9000H) = 19H
(900IH) = 6AH
(9004H) = 15H (9003H) = 5CH
Result = 6A19H - 5C15H = OE04H
(9004H) = 04H
(9005H) = OEH

EXERCISE
1. Specify the register contents as the following instructions in the given program are
executed.
A H L CY Z S P AC
MVI A, 5EH
ADI A2H
SUB A
MVI H, FFH
MOV L,H
INR H
INX H
HLT

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Arithmetic and Logic Instruction of 9
Interfacing 8085.
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 03 DATE :
REV. NO.: 1.00/JAN-2012

2. Specify the register contents as the following instructions in the given program are
executed.
A B CY Z S
MVI A, 40H
MVI b, 20H
SUB B
MVI A, 20H
MVI B, 40H
SUB B
HLT

3. Two 16 bit data bytes are stored in memory from location 2050H with lower
bytes stored first. Write a program to add these two data and store the result
from 2054H. (Do it with and without using DAD instruction)
4. Write a program to multiply a number stored in accumulator by 3. (Assume
that the result is less then FFH)
5. Two BCD data are stored in memory location 2050H and 2051H. Write a
program to add this two data and store the result in memory location 2052H.
The result should be in BCD.
6. Two data bytes are stored in memory location 2041H and 2042H. Write a
program to add the higher 4 bits of the first data with lower 4 bits of second
data. Store the result in memory location 2043H.
7. Assume some data in register B and C. Mask all the bits except D0 from register
B and C. If D0 is at logic 1 in both registers, store 01H in memory location 2050
H otherwise store 00H.
8. Assume some data in accumulator and register B. If data of accumulator is less
than the data of register B then store 01H in memory location 2050H otherwise
store 00H.

GRADE LAB-INCHARGE H.O.D

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Branching Instruction of 8085. 1
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 05 DATE :
REV. NO.: 2.00/JAN-2012

AIM: - To study Branching instructions of 8085.

THEORY: -
Branching instruction changes the sequence of program execution. This is useful in
conditional execution and iterations. Branching instructions also called as Jump instructions
are mainly of two types: Unconditional jump instruction and conditional jump instructions.

Branching instruction

Sr. Instruction No. of Description Addressing Machine Cycles


No. Opcode Operand Bytes Mode
1 JMP 16-bit 3 Change the program sequence at Immediate OF, MR, MR
location specified by the 16-bit
address unconditionally
2 JZ 16-bit 3 Change the program sequence at Immediate True: OF,MR, MR
location specified by the 16-bit False: OF, MR
address if the zero flag is set
3 JNZ 16-bit 3 Change the program sequence at Immediate True: OF,MR, MR
location specified by the 16-bit False: OF, MR
address if the zero flag is reset
4 JC 16-bit 3 Change the program sequence at Immediate True: OF,MR, MR
location specified by the 16-bit False: OF, MR
address if the carry flag is set
5 JNC 16-bit 3 Change the program sequence at Immediate True: OF,MR, MR
location specified by the 16-bit False: OF, MR
address if the carry flag is reset
6 JP 16-bit 3 Change the program sequence at Immediate True: OF,MR, MR
location specified by the 16-bit False: OF, MR
address if the sign flag is reset
7 JM 16-bit 3 Change the program sequence at Immediate True: OF,MR, MR
location specified by the 16-bit False: OF, MR
address if the sign flag is set
8 JPE 16-bit 3 Change the program sequence at Immediate True: OF,MR, MR
location specified by the 16-bit False: OF, MR
address if the parity flag is set
9 JPO 16-bit 3 Change the program sequence at Immediate True: OF,MR, MR
location specified by the 16-bit False: OF, MR
address if the parity flag is reset

No Flags are affected.

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Branching Instruction of 8085. 2
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 05 DATE :
REV. NO.: 2.00/JAN-2012

Example Program 1: Write an assembly language program to copy block of 10 data stored in
memory starting from memory location 2050h to memory locations starting from 3000h

Memory Mnemonics M/C code No. of Comments


Address bytes
2000 LXI B, 2050H 01,50,20 3 BC used as memory read pointer
2003 LXI D, 3000H 11,00,30 3 DE used as memory write pointer
2006 MVI H,0AH 26,0A 2 H is used a counter initialized with 10
2008 LDAX B 0A 1 Copy data from ML pointed by BC to A
2009 STAX D 12 1 Copy data from A to ML pointed by DE
200A INX B 03 1 Update read pointer to next ML
200B INX D 13 1 Update write pointer to next ML
200C DCR H 25 1 Update counter by decrementing by 1
200D JNZ 2008H C2,08,20 3 If counter is not zero then jump & repeat
2010 HLT 76 1 If counter is zero then program ends
Note: While working on the simulator the address given with jump instruction can be
replaced by the label.

Example Program 2: Write a program to store data 33H at each memory location starting
from 20F0H to 20FFH.

Mnemonics Comments
LXI H, 20F0H HL initialized as memory pointer
MVI C,10H C initialized as counter
MVI A,33H Load required data into A
LOOP: MOV M,A Copy data from A to ML pointed by HL
INX H Update memory pointer to next ML
DCR C Update counter by decrementing by 1
JNZ LOOP If counter is not zero then jump & repeat
HLT If counter is zero then program ends

EXERCISE

1. A set of 16 data are stored in memory locations starting from 2050H to 205FH. To
insert additional five data bytes of data it is necessary to shift the data string by five
memory locations. Write a program to store data string from 2055H to 2064H.

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Study Branching Instruction of 8085. 3
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 05 DATE :
REV. NO.: 2.00/JAN-2012

(Instead of tabular documentation following questions can be documented in file just


by its ALP with relevant comments.)

2. Write a program to find maximum number in a given block of data. The block starts
at 3000H. The 1st data shows the length of block. Store the result at end of the
block.

3. A set of eight data bytes are stored in memory locations starting from 2070H. Write
a program to add two bytes at a time and store the sum in same memory location,
low order sum replacing 1st byte and a carry replacing 2nd byte. If any pair does not
generate a carry, the memory location of the 2nd byte should be cleared.

4. A set of readings is stored in memory locations starting from 2050H and last reading
is FFH. Write a program to check each byte in the string and save the bytes in the
range of (100)d to (150)d (both inclusive) in memory location starting from 2070H.
Also store number of bytes in a given range at 206FH memory location.

5. A set of ten current readings is stored in memory locations starting at 2060H. The
readings are expected to be signed. Write a program to check each reading whether
it is positive or negative and eliminate all negative readings, thus reducing the size
of data set.

GRADE LAB-INCHARGE H.O.D

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Programming Tutorial 1
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 05 DATE :
REV. NO.: 1.00/JAN-2012

Simulate following programs on the simulator and either write or attach a print-out
of the same in the file.

1 Six data bytes are stored at memory locations starting from 2050H. Write a program
to separate data with odd parity. Store all such data bytes at memory location
2060H.

2 Write to count how many increments and decrements are required to equalize 67H
and 85H respectively. 67H should increment and 85H should decrement one by one.

3 A set of data bytes is stored in the memory locations starting at 2050H. Check each
data byte for bits D7 and D0. If D7 or D0 is 1, reject the data byte, otherwise store
the data at memory location starting at 2080H. The end of data string is indicated
by the data byte 00H.

4 A bar code scanner scans the boxes being shipped from the loading dock and
records all the codes in computer memory. The end of data is indicated by 00H. 8
bit bar code 10100011(A3H) is assigned to 19 TV sets. Write a program to counter
the number of 19 TV sets that were shipped from given data.

5 A set of five readings is stored in memory locations starting at 2050H. Sort the
readings in ascending order.

6 A set of 5 reading is stored in memory location starting from 2050H. Write a


program to count number of 1s (bit 1) present in each data byte (eg. 33h =
00110011 has 4 1s). Store the result in the same memory location.

GRADE LAB-INCHARGE H.O.D

Darshan Institute of Engineering And Technology, Rajkot


SUBJECT: TITLE:
Microprocessor & Designing Counter and Time Delays 1
Interfacing
DOC. CODE: DIET/EC/CE
EXPERIMENT NO. 06 DATE :
REV. NO.: 1.00/JAN-2011

1. Calculate the time required by 8085 to execute the following program.(Assume


crystal of 6.144MHz frequency).
T states
MVI B,DEH 7
LOOP: DCR B 4
NOP 4
NOP 4
JNZ LOOP 10/7
RST 1 12

2. Calculate the time required by 8085 to execute the following program.(Assume


crystal of 6.144MHz frequency).
T-states
LXI B,FFFFH 10
LOOP: DCX B 6
NOP 4
NOP 4
MOV A,C 4
ORA B 4
JNZ LOOP 10/7

3. Write a program to generate a delay of 5 seconds.(Assume crystal of 6.144MHz


frequency).

4. Write a program to generate a square wave of 2.5 kHz frequency. Use D0 bit of
output port ACH, to output the square wave.

5. Make an up-down counter that will count from 00H to 10H in upward & again
from 10H to 00H in downward. Send the counts to output port CDH. Between
each count, there should be a time delay of 1 second approximately.(Assume
crystal of 6.144MHz frequency).

GRADE LAB-INCHARGE H.O.D

Darshan Institute of Engineering And Technology, Rajkot

Das könnte Ihnen auch gefallen