Closed FrazzleDancer closed 1 year ago
you need to be more specific for which instruction you're talking about in SLEIGH and the manual. p39 only discusses bctar
and bctarl
which is implemented in ppc_isa.sinc and does not use the variables you provided as the faulty SLEIGH.
Are you sure you're using the right language settings?
All of the "branch conditional and link" instructions are affected; in the 2015 manual, they are
In the Sleigh file ppc_instructions.sinc, they are
The discrepency is evident in this screencap of (on the left) part of ppc_instructions.sinc and (on the right) the 2015 IBM PowerISA Version 3.0 manual:
Sleigh for PowerPC branches where CC & LK=1 or CTR_DEC & LK=1 use code like
which sets the link register to the address of the following instruction only if the branch is taken; but IBM's "Power ISATM Version 3.0"'s description of "Branch Conditional B-form" (p. 39) is
which sets the link register to the address of the following instruction regardless of whether the branch is taken; this is supported by the subsequent text, which states without qualification that if LK=1, the effective address of the next instruction is placed into the link register. I have seen production code that relies upon this peculiarity. I believe where LK=1, the line "LR = inst_next;" should be the first line of the body, preceding the conditional test.
[Apologies for the appearance of the sup and sub tags in the quote of the IBM manual; I avoided back-ticks around that in the hopes that the tags would render correctly, but apparently GitHub is too smart for that.]