RST
performs a reset. Specifically it calls a routine at one of 8 addresses at the base of memory.
It is the equivalent of performing a CALL
to that address except the RST
instruction is just
1 byte compared to 3 for CALL
and is slightly faster.
\((SP-1) \longleftarrow PC_h \\(SP-2) \longleftarrow PC_l \\SP \longleftarrow SP-2 \\PC_h \longleftarrow 0\\PC_l \longleftarrow b*8\)
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|
1 | 1 | b | 1 | 1 | 1 |
Value | b | |
---|---|---|
0 | 000 | |
1 | 001 | |
2 | 010 | |
3 | 011 | |
4 | 100 | |
5 | 101 | |
6 | 110 | |
7 | 111 |
Issues with RST instructions
Assemblers use different conventions for the RST
instruction.
Some use numbers 0…7 whilst others use the address of the code invoked.
They are all equivalent, as there are just 8 possible instruction codes.
Address | OP Code | RST Instruction | Action | |||
---|---|---|---|---|---|---|
0000 | C7 | RST 0 | Reset machine | |||
0008 | CF | RST 1 | RST 8 | Operating System Specific | ||
0010 | D7 | RST 2 | RST $10 | RST 16 | ||
0018 | DF | RST 3 | RST $18 | RST 24 | ||
0020 | E7 | RST 4 | RST $20 | RST 32 | ||
0028 | EF | RST 5 | RST $28 | RST 40 | ||
0030 | F7 | RST 6 | RST $30 | RST 48 | ||
0038 | FF | RST 7 | RST $38 | RST 56 | Interrupt Handler in Mode 1 |
Flags Affected
None. |
Opcode Matrix
Reset routine | ||||||||
---|---|---|---|---|---|---|---|---|
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
RST |
RST 0
C7111 |
RST 1
CF111 |
RST 2
D7111 |
RST 3
DF111 |
RST 4
E7111 |
RST 5
EF111 |
RST 6
F7111 |
RST 7
FF111 |
Instruction
Opcode hexSize bytesCycle count
| Special |