分支指令是指由于执行分支指令而将执行切换到不同的指令序列的动作。
三种类型的分支指令是:
- 跳转(无条件和有条件)
- 致电(无条件和有条件)
- 回报(无条件和有条件)
1.跳转指令–跳转指令根据指定的标志将程序序列传送到操作数中给定的存储器地址。跳转指令有2种类型:无条件跳转指令和有条件跳转指令。
(a)无条件跳转指令:将程序序列传送到所描述的存储器地址。
OPCODE | OPERAND | EXPLANATION | EXAMPLE |
---|---|---|---|
JMP | address | Jumps to the address | JMP 2050 |
(b)条件跳转指令:仅在满足条件的情况下,才将程序序列传送到所描述的存储器地址。
OPCODE | OPERAND | EXPLANATION | EXAMPLE |
---|---|---|---|
JC | address | Jumps to the address if carry flag is 1 | JC 2050 |
JNC | address | Jumps to the address if carry flag is 0 | JNC 2050 |
JZ | address | Jumps to the address if zero flag is 1 | JZ 2050 |
JNZ | address | Jumps to the address if zero flag is 0 | JNZ 2050 |
JPE | address | Jumps to the address if parity flag is 1 | JPE 2050 |
JPO | address | Jumps to the address if parity flag is 0 | JPO 2050 |
JM | address | Jumps to the address if sign flag is 1 | JM 2050 |
JP | address | Jumps to the address if sign flag 0 | JP 2050 |
2.调用指令–调用指令将程序序列传送到操作数中给定的存储器地址。在传送之前,将CALL之后的下一条指令的地址压入堆栈。呼叫指令有2种类型:无条件呼叫指令和有条件呼叫指令。
(a)无条件调用指令:它将程序序列传送到操作数中给定的存储器地址。
OPCODE | OPERAND | EXPLANATION | EXAMPLE |
---|---|---|---|
CALL | address | Unconditionally calls | CALL 2050 |
(b)条件呼叫指令:只有满足条件时,指令才执行。
OPCODE | OPERAND | EXPLANATION | EXAMPLE |
---|---|---|---|
CC | address | Call if carry flag is 1 | CC 2050 |
CNC | address | Call if carry flag is 0 | CNC 2050 |
CZ | address | Calls if zero flag is 1 | CZ 2050 |
CNZ | address | Calls if zero flag is 0 | CNZ 2050 |
CPE | address | Calls if parity flag is 1 | CPE 2050 |
CPO | address | Calls if parity flag is 0 | CPO 2050 |
CM | address | Calls if sign flag is 1 | CM 2050 |
CP | address | Calls if sign flag is 0 | CP 2050 |
3.返回指令–返回指令将程序序列从子例程传送到调用程序。返回指令有2种类型:无条件跳转指令和条件跳转指令。
(a)无条件返回指令:程序序列无条件地从子例程传送到调用程序。
OPCODE | OPERAND | EXPLANATION | EXAMPLE |
---|---|---|---|
RET | none | Return from the subroutine unconditionally | RET |
(b)有条件的返回指令:只有在满足条件的情况下,程序序列才能无条件地从子例程传送到调用程序。
OPCODE | OPERAND | EXPLANATION | EXAMPLE |
---|---|---|---|
RC | none | Return from the subroutine if carry flag is 1 | RC |
RNC | none | Return from the subroutine if carry flag is 0 | RNC |
RZ | none | Return from the subroutine if zero flag is 1 | RZ |
RNZ | none | Return from the subroutine if zero flag is 0 | RNZ |
RPE | none | Return from the subroutine if parity flag is 1 | RPE |
RPO | none | Return from the subroutine if parity flag is 0 | RPO |
RM | none | Returns from the subroutine if sign flag is 1 | RM |
RP | none | Returns from the subroutine if sign flag is 0 | RP |