废除分支与常规分支有何不同? [英] How is an annulled branch different from a regular branch?

查看:88
本文介绍了废除分支与常规分支有何不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

特别是对于SPARC Assembly,废止分支与常规分支有何不同?

For SPARC Assembly particularly, how are annulled branches different from regular branches?

我一直认为,当我需要为分支指令填充nop延迟槽时,需要取消分支指令.但是,我认为这部分是不正确的,因为您可以在不取消分支的情况下填充nop.

I always thought that annulling branch instructions is required when I need to fill the nop delay slot for branch instructions. However, I don't think I'm correct on this part, because you can fill the nop without annulling the branch.

推荐答案

如果未采用分支,则无效的分支指令会导致延迟槽中的指令(分支后的指令)被忽略.

The annulled branch instruction causes the instruction in the delay slot -- the instruction after the branch -- to be ignored if the branch is not taken.

为什么这很重要?因为通常,即使采用分支,分支之后的指令也会执行.这是因为有两个程序计数器,即PC和NPC.在将NPC更新到分支指令的目标的同时,将指示正在执行的指令的PC更新为PC + 4的NPC.因此,由于这些事件的时间安排,必须加载下一条指令.与其抛弃这个循环,不如尽我们所能,使用该循环会更有利可图.然后,我们只需将该指令作为循环的一部分即可.

Why would this be important? Because normally, the instruction after the branch is executed, even if the branch is taken. This is because there are two program counters, PC and NPC. PC, which indicates the instruction being executed, is updated to NPC, which is PC + 4, at the same time as NPC is being updated to the target of the branch instruction. So because of the timing of these events, the next instruction has to be loaded. Rather than just throw that cycle away, it's more profitable to use that cycle if we can. We would then just make that instruction part of the loop.

loop:   someOp                
        someOtherOp
        branch      loop      ;
        delayslotOp           ; will actually be executed, before someOp, after branch

如果我们不能在分支之后使用指令槽,那么我们在其中插入一个nop,然后在该周期中不执行任何操作.

If we can't use the instruction slot after the branch, then we stick a nop in there, and do nothing on that cycle.

那么,为什么要使用带有空和非空分支选项的不同指令呢?让我们选择退出循环时会发生什么.如果我们将延迟槽作为循环活动的一部分,则可能不希望该操作在退出循环后执行.因此,我们将,a"添加到分支指令的末尾.

So why then have different instructions with annulled and non-annulled branch options? To give us the choice of what happens on exit from the loop. If we've made the delay slot part of the loop activity, we might not want that op executed upon leaving from the loop. Therefore, we'd add ",a" to the end of the branch instruction.

此页面提供了一些很好的示例.

这篇关于废除分支与常规分支有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