@@ -328,6 +328,22 @@ static DecodeStatus decodeCondBranch(MCInst &Inst, unsigned Insn,
328328 return MCDisassembler::Success;
329329}
330330
331+ static DecodeStatus decodeAddWordImm (MCInst &Inst, unsigned Insn,
332+ uint64_t Address,
333+ const MCDisassembler *Decoder) {
334+ // Get the register
335+ unsigned RegVal = GPRDecoderTable[24 + 2 * ((Insn >> 4 ) & 0x3 )];
336+
337+ if ((Insn & 0xff00 ) == 0x9600 ) {
338+ Inst.setOpcode (AVR::ADIWRdK);
339+ Inst.addOperand (MCOperand::createReg (RegVal));
340+ Inst.addOperand (
341+ MCOperand::createImm (((Insn & 0x00C0 ) >> 2 ) | (Insn & 0xF )));
342+ return MCDisassembler::Success;
343+ }
344+ return MCDisassembler::Fail;
345+ }
346+
331347static DecodeStatus decodeMoveWord (MCInst &Inst, unsigned Insn,
332348 uint64_t Address,
333349 const MCDisassembler *Decoder) {
@@ -522,6 +538,11 @@ DecodeStatus AVRDisassembler::getInstruction(MCInst &Instr, uint64_t &Size,
522538 Result = decodeMoveWord (Instr, Insn, Address, this );
523539 if (Result != MCDisassembler::Fail)
524540 return Result;
541+
542+ // Try to decode to a ADIW instruction
543+ Result = decodeAddWordImm (Instr, Insn, Address, this );
544+ if (Result != MCDisassembler::Fail)
545+ return Result;
525546
526547 // Try to decode to a load/store instruction. ST/LD need a specified
527548 // DecoderMethod, as they already have a specified PostEncoderMethod.
0 commit comments