0% found this document useful (0 votes)
11 views4 pages

Experiment No 4

This document outlines Experiment No. 4, focusing on the comparison and jump instructions of the 8085 microprocessor. It details the comparison operations (CMP, CPI) and their effects on flags, as well as various jump instructions that conditionally alter program flow based on flag status. Additionally, it discusses designing counters for tracking events and provides examples of using up-counters and down-counters in programming applications.

Uploaded by

OMNYAT 123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Experiment No 4

This document outlines Experiment No. 4, focusing on the comparison and jump instructions of the 8085 microprocessor. It details the comparison operations (CMP, CPI) and their effects on flags, as well as various jump instructions that conditionally alter program flow based on flag status. Additionally, it discusses designing counters for tracking events and provides examples of using up-counters and down-counters in programming applications.

Uploaded by

OMNYAT 123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EXPERIMENT NO.

4
Comparison AND JUMP INSTRUCTIONS OF THE 8085
MICROPROCESSOR

OBJECT:
To study the comparison capabilities of the 8085 microprocessor and to further
investigate the conditional and unconditional branch instructions.

THEORY

Compare Operations (CMP, CPI) :- These instructions compare the accumulator


with the required 8-bit data, setting the appropriate flag and leaving the accumulator
untouched.

No Instruction Type No. of Function Effect


Bytes
1. CMP r Logical 1 Compare r with A (A-r) All
2. CPI byte Logical 2 Compare byte with A All
(A-byte)

The result of the comparison is shown by setting the flags as follows:-


If A = (r/byte) then CY=0 and Z=1
If A < (r/byte) then CY=1 and Z=0
If A > (r/byte) then CY=0 and Z=0

Notes of flags affection


We can see from the previous experiments that only arithmetic and logical
instructions affect the flag register, and we notice some exceptions.
1- The four rotate instructions, STC, CMC, and DAD instructions affect carry flag only
and we can write the effect is: CY.
2- DCR and INR instructions affect all the flag bits except the carry bit and we can
write the effect is: All but CY.
3- INX, DCX, and CMA instructions don’t affect any flag bits and we can write the
effect is: None.
4- Other arithmetic and logical instructions affect all the flag bits and we can write the
effect is: All.

23
It is known that the flow of some program may be deviated by specific jump
instructions. These jumps test the status of the appropriate flags and jump accordingly
to the specified address, given by the two bytes following the jump instruction in the
order (Low Byte, High Byte). The types of JUMPs supported are:

1. JMP (address) :- This instruction jumps unconditionally to the specified address.


2. JZ (address) :- This instruction tests the zero flag bit, and jumps to the specified
address if this bit is set.
3. JNZ (address) :- This instruction tests the zero flag bit, and jumps to the specified
address if this bit is reset.
4. JC (address) :- This instruction tests the carry flag bit, and jumps to the specified
address if this bit is set.
5. JNC (address) :- This instruction tests the carry flag bit, and jumps to the specified
address if this bit is reset.
6. JM (address) :- This instruction tests the sign flag bit, and jumps to the specified
address if this bit is set.
7. JP (address) :- This instruction tests the sign flag bit, and jumps to the specified
address if this bit is reset.
8. JPE (address) :- This instruction tests the parity flag bit, and jumps to the specified
address if this bit is set (even parity).
9. JPO (address) :- This instruction tests the parity flag, bit, and jumps to the
specified address if this bit is reset (odd parity).
No Instruction Type No. of Function Effect
Bytes
1. JMP address Branch 3 Pc=address None
2. JZ address Branch 3 Pc=address if Z=1 None
3. JNZ address Branch 3 Pc=address if Z=0 None
4. JC address Branch 3 Pc=address if CY=1 None
5. JNC address Branch 3 Pc=address if CY=0 None
6. JM address Branch 3 Pc=address if S=1 None
7. JP address Branch 3 Pc=address if S=0 None
8. JPE address Branch 3 Pc=address if P=1 None
9. JPO address Branch 3 Pc=address if P=0 None
Pc: program counter. Notice: Jumps inst. Check the flags but not affect the flags
Example:- Example:- Example:-
Check if A+B = 0 then Check if A+B = 50 then Check if A = 0 then
increment the result increment the result increment A
MVI A, … MVI A, … MVI A, …
MVI B, … MVI B, … ANA A ; (/ ORA A/
ADD B ADD B ; CPI 0/ ADI 0)
JNZ end CPI 50 JNZ end
INR A JNZ end INR A
End: RST5 INR A End: RST5
End: RST5
24
Counters
Designing a counter is a frequent programming application. Counters are used
primarily to keep track of events.
A counter is designed by loading an appropriate count in a register. A loop is set
up decrement the count for a down-counter (counts in the descending order) by using
the DCR (decrement by one) instruction or to increment the count for an up-counter
(counts in the ascending order) by using the INR (increment by one) instruction. A loop
is established to update the counter, and each count is checked to determine whether it
has reached the final number; if not the loop is repeated.

Examples:-
1- 1≤ No. of loops < 256
Using UP-counter:-
Using down-counter:-
MVI C,0
MVI C,8
Loop: INR C
Loop: DCR C
MOV A, C
JNZ Loop
CPI 8
RST5
JNZ Loop
RST5
2- No. of loops = 256

Using down-counter:-
MVI C,0
Loop: DCR C
No. of loops ≤ 256
JNZ Loop
RST5
Using UP-counter:-
LXI B,0
3- No. of loops > 256 Loop: INX B
MOV A,C
Using down-counter:- CPI lowbyteno
LXI B, 3b5h JNZ Loop
Loop: DCX B ; not effect Z flag MOV A,B
; To affect the Z flag and check if B or CPI highbyteno
C is not finished then continue the loop JNZ loop
MOV A,C RST5
ORA B
JNZ Loop
RST5

Note:- You can see that down-counter is preferred to use than up-counter.

25
Useful instructions:
PCHL: The contents of register H and L are copied into the program counter. The
contents of H are placed as a high-order byte and of L as a low-order byte.

Instruction Type No. of Function Effect


Bytes
PCHL Branch 1 PC=HL None

LAB Work
1- exclusive or register A and B, then add 3 to register C if the parity is even otherwise
add 30h to C, when A=35h, B=20h, C=10h
2- Check if the content of register B is even then C=1, otherwise C=2. (by using two
methods)
3- Calculate the sum of numbers between 10 and 1.

26

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy