MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / ByteReverseRegister

Function ByteReverseRegister

arch/powerpc/il.cpp:426–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424
425
426static ExprId ByteReverseRegister(LowLevelILFunction &il, uint32_t reg, size_t size)
427{
428 ExprId swap = BN_INVALID_EXPR;
429
430 for (size_t srcIndex = 0; srcIndex < size; srcIndex++)
431 {
432 ExprId extracted = il.Register(4, reg);
433 size_t dstIndex = size - srcIndex - 1;
434
435 if (dstIndex > srcIndex)
436 {
437 ExprId mask = il.Const(4, 0xffull << (srcIndex * 8));
438 extracted = il.And(4, extracted, mask);
439 extracted = il.ShiftLeft(4, extracted, il.Const(4, (dstIndex - srcIndex) * 8));
440 }
441 else if (srcIndex > dstIndex)
442 {
443 ExprId mask = il.Const(4, 0xffull << (dstIndex * 8));
444 extracted = il.LogicalShiftRight(4, extracted, il.Const(4, (srcIndex - dstIndex) * 8));
445 extracted = il.And(4, extracted, mask);
446 }
447
448 if (swap == BN_INVALID_EXPR)
449 swap = extracted;
450 else
451 swap = il.Or(4, swap, extracted);
452 }
453
454 return swap;
455}
456
457
458static void ByteReversedLoad(LowLevelILFunction &il, struct cs_ppc* ppc, size_t size, size_t addressSize_a=4)

Callers 2

ByteReversedLoadFunction · 0.85
ByteReversedStoreFunction · 0.85

Calls 6

RegisterMethod · 0.45
ConstMethod · 0.45
AndMethod · 0.45
ShiftLeftMethod · 0.45
LogicalShiftRightMethod · 0.45
OrMethod · 0.45

Tested by

no test coverage detected