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

Function DecodeCPSInstruction

arch/ARM/ARMDisassembler.c:2153–2199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2151}
2152
2153static DecodeStatus DecodeCPSInstruction(MCInst *Inst, unsigned Insn,
2154 uint64_t Address, const void *Decoder)
2155{
2156 unsigned imod = fieldFromInstruction_4(Insn, 18, 2);
2157 unsigned M = fieldFromInstruction_4(Insn, 17, 1);
2158 unsigned iflags = fieldFromInstruction_4(Insn, 6, 3);
2159 unsigned mode = fieldFromInstruction_4(Insn, 0, 5);
2160
2161 DecodeStatus S = MCDisassembler_Success;
2162
2163 // This decoder is called from multiple location that do not check
2164 // the full encoding is valid before they do.
2165 if (fieldFromInstruction_4(Insn, 5, 1) != 0 ||
2166 fieldFromInstruction_4(Insn, 16, 1) != 0 ||
2167 fieldFromInstruction_4(Insn, 20, 8) != 0x10)
2168 return MCDisassembler_Fail;
2169
2170 // imod == '01' --> UNPREDICTABLE
2171 // NOTE: Even though this is technically UNPREDICTABLE, we choose to
2172 // return failure here. The '01' imod value is unprintable, so there's
2173 // nothing useful we could do even if we returned UNPREDICTABLE.
2174
2175 if (imod == 1) return MCDisassembler_Fail;
2176
2177 if (imod && M) {
2178 MCInst_setOpcode(Inst, ARM_CPS3p);
2179 MCOperand_CreateImm0(Inst, imod);
2180 MCOperand_CreateImm0(Inst, iflags);
2181 MCOperand_CreateImm0(Inst, mode);
2182 } else if (imod && !M) {
2183 MCInst_setOpcode(Inst, ARM_CPS2p);
2184 MCOperand_CreateImm0(Inst, imod);
2185 MCOperand_CreateImm0(Inst, iflags);
2186 if (mode) S = MCDisassembler_SoftFail;
2187 } else if (!imod && M) {
2188 MCInst_setOpcode(Inst, ARM_CPS1p);
2189 MCOperand_CreateImm0(Inst, mode);
2190 if (iflags) S = MCDisassembler_SoftFail;
2191 } else {
2192 // imod == '00' && M == '0' --> UNPREDICTABLE
2193 MCInst_setOpcode(Inst, ARM_CPS1p);
2194 MCOperand_CreateImm0(Inst, mode);
2195 S = MCDisassembler_SoftFail;
2196 }
2197
2198 return S;
2199}
2200
2201static DecodeStatus DecodeT2CPSInstruction(MCInst *Inst, unsigned Insn,
2202 uint64_t Address, const void *Decoder)

Callers 3

DecodeQADDInstructionFunction · 0.85
DecodeSMLAInstructionFunction · 0.85
DecodeSwapFunction · 0.85

Calls 2

MCInst_setOpcodeFunction · 0.85
MCOperand_CreateImm0Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…