MCPcopy Create free account
hub / github.com/capstone-engine/capstone / DecodeBitfieldMaskOperand

Function DecodeBitfieldMaskOperand

arch/ARM/ARMDisassembler.c:1423–1450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1421}
1422
1423static DecodeStatus DecodeBitfieldMaskOperand(MCInst *Inst, unsigned Val,
1424 uint64_t Address, const void *Decoder)
1425{
1426 // This operand encodes a mask of contiguous zeros between a specified MSB
1427 // and LSB. To decode it, we create the mask of all bits MSB-and-lower,
1428 // the mask of all bits LSB-and-lower, and then xor them to create
1429 // the mask of that's all ones on [msb, lsb]. Finally we not it to
1430 // create the final mask.
1431 unsigned msb = fieldFromInstruction_4(Val, 5, 5);
1432 unsigned lsb = fieldFromInstruction_4(Val, 0, 5);
1433 uint32_t lsb_mask, msb_mask;
1434
1435 DecodeStatus S = MCDisassembler_Success;
1436 if (lsb > msb) {
1437 Check(&S, MCDisassembler_SoftFail);
1438 // The check above will cause the warning for the "potentially undefined
1439 // instruction encoding" but we can't build a bad MCOperand value here
1440 // with a lsb > msb or else printing the MCInst will cause a crash.
1441 lsb = msb;
1442 }
1443
1444 msb_mask = 0xFFFFFFFF;
1445 if (msb != 31) msb_mask = (1U << (msb + 1)) - 1;
1446 lsb_mask = (1U << lsb) - 1;
1447
1448 MCOperand_CreateImm0(Inst, ~(msb_mask ^ lsb_mask));
1449 return S;
1450}
1451
1452static DecodeStatus DecodeCopMemInstruction(MCInst *Inst, unsigned Insn,
1453 uint64_t Address, const void *Decoder)

Callers

nothing calls this directly

Calls 2

MCOperand_CreateImm0Function · 0.85
CheckFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…