I'm developing a processor module for a specific microcontroller. There are cases, when instruction modifies some register (lets call it STATUS) indirectly. By indirectly, I mean, that STATUS is not one of the operands for this instruction. As an example, let's take
It basically rotates A left with Carry (C). C is part of STATUS register (just one bit). I cannot modify anything within the
ev_ana_insn callback as per IDA Pro documentation, so it looks like that:
def ev_ana_insn(self, insn): if b == 0x67: # rlc insn.size = 1 insn.itype = self.itype_rlc insn.Op1.type = ida_ua.o_reg insn.Op1.reg = self.ireg_A
That's fine. But in
ev_emu_insn I don't understand how and where should I modify the
STATUS register, since it is missing (and shouldn't be there in the first place) from
I had a couple of thoughts, but they are not good enough in my opinion:
Op1and save the information about needed changes to the
STATUSregister. But still, I need to make these changes and track them somewhere during the analysis and emulation stages.
- Map the
STATUSregister to RAM segment and modify it there. Here as example of such an implementation: https://github.com/Treeki/TM155-tools/blob/master/ida-module/ht68fb560.py#L470, but I don't know if it's the correct approach.
- Put another
insn, assign it to the
STATUSregister and modify it during the emulation stage. However, this approach breaks the whole disassembler, since it expects 2 operands, but really there is only 1. I can play around with that during the output stage, but I don't think that it is a correct approach and is more like a hack.
So, any input is much appreciated.