Пример #1
0
 public WE32100Rewriter(WE32100Architecture arch, EndianImageReader rdr, ProcessorState state, IStorageBinder binder, IRewriterHost host)
 {
     this.arch   = arch;
     this.rdr    = rdr;
     this.state  = state;
     this.binder = binder;
     this.host   = host;
     this.dasm   = new WE32100Disassembler(arch, rdr).GetEnumerator();
     this.instr  = null !;
     this.m      = null !;
 }
Пример #2
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                var rtls = new List <RtlInstruction>();
                m           = new RtlEmitter(rtls);
                this.iclass = instr.InstructionClass;
                switch (instr.Mnemonic)
                {
                default:
                    host.Error(instr.Address, $"WE32100 instruction '{instr}' is not supported yet.");
                    EmitUnitTest();
                    goto case Mnemonic.invalid;

                case Mnemonic.invalid:
                    m.Invalid(); iclass = InstrClass.Invalid; break;

                case Mnemonic.addb2: RewriteArithmetic2(m.IAdd, PrimitiveType.Byte); break;

                case Mnemonic.addh2: RewriteArithmetic2(m.IAdd, PrimitiveType.Word16); break;

                case Mnemonic.addw2: RewriteArithmetic2(m.IAdd, PrimitiveType.Word32); break;

                case Mnemonic.addb3: RewriteArithmetic3(m.IAdd, PrimitiveType.Byte); break;

                case Mnemonic.addh3: RewriteArithmetic3(m.IAdd, PrimitiveType.Word16); break;

                case Mnemonic.addw3: RewriteArithmetic3(m.IAdd, PrimitiveType.Word32); break;

                case Mnemonic.dech: RewriteUnary(e => m.ISub(e, 1), PrimitiveType.Word16, NZVC); break;

                case Mnemonic.movb: RewriteMov(PrimitiveType.Byte); break;

                case Mnemonic.xorb2: RewriteLogical2(m.Xor, PrimitiveType.Byte); break;

                case Mnemonic.xorh2: RewriteLogical2(m.Xor, PrimitiveType.Word16); break;

                case Mnemonic.xorw2: RewriteLogical2(m.Xor, PrimitiveType.Word32); break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));
            }
        }