分支寄存器在ppc64le中是如何工作的?
我在armv8 --br x19或armv7 -- bx r4中有以下代码
在ppc64le中它的等价物是什么?
只能使用b r4,否则我将不得不使用mflr r4 mr r0, r5 mtlr r4 blr
发布于 2016-10-13 08:52:52
听起来你想做的是一个间接的分支。Power上有几个工具--计数器寄存器和链接寄存器。
传统上,链接寄存器用于调用函数时的返回地址。因此,例如,如果您在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如果你想做你在问题中提到的那种间接分支,你可能会想要使用计数器寄存器。计数器寄存器通常用于循环(因此而得名),但对于间接分支也非常有用。如果你在一个函数中进行分支:
mtctr r4 // r4 - address you want to go to
bctr // unconditional branch to contents of ctr如果要对另一个函数进行间接分支,则希望分支也设置链接寄存器:
mtctr r4
bctrl // branch to counter, setting link register你需要的两个关键参考资料是:
https://stackoverflow.com/questions/40008483
复制相似问题