Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views22 pages

MPMC Module 2 Lecture 6

The document provides a detailed overview of the 8085 microprocessor instruction set, focusing on branch instructions that control program execution. It explains both unconditional and conditional branch instructions, including examples of assembly language programs that illustrate their usage. Additionally, it includes several examples of assembly language programs for various operations, such as loading values, arithmetic operations, and manipulating memory locations.

Uploaded by

jay10052004
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)
7 views22 pages

MPMC Module 2 Lecture 6

The document provides a detailed overview of the 8085 microprocessor instruction set, focusing on branch instructions that control program execution. It explains both unconditional and conditional branch instructions, including examples of assembly language programs that illustrate their usage. Additionally, it includes several examples of assembly language programs for various operations, such as loading values, arithmetic operations, and manipulating memory locations.

Uploaded by

jay10052004
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/ 22

Dr.

Subhasish Mahapatra
Sr. Assistant Professor
School of Electronics Engineering (SENSE)
VIT-AP University
E-Mail: [email protected]
CONTENT

 8085 microprocessor Instruction


Sets (Cont…)

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 2
Dr. Subhasish Mahapatra
Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 3
8085 INSTRUCTION SET: BRANCH INSTRUCTION

 These instructions are used to transfer the program control:


 To jump from one memory location to any other memory location within a program
 From one program to another program called as a subroutine
 Alters the sequence of program execution either conditionally or unconditionally
 Unconditional branch instructions - Transfer the program to the specified label or address JMP
unconditionally i.e. without satisfying any condition.
 Unconditional Program control instructions are CALL & RET
 Conditional branch instructions -Transfer the program to the specified label or address when
certain condition is satisfied.
 JNC, JC, JNZ, JZ, JP, JM, JPE, JPO
 CNC, CC, CNZ, CZ, CP, CM, CPE, CPO
 RNC, RC, RNZ, RZ, RP, RM, RPE, RPO

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 4
8085 INSTRUCTION SET: BRANCH INSTRUCTION

OPCODE OPERAND EXPLANATION Flag Status EXAMPLE


Unconditional Jump
JMP 16 bit Address Jump to a address None JMP 5000H

Conditional Jump
JC 16 bit Address Jump on Carry CY=1 JC 5000H
JNC 16 bit Address Jump on no Carry CY=0 JNC 5000H
JP 16 bit Address Jump on positive S=0 JP 5000H
JM 16 bit Address Jump on minus S=1 JM 5000H
JZ 16 bit Address Jump on zero Z=1 JZ 5000H
JNZ 16 bit Address Jump on no zero Z=0 JNZ 5000H
JPE 16 bit Address Jump on parity even P=1 JPE 5000H
JPO 16 bit Address Jump on parity odd P=0 JPO 5000H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 5
8085 INSTRUCTION SET: BRANCH INSTRUCTION

OPCODE OPERAND EXPLANATION Flag Status EXAMPLE


Unconditional Call
CALL 16 bit Address Call to a address None CALL 5000H

Conditional Call
CC 16 bit Address Call on Carry CY=1 CC 5000H
CNC 16 bit Address Call on no Carry CY=0 CNC 5000H
CP 16 bit Address Call on positive S=0 CP 5000H
CM 16 bit Address Call on minus S=1 CM 5000H
CZ 16 bit Address Call on zero Z=1 CZ 5000H
CNZ 16 bit Address Call on no zero Z=0 CNZ 5000H
CPE 16 bit Address Call on parity even P=1 CPE 5000H
CPO 16 bit Address Call on parity odd P=0 CPO 5000H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 6
8085 INSTRUCTION SET: BRANCH INSTRUCTION

OPCODE OPERAND EXPLANATION Flag Status EXAMPLE


Unconditional Return
RET 16 bit Address Return to a address None RET 5000H

Conditional Return
RC 16 bit Address Return on Carry CY=1 RC 5000H
RNC 16 bit Address Return on no Carry CY=0 RNC 5000H
RP 16 bit Address Return on positive S=0 RP 5000H
RM 16 bit Address Return on minus S=1 RM 5000H
RZ 16 bit Address Return on zero Z=1 RZ 5000H
RNZ 16 bit Address Return on no zero Z=0 RNZ 5000H
RPE 16 bit Address Return on parity even P=1 RPE 5000H
RPO 16 bit Address Return on parity odd P=0 RPO 5000H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 7
Dr. Subhasish Mahapatra
Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 8
8085 ASSEMBLY LANGUAGE PROGRAMS

