示例#1
0
 public Msp430Rewriter(Msp430Architecture arch, EndianImageReader rdr, ProcessorState state, IStorageBinder binder, IRewriterHost host)
 {
     this.arch   = arch;
     this.state  = state;
     this.binder = binder;
     this.host   = host;
     this.rdr    = rdr;
     this.dasm   = new Msp430Disassembler(arch, rdr).GetEnumerator();
     this.instr  = null !;
     this.m      = null !;
 }
示例#2
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                var instrs = new List <RtlInstruction>();
                this.m      = new RtlEmitter(instrs);
                this.iclass = InstrClass.Linear;
                switch (instr.Mnemonic)
                {
                case Mnemonics.invalid: Invalid(); break;

                default:
                    EmitUnitTest();
                    Invalid();
                    break;

                case Mnemonics.addc: RewriteAdcSbc(m.IAdd); break;

                case Mnemonics.add: RewriteBinop(m.IAdd, "V-----NZC"); break;

                case Mnemonics.and: RewriteBinop(m.And, "0-----NZC"); break;

                case Mnemonics.bic: RewriteBinop(Bis, "---------"); break;

                case Mnemonics.bis: RewriteBinop(m.Or, "---------"); break;

                case Mnemonics.bit: RewriteBit(); break;

                case Mnemonics.br: RewriteBr(); break;

                case Mnemonics.call: RewriteCall(); break;

                case Mnemonics.cmp: RewriteCmp(); break;

                case Mnemonics.dadd: RewriteBinop(Dadd, "------NZC"); break;

                case Mnemonics.jc:  RewriteBranch(ConditionCode.ULT, FlagM.CF); break;

                case Mnemonics.jge: RewriteBranch(ConditionCode.GE, FlagM.VF | FlagM.NF); break;

                case Mnemonics.jl:  RewriteBranch(ConditionCode.LT, FlagM.VF | FlagM.NF); break;

                case Mnemonics.jmp: RewriteGoto(); break;

                case Mnemonics.jn:  RewriteBranch(ConditionCode.SG, FlagM.NF); break;

                case Mnemonics.jnc: RewriteBranch(ConditionCode.UGE, FlagM.CF); break;

                case Mnemonics.jnz: RewriteBranch(ConditionCode.NE, FlagM.ZF); break;

                case Mnemonics.jz:  RewriteBranch(ConditionCode.EQ, FlagM.ZF); break;

                case Mnemonics.mov: RewriteBinop((a, b) => b, ""); break;

                case Mnemonics.mova: RewriteBinop((a, b) => b, ""); break;

                case Mnemonics.popm: RewritePopm(); break;

                case Mnemonics.push: RewritePush(); break;

                case Mnemonics.pushm: RewritePushm(); break;

                case Mnemonics.ret: RewriteRet(); break;

                case Mnemonics.reti: RewriteReti(); break;

                case Mnemonics.rra: RewriteRra("0-----NZC"); break;

                case Mnemonics.rrax: RewriteRrax("0-----NZC"); break;

                case Mnemonics.rrc: RewriteRrc("0-----NZC"); break;

                case Mnemonics.rrum: RewriteRrum("0-----NZC"); break;

                case Mnemonics.sub: RewriteBinop(m.ISub, "V-----NZC"); break;

                case Mnemonics.subc: RewriteAdcSbc(m.ISub); break;

                case Mnemonics.swpb: RewriteSwpb(); break;

                case Mnemonics.sxt: RewriteSxt("0-----NZC"); break;

                case Mnemonics.xor: RewriteBinop(m.Xor, "V-----NZC"); break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));
            }
        }