# Restart instructions (RSTn) in 8085 Microprocessor

Microprocessor8085

In 8085 Instruction set, RSTn is actually standing for “Restart n”. And in this case, n has a value from 0 to 7 only. Thus the eight possible RST instructions are there, e.g. RST 0, RST 1, …, RST 7. They are 1-Byte call instructions. Functionally RST n instruction is similar with:

RST n = CALL n*8

For example, let us consider RST 4 is functionally equivalent to CALL 4*8, i.e. CALL 32 = CALL 0020H. The advantage of RST 2 is that it is only 1 Byte, whereas CALL 0010H is 3-Byte long. Thus RST instructions are useful for branching to frequently used subroutines.

Mnemonics, Operand
Opcode(in HEX)
In Binary
Bytes
RST 0
C7
1100 0111
1
0000H
RST 1
CF
1100 1111
1
0008H
RST 2
D7
1101 0111
1
0010H
RST 3
DF
1101 1111
1
0018H
RST 4
E7
1110 0111
1
0020H
RST 5
EF
1110 1111
1
0028H
RST 6
F7
1111 0111
1
0030H
RST 7
FF
1111 1111
1
0038H

In the above table, it has been shown that if we analyze the RSTn Hex Codes than we are finding that middle most 3-bits are denoting the value for n (As highlighted in the table). And the other5 bits in the Byte provide the code for RST.

Let us consider, RST 4 is an example instruction of this type. It is a 1-Byte instruction. It is functionally same as CALL 0020H = PUSH PC + JMP  0010H. It causes a branch to subroutine starting from memory address 0020H. Similarly, RST 5 causes a branch to a subroutine at 5*8 = 0028H. Thus, the subroutine, which starts at location 0020H should not go beyond memory location 0027H. So at the most only eight locations are available for the subroutine, which is too small in general to keep the sub-routine bodies. This limitation is overcome by branching to a subroutine at some other memory location, like 4050H. It is achieved by the combination of RST 4 instruction, and JMP 4050H instruction at memory location 0020H, as shown in the following Fig.

The way in which the stack contents get affected due to the execution of RST 4 is shown below.

The way in which the stack contents get affected due to an execution of RST 4 is shown below.

Before
After
(PC)
2021H
0020H
(SP)
5000H
4FFEH
(4FFFH)
Any Value
20H
(4FFEH)
Any Value
21H