Example 1: Write an assembly language program (ALP) to place 05H in register B

Program: MVI B, 05H ; B = 05H


HLT

Example 2: Write an ALP to place 05 in register A ; then move it to register B

Program: MVI A, 05 ; A = 05
MOV B, A ; B = 05
HLT

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 9
8085 ASSEMBLY LANGUAGE PROGRAMS

Example 3: Write an ALP to load the content of memory location FC50H


Address Data
directly to the accumulator, then transfer it to register B. The
content of the memory Location is 05H. 0000H 00H
0001H 00H
Program: LDA FC50H ; A = 05H .
MOV B, A ; B = 05H .
HLT FC50H 05H
FC51H 08H
Example 4: Write an ALP to load the content of memory location FC51H
.
to register C. The content of the memory Location is 08. .
Program: LXI H, 0FC51H ; HL = FC51H HL FFFFH 00H
MOV C, M ; C = 08H
HLT

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 10
8085 ASSEMBLY LANGUAGE PROGRAMS

Example 5: Write an ALP to place the content of memory location FC50H


Address Data
in B register and that of FC51H in Register C. The contents of
the memory locations FC50H and FC51H are 11H and 12H, 0000H 00H
0001H 00H
respectively.
.
Program: LXI H, 0FC50H ; HL = FC50H .
FC50H 11H
MOV B, M ; B = 11H
FC51H 12H
INX H ; HL = FC51H .
MOV C, M ; C = 12H .
HL
FFFFH 00H
HLT

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 11
8085 ASSEMBLY LANGUAGE PROGRAMS

Example 6: Write an ALP to place 05 in the accumulator. Increment it by


one and store the result in the memory Location FC50H.
Address Data
Program: MVI A, 05 ; A = 05
0000H 00H
INR A ; A = 06 0001H 00H
STA FC50H ; [FC50H] = 06H .
.
HLT FC50H 06H
.
.
FFFFH 00H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 12
8085 ASSEMBLY LANGUAGE PROGRAMS

Example 7: Write an ALP to add 49H and 56H. Assume 49H is in 2501H,
Address Data
56H is in 2502H and result is to be stored in 2503H
0000H 00H
Program: LXI H, 2501H ; HL = 2501H 0001H 00H
MOV A, M ; A = 49H .
.
INX H ; HL = 2502H
2501H 49H
ADD M ; A = 49H + 56H = 9FH 2502H 56H
2503H 9FH
STA 2503H ; [2503H] = 9FH
.
HL
HLT .
FFFFH 00H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 13
8085 ASSEMBLY LANGUAGE PROGRAMS

Example 8: Write an ALP to subtract 49H - 32H. Assume 49H is in 2501H,


Address Data
32H is in 2502H and result is to be stored in 2503H
0000H 00H
Program: LXI H, 2501H ; HL = 2501H 0001H 00H
MOV A, M ; A = 49H .
.
INX H ; HL = 2502H
2501H 49H
SUB M ; A = 49H - 32H = 17H 2502H 32H
2503H 17H
INX H ; HL = 2503H
.
HL
MOV M, A ; [2503H] = 17H .
HLT FFFFH 00H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 14
8085 ASSEMBLY LANGUAGE PROGRAMS
Address Data
Example 9: Write an ALP to add N numbers in a data array. Assume the data
0000H 00H
is starting form 2501H location and result is to be stored in 0001H 00H
3000H .
2500H N = 05
Program: LXI H, 2500H ; HL = 2500H
2501H 10H
MOV C, M ; Counter value N, C = [2500H] HL
2502H 40H
MVI A, 00H ; A = 00H
2502H 50H
BACK: INX H ; HL = HL + 1
2502H 30H
ADD M ; Flags = A - [HL] 2502H 06H
DCR C ;C=C-1 .
JNZ BACK ; Is Z = 0 ? 3000H 50H
STA 2503H ; [2503H] = 49H .
HLT FFFFH 00H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 15
8085 ASSEMBLY LANGUAGE PROGRAMS

Example 10: Write an ALP to largest number between 49H and 32H. Assume Address Data

49H is in 2501H, 32H is in 2502H and result is to be stored 0000H 00H


in 2503H 0001H 00H
.
Program: LXI H, 2501H ; HL = 2501H
2501H 49H
MOV A, M ; A = 49H
2502H 32H
INX H ; HL = 2502H 2503H 49H
CMP M ; Flags = 49H - 32H .
HL
JNC AHEAD ; Is CY = 0 ? FFFFH 00H
MOV A, M ; A = [2502H]
AHEAD: STA 2503H ; [2503H] = 49H S Z X AC X P X CY
HLT 0 0 0 1 0

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 16
8085 ASSEMBLY LANGUAGE PROGRAMS
Address Data
Example 11: Write an ALP to largest number in a data array. Assume the
0000H 00H
data is starting form 2501H location and result is to be 0001H 00H
stored in 3000H .
Program: LXI H, 2500H ; HL = 2500H 2500H N = 05
MOV C, M ; Counter value, C = [2500H] 2501H 10H
MVI A, 00H ; A = 00H 2502H 40H
BACK: INX H ; HL = HL + 1 2502H 50H
HL
CMP M ; Flags = A - [HL] 2502H 30H
JNC AHEAD ; Is CY = 0 ? 2502H 06H
MOV A, M ; A = [HL]
.
AHEAD: DCR C ;C=C-1
JNZ BACK ; Is Z = 0 ? 3000H 50H
STA 2503H ; [2503H] = H .
HLT FFFFH 00H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 17
8085 ASSEMBLY LANGUAGE PROGRAMS

Address Data
Example 12: Write an ALP to set bit 3 in accumulator. Assume 41H is in
0000H 00H
2501H, copy the content to accumulator and result is to be
0001H 00H
stored in 2503H .
Program: LXI H, 2501H ; HL = 2501H 2501H 41H
MOV A, M ; A = 41H 2502H 00H
2503H 49H
ORI 08H
HL .
STA 2503H ; [2503H] = 49H
FFFFH 00H
HLT
D7 D6 D5 D4 D3 D2 D1 D0 A = 41H
OR 0 0 0 0 1 0 0 0 08H
D7 D6 D5 D4 1 D2 D1 D0 A = 49H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 18
8085 ASSEMBLY LANGUAGE PROGRAMS

Address Data
Example 13: Write an ALP to set bit 3 in accumulator. Assume 41H is in
0000H 00H
2501H, copy the content to accumulator and result is to be
0001H 00H
stored in 2503H .
Program: LXI H, 2501H ; HL = 2501H 2501H 41H
MOV A, M ; A = 41H 2502H 00H
2503H 49H
ORI 08H ; A = A | 08H = 49H
HL .
STA 2503H ; [2503H] = 49H
FFFFH 00H
HLT
D7 D6 D5 D4 D3 D2 D1 D0 A = 41H
OR 0 0 0 0 1 0 0 0 08H
D7 D6 D5 D4 1 D2 D1 D0 A = 49H

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 19
8085 ASSEMBLY LANGUAGE PROGRAMS

Example 14: Write an ALP to set bits 3 and 1, clear bits 6 and 4, and complement bits 7 and 0 in
accumulator. Assume D7H is in 2501H, copy the content to accumulator and result is to
be stored in 2503H

Program:
1 1 0 1 0 1 1 1 A = D7H
OR 0 0 0 0 1 0 1 0 0AH
1 1 0 1 1 1 1 1 A = DFH
AND 1 0 1 0 1 1 1 1 AFH
1 0 0 0 1 1 1 1 A = 8FH
XOR 0 0 1 0 0 0 0 1 21H
1 0 1 0 1 1 1 0 A = AEH

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 20
8085 ASSEMBLY LANGUAGE PROGRAMS

Example 14:
Address Data
Program: LXI H, 2501H ; HL = 2501H
0000H 00H
MOV A, M ; A = D7H
0001H 00H
ORI 0AH ; A = A | 0AH = DFH .
2501H D7H
ANI AFH ; A = A & AFH = 8FH
2502H 00H
XRI 21H ; A = A ^ 21H = AEH 2503H AEH
STA 2503H ; [2503H] = AEH HL .
FFFFH 00H
HLT

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 21
Please follow the instructions of the government and stay safe

Dr. Subhasish Mahapatra


Sr. Assistant Professor, SENSE
8085 and 8086 Microprocessors 22

You might also like