Branching instructions in 8085 Microprocessor

The instructions in 8085 that are used to transfer the program control from one memory location to another memory location are grouped under branching instructions in 8085 microprocessor.

Branching Instructions in 8085

Opcode

Operand

Explanation of Instruction

Description

JMP

16-bit address

Jump unconditionally

The program sequence is transferred to the memory location specified by the 16-bit address given in the operand. Example: JMP 2034H or JMP XYZ

Opcode

Description

Flag Status

JC

Jump on Carry

CY = 1

JNC

Jump on no Carry

CY = 0

JP

Jump on positive

S = 0

JM

Jump on minus

S = 1

JZ

Jump on zero

Z = 1

JNZ

Jump on no zero

Z = 0

JPE

Jump on parity even

P = 1

JPO

Jump on parity odd

P = 0

16-bit address

Jump conditionally

The program sequence is transferred to the memory location specified by the 16-bit address given in the operand based on the specified flag of the PSW as described below.

Example: JZ 2034H or JZ XYZ

CALL

16-bit address

Call unconditionally

The CALL instruction pushes the current contents of the program counter (the address of the next instruction to be executed) onto the stack and then transfers control to the specified subroutine.

Example: CALL 2050H

Opcode

Description

Flag Status

CC

Call on Carry

CY = 1

CNC

Call on no Carry

CY = 0

CP

Call on positive

S = 0

CM

Call on minus

S = 1

CZ

Call on zero

Z = 1

CNZ

Call on no zero

Z = 0

CPE

Call on parity even

P = 1

CPO

Call on parity odd

P = 0

16-bit address

Unconditional subroutine call

The program sequence is transferred to the memory location specified by the 16-bit address given in the operand. Before the transfer, the address of the next instruction after CALL (the contents of the program counter) is pushed onto the stack.

Example: CALL 2034H or CALL XYZ

RET

none

Return from subroutine unconditionally

The program sequence is transferred from the subroutine to the calling program. The two bytes from the top of the stack are copied into the program counter, and program execution begins at the new address.

Example: RET

Opcode

Description

Flag Status

RC

Return on Carry

CY = 1

RNC

Return on no Carry

CY = 0

RP

Return on positive

S = 0

RM

Return on minus

S = 1

RZ

Return on zero

Z = 1

RNZ

Return on no zero

Z = 0

RPE

Return on parity even

P = 1

RPO

Return on parity odd

P = 0

none

Return from subroutine conditionally

The program sequence is transferred from the subroutine to the calling program based on the specified flag of the PSW as described below. The two bytes from the top of the stack are copied into the program counter, and program execution begins at the new address.

Example: RZ

RST

0-7

Restart

The RST instruction is equivalent to a 1-byte call instruction to one of eight memory locations depending upon the number. The instructions are generally used in conjunction with interrupts and inserted using external hardware. However these can be used as software instructions in a program to transfer program execution to one of the eight locations. The addresses are:

Instruction

Restart Address

RST 0

0000H

RST1

0008H

RST 2

0010H

RST 3

0018H

RST 4

0020H

RST 5

0028H

RST 6

0030H

RST 7

0038H

The 8085 has four additional interrupts and these interrupts generate RST instructions internally and thus do not require any external hardware. These instructions and their Restart addresses are:

Interrupt

Restart Address

TRAP

0024H

RST 5.5

002CH

RST 6.5

0034H

RST 7.5

003CH

Difference Between Call and Return Instruction in 8085 Microprocessor

Here is a table summarizing the differences between the CALL and RETURN instructions:

Instruction

CALL

RETURN

Function

Jumps to a subroutine

Returns from a subroutine

Syntax

CALL address

RET

Operands

Address of subroutine

None

Stack

Pushes the address of the next instruction onto the stack

Pops the return address from the stack into the program counter (PC)

Execution

Non-conditional

Non-conditional

Addressing mode

Immediate addressing

None

Length

3 bytes

1 byte

Timing

17 cycles

10 cycles

Effect on flags

None

None

In summary, the main differences between the CALL and RETURN instructions are:

  • CALL is used to jump to a subroutine, while RETURN is used to return from a subroutine.
  • CALL requires an operand, which is the address of the subroutine being called, while RETURN does not require any operands.
  • CALL pushes the address of the next instruction onto the stack before jumping to the specified subroutine, while RETURN pops the return address from the stack and loads it into the program counter (PC).
  • CALL uses immediate addressing mode, while RETURN does not use any addressing mode.
  • CALL is a 3-byte instruction, while RETURN is a 1-byte instruction.
  • CALL takes longer to execute than RETURN, requiring 17 cycles compared to 10 cycles for RETURN.
  • Neither instruction affects the state of the flags register.

Recent posts

Leave a Comment

Your email address will not be published. Required fields are marked *