Experiment No: 3 ROLL NUMBER: 18BEE105
Aim: - To apply the branching instructions of 8085 microprocessor.
Branching Instructions:
Type Instruction Function
JUMP JMP 16-bit Jumps to the 16-bit
address(unconditional).
JC 16-bit Jumps to 16-bit address
if CY = 1.
JNC 16-bit Jumps to 16-bit address
if CY is not equal to 1.
JZ 16-bit Jumps to 16-bit address
if zero flag = 1.
JNZ 16-bit Jumps to 16-bit address
if zero flag is not equal
to 1.
JPE 16-bit Jumps to 16-bit address
if parity flag = 1.
JPO 16-bit Jumps to 16-bit address
if parity flag is not equal
to 1.
JP 16-bit Jumps to 16-bit address
if it is a positive
number.
JM 16-bit Jumps to 16-bit address
if it is a negative
number.
CALL CALL 16-bit Transfer the program
sequence to 16-bit
memory location from
the main program.
(unconditional)
CC 16-bit Calls the 16-bit address
if CY = 1.
CNC 16-bit Calls the 16-bit address
if CY is not equal to 1.
CZ 16-bit Calls the 16-bit address
if zero flag = 1.
CNZ 16-bit Calls the 16-bit address
if zero flag is not equal
to 1.
CPE 16-bit Calls the 16-bit address
if parity flag = 1.
CPO 16-bit Calls the 16-bit address
if parity flag is not equal
to 1.
CP 16-bit Calls the 16-bit address
if it is a positive
number.
CM 16-bit Calls the 16-bit address
if it is a negative
number.
RETURN RET Program routine is
transferred
unconditionally from
subroutine to the main
program.
RC Return if CY = 1.
RNC Return if CY is not equal
to 1.
RZ Return if zero flag = 1.
RNZ Return if zero flag is not
equal to 1.
RPE Return if parity flag = 1.
RPO Return if parity flag is
not equal to 1.
RP Return if it is a positive
number.
RM Return if it is a negative
number.
1. Find the smallest element in a block of data. The length of the
block is in memory location 1051 H and block itself begins in
memory location 1052 H. Store the smallest number in
memory location 1050 H. Assume that the numbers in the
block are all 8-bit unsigned binary numbers.
Memory Location Instruction Opcode(H)
1000 LXI H,1051H 21
1001 51
1002 10
1003 MOV C, M 4E
1004 MVI A, FFH 3E
1005 FF
1006 LOOP: INX H 23
1007 CMP M BE
1008 JC SKIP DA
1009 MOV A, M DC
100A SKIP: DCR C 10
100B JNZ LOOP 7E
100C 0D
100D C2
100E 06
100F 10
1010 32
1011 50
1012 10
1013 HLT 76
2. Determine the number of odd and even elements in a block of
data. The length of the block is in memory location 1051 H and
the block itself starts in memory location 1052 H. Store the
number of odd elements in memory location 1070H and even
elements in memory location 1071 H.
Memory Location Instruction Opcode(H)
1000 LXI H,1050H 21
1001 50
1002 10
1003 MOV C, M 4E
1004 INX H 23
1005 MOV D,00H 16
1006 00
1007 MOV E, D 5A
1008 LOOP: MOV M, A 77
1009 RRC 0F
100A JC SKIP DA
100B INX E 11
100C JMP SKIP1 10
100D SKIP: INR D 1C
100E SKIP1: INX H C3
100F 12
1010 10
1011 DCR C 14
1012 JNZ LOOP 23
1013 00
1014 C2
1015 08
1016 10
1017 MOV A, D 7A
1018 STA 1070H 32
1019 70
101A 10
101B MOV A, E 7B
101C 32
101D STA 1070H 71H
101E 10
101F 76
1020 HLT 76
3. A set of 10 readings is stored in memory location starting at
1060H. The readings are expected to be positive. Write an
ALP to
a) check each reading to determine whether is it positive or
negative
b) reject all negative readings
c) add all positive readings
d) store FFH in ML 1070H if the sum exceeds 8-bit else store
the actual sum.
Memory Location Instruction Opcode(H)
1000 LXI H,1060H 21
1001 60
1002 10
1003 MVI B,00H 06
1004 00
1005 MVI C,00H 0E
1006 00
1007 MVI D,00H 16
1008 00
1009 LOOP: MVI A,00H 3E
100A 00
100B JM SKIP 86
100C ADD M FA
100D ADD D 12
100E MOV D, A 10
100F INX B 82
1010 SKIP: INX H 57
1011 DCR C 04
1012 JNZ LOOP 23
1013 0D
1014 C2
1015 09
1016 10
1017 MOV A, D 78
1018 STA 2000H 32
1019 00
101A 20
101B MOV A, D 7A
101C STA 1070H 32
101D 70
101E 10
101F HLT 76
4. Convert the hex content of M.L. 1060H to ASCII. Store the
ASCII character in 1061H. The number is between 00H to 0FH.
Memory Location Instruction Opcode(H)
1000 LDA 1060H 21
1001 60
1002 10
1003 CPI 0AH 7E
1004 FE
1005 0A
1006 JC SKIP DA
1007 0B
1008 10
1009 ADI 07H C6
100A 07
100B SKIP: ADI 30H C6
100C 30
100D 23
100E 77
100F 76
1010 10
1011 STA 1061H 32
1012 61
1013 10
1014 HLT 76
5. Write an ALP to convert the content of M.L. 1040H from
decimal no. to seven segment code in 1041H. If the no. in
1040H is not a valid 7 segment code, set 1041H with 00H.
Memory Location Instruction Opcode(H)
1000 MVI B, 00H 06
1001 00
1002 LDA 1040H 3A
1003 40
1004 10
1005 CPI 0AH FE
1006 0A
1007 JNC SKIP D2
1008 12
1009 10
100A LXI D,2000H 11
100B 00
100C 20
100D MOV L, A 6F
100E MVI H,00H 26
100F 00
1010 DAD D 19
1011 MOV B, M 46
1012 SKIP: MOV A, B 78
1013 STA 1041H 32
1014 41
1015 10
1016 HLT 76