[英]How does the branch register work in ppc64le?
How does the branch register work in ppc64le? 分支寄存器如何在ppc64le中工作?
I have the following code in armv8
-- br x19
or in armv7
-- bx r4
我在armv8
- br x19
或armv7
- bx r4
有以下代码
What is equivalent in ppc64le
for it? 什么在ppc64le
等同于它?
Would just the b r4
work or I will have to mflr r4 mr r0, r5 mtlr r4 blr
只是b r4
工作或我将不得不mflr r4 mr r0, r5 mtlr r4 blr
It sounds like what you want to do is an indirect branch. 听起来你想做的是间接分支。 There's a couple of facilites for this on Power - the counter register, and the link register. Power上有几个设备 - 计数器寄存器和链接寄存器。
The link register is traditionally used for the return address when calling a function. 链接寄存器传统上用于调用函数时的返回地址。 So for example, if you have a function in asm, you might do something like: 例如,如果你在asm中有一个函数,你可能会这样做:
.my_func
// save r31 to the stack
...
mflr r31 // save off link register
...
bl .another_function // branch, setting the link register
nop // control will return here
...
mtlr r31 // restore LR
// restore r31 from stack
blr // branch to LR, exiting the function
If you want to do the sort of indirect branch you're talking about in your question, you'd probably want to use the counter register. 如果你想在你的问题中谈论你所讨论的那种间接分支,你可能想要使用计数器寄存器。 The counter register is often used for loops (hence the name) but is also very useful for indirect branches. 计数器寄存器通常用于循环(因此名称),但对间接分支也非常有用。 If you're branching within a function: 如果你在一个函数内分支:
mtctr r4 // r4 - address you want to go to
bctr // unconditional branch to contents of ctr
If you want to do an indirect branch to another function, you want your branch to also set the link register: 如果要对另一个函数进行间接分支,则希望分支也设置链接寄存器:
mtctr r4
bctrl // branch to counter, setting link register
Two critical references you'll want are: 您需要的两个关键参考是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.