# mips延迟槽bnez和bnezl的区别

80031DB8  bnez    $v0, loc_80031F58 80031DBC move$v0, $zero 例如如上的指令。 BNEZ是branch not equal to zero 当BNEZ进入执行阶段还没有执行时，move进入译码还没有执行的阶段 当BNEZ执行完毕后（此时的V0是之前的V0）。move译码完毕，接下来一定能够执行。 因此不管BNEZ跳不跳转。V0都将会被修改为0 这是bnez. 而BNEZL是 branch not equal to zero likely 这个likely文章大了。likely表示可能性高。unlikely表示可能性低。 对于BNEZL则不是这样。 80031DB8 bnezl$v0, loc_80031F58
80031DBC  move    $v0,$zero
bnezl表示必须要跳转成立。下面一条延迟槽才会被执行。

https://www.math.ku.edu/computing/cluster/totalview.6.0.0-0-doc/ref_guide/architectures29.html

## MIPS Delay Slot Instructions

On the MIPS architecture, jump and branch instructions have a "delay slot". This means that the instruction after the jump or branch instruction is executed before the jump or branch is executed.

In addition, there is a group of "branch likely" conditional branch instructions in which the instruction in the delay slot is executed only if the branch is taken.

The MIPS processors execute the jump or branch instruction and the delay slot instruction as an indivisible unit. If an exception occurs as a result of executing the delay slot instruction, the branch or jump instruction is not executed, and the exception appears to have been caused by the jump or branch instruction.

This behavior of the MIPS processors affects both the TotalView instruction step command and TotalView breakpoints.

The TotalView instruction step command will step both the jump or branch instruction and the delay slot instruction as if they were a single instruction.

If a breakpoint is placed on a delay slot instruction, execution will stop at the jump or branch preceding the delay slot instruction, and TotalView will not know that it is at a breakpoint. At this point, attempting to continue the thread that hit the breakpoint without first removing the breakpoint will cause the thread to hit the breakpoint again without executing any instructions. Before continuing the thread, you must remove the breakpoint. If you need to reestablish the breakpoint, you might then use the instruction step command to execute just the delay slot instruction and the branch.

A breakpoint placed on a delay slot instruction of a branch likely instruction will be hit only if the branch is going to be taken.

12-25

04-08 1744
09-19 2920
09-30 1万+
03-12 2156
09-12 477
11-04 1665
06-18 1万+
10-31 323
02-25 2万+
06-09