| 198 | |
| 199 | |
| 200 | static bool LiftConditionalBranch(LowLevelILFunction& il, uint8_t bo, uint8_t bi, BNLowLevelILLabel& takenLabel, BNLowLevelILLabel& falseLabel, size_t addressSize_a=4) |
| 201 | { |
| 202 | bool testsCtr = !(bo & 4); |
| 203 | bool testsCrBit = !(bo & 0x10); |
| 204 | bool isConditional = testsCtr || testsCrBit; |
| 205 | |
| 206 | if (testsCtr) |
| 207 | { |
| 208 | ExprId cond, left, right; |
| 209 | |
| 210 | il.AddInstruction( |
| 211 | il.SetRegister(addressSize_a, PPC_REG_CTR, |
| 212 | il.Sub(addressSize_a, |
| 213 | il.Register(addressSize_a, PPC_REG_CTR), |
| 214 | il.Const(addressSize_a, 1)))); |
| 215 | |
| 216 | left = il.Register(addressSize_a, PPC_REG_CTR); |
| 217 | right = il.Const(addressSize_a, 0); |
| 218 | |
| 219 | if (bo & 2) |
| 220 | cond = il.CompareEqual(addressSize_a, left, right); |
| 221 | else |
| 222 | cond = il.CompareNotEqual(addressSize_a, left, right); |
| 223 | |
| 224 | if (!testsCrBit) |
| 225 | { |
| 226 | il.AddInstruction(il.If(cond, takenLabel, falseLabel)); |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | LowLevelILLabel trueLabel; |
| 231 | il.AddInstruction(il.If(cond, trueLabel, falseLabel)); |
| 232 | il.MarkLabel(trueLabel); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | if (testsCrBit) |
| 237 | { |
| 238 | ExprId cond = ExtractConditionClause(il, bi, !(bo & 8)); |
| 239 | il.AddInstruction(il.If(cond, takenLabel, falseLabel)); |
| 240 | } |
| 241 | |
| 242 | return isConditional; |
| 243 | } |
| 244 | |
| 245 | static bool LiftBranches(Architecture* arch, LowLevelILFunction &il, const uint8_t* data, uint64_t addr, bool le) |
| 246 | { |
no test coverage detected