Experiment No 4
Experiment No 4
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
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:
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.
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