Ejemplo n.º 1
0
        private void RewriteRra(string flags)
        {
            var src = RewriteOp(instr.Operands[0]);
            var dst = RewriteDst(instr.Operands[0], src, (a, b) => m.Sar(a, m.Byte(1)));

            EmitCc(dst, flags);
        }
Ejemplo n.º 2
0
        private void RewriteRotation(string pseudoOp, bool useCarry)
        {
            Expression reg;

            if (dasm.Current.Operands.Length > 0)
            {
                reg = RewriteOp(dasm.Current.Operands[0]);
            }
            else
            {
                reg = binder.EnsureRegister(Registers.a);
            }
            var        C   = FlagGroup(FlagM.CF);
            var        one = m.Byte(1);
            Expression src;

            if (useCarry)
            {
                src = host.PseudoProcedure(pseudoOp, reg.DataType, reg, one, C);
            }
            else
            {
                src = host.PseudoProcedure(pseudoOp, reg.DataType, reg, one);
            }
            m.Assign(reg, src);
            m.Assign(C, m.Cond(reg));
        }
Ejemplo n.º 3
0
        private void RewriteRotate(IntrinsicProcedure rot)
        {
            var op = Operand(instr.Operands[0]);
            var C  = binder.EnsureFlagGroup(arch.GetFlagGroup(arch.st, (uint)FlagM.CF));

            m.Assign(op, m.Fn(rot, op, m.Byte(1)));
            m.Assign(C, m.Cond(op));
        }
Ejemplo n.º 4
0
        private void RewriteRra()
        {
            var src = RewriteOp(instr.Operands[0]);
            var dst = RewriteDst(instr.Operands[0], src, (a, b) => m.Sar(a, m.Byte(1)));

            EmitCc(dst, Registers.NZC);
            Assign(Registers.V, Constant.False());
        }
Ejemplo n.º 5
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (instrs.MoveNext())
            {
                var instr = instrs.Current;
                this.rtlCluster       = new RtlInstructionCluster(instr.Address, instr.Length);
                this.rtlCluster.Class = RtlClass.Linear;
                emitter = new RtlEmitter(rtlCluster.Instructions);
                Expression src;
                Expression dst;
                switch (instr.Opcode)
                {
                default: throw new AddressCorrelatedException(
                              instr.Address,
                              "Rewriting of PDP-11 instruction {0} not supported yet.", instr.Opcode);

                case Opcodes.clrb:
                    dst = RewriteDst(instr.op1, emitter.Byte(0), s => s);
                    SetFlags(dst, 0, FlagM.NF | FlagM.CF | FlagM.VF, FlagM.ZF);
                    break;

                case Opcodes.mov:
                    src = RewriteSrc(instr.op1);
                    dst = RewriteDst(instr.op2, src, s => s);
                    SetFlags(dst, FlagM.ZF | FlagM.NF, FlagM.VF, 0);
                    break;

                case Opcodes.movb:
                    src = RewriteSrc(instr.op1);
                    dst = RewriteDst(instr.op2, src, s => emitter.Cast(PrimitiveType.Int16, s));
                    SetFlags(dst, FlagM.ZF | FlagM.NF, FlagM.VF, 0);
                    break;

                case Opcodes.xor:
                    src = RewriteSrc(instr.op1);
                    dst = RewriteDst(instr.op2, src, (s, d) => emitter.Xor(d, s));
                    SetFlags(dst, FlagM.ZF | FlagM.NF, FlagM.CF | FlagM.VF, 0);
                    break;
                }
                yield return(rtlCluster);
            }
        }
Ejemplo n.º 6
0
        private void RewriteRotate(string rot)
        {
            var dst = OpSrc(instr.Operand1);

            m.Assign(dst, host.PseudoProcedure(rot, dst.DataType, dst, m.Byte(1)));
        }
Ejemplo n.º 7
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (instrs.MoveNext())
            {
                var instr = instrs.Current;
                this.rtlCluster       = new RtlInstructionCluster(instr.Address, instr.Length);
                this.rtlCluster.Class = RtlClass.Linear;
                m = new RtlEmitter(rtlCluster.Instructions);
                switch (instr.Opcode)
                {
                default: throw new AddressCorrelatedException(
                              instr.Address,
                              "Rewriting of PDP-11 instruction {0} not supported yet.", instr.Opcode);

                case Opcode.adc: RewriteAdc(instr); break;

                case Opcode.add: RewriteAdd(instr); break;

                case Opcode.addb: RewriteAdd(instr); break;

                case Opcode.ash: RewriteShift(instr); break;

                case Opcode.asl: RewriteAsl(instr); break;

                case Opcode.asr: RewriteAsr(instr); break;

                case Opcode.bcc: RewriteBxx(instr, ConditionCode.UGE, FlagM.CF); break;

                case Opcode.bcs: RewriteBxx(instr, ConditionCode.ULT, FlagM.CF); break;

                case Opcode.beq: RewriteBxx(instr, ConditionCode.EQ, FlagM.ZF); break;

                case Opcode.bge: RewriteBxx(instr, ConditionCode.GE, FlagM.VF | FlagM.NF); break;

                case Opcode.bgt: RewriteBxx(instr, ConditionCode.GT, FlagM.ZF | FlagM.NF | FlagM.VF); break;

                case Opcode.bhi: RewriteBxx(instr, ConditionCode.UGT, FlagM.ZF | FlagM.CF); break;

                case Opcode.bic: RewriteBic(instr); break;

                case Opcode.bis: RewriteBis(instr); break;

                case Opcode.bisb: RewriteBis(instr); break;

                case Opcode.bit: RewriteBit(instr); break;

                case Opcode.bitb: RewriteBit(instr); break;

                case Opcode.ble: RewriteBxx(instr, ConditionCode.LE, FlagM.ZF | FlagM.NF | FlagM.VF); break;

                case Opcode.blos: RewriteBxx(instr, ConditionCode.ULE, FlagM.ZF | FlagM.CF); break;

                case Opcode.blt: RewriteBxx(instr, ConditionCode.LT, FlagM.NF | FlagM.VF); break;

                case Opcode.bmi: RewriteBxx(instr, ConditionCode.LT, FlagM.NF); break;

                case Opcode.bne: RewriteBxx(instr, ConditionCode.NE, FlagM.ZF); break;

                case Opcode.bpl: RewriteBxx(instr, ConditionCode.GT, FlagM.NF); break;

                case Opcode.br: RewriteBr(instr); break;

                case Opcode.clr: RewriteClr(instr, m.Word16(0)); break;

                case Opcode.clrb: RewriteClr(instr, m.Byte(0)); break;

                case Opcode.cmp: RewriteCmp(instr); break;

                case Opcode.com: RewriteCom(instr); break;

                case Opcode.dec: RewriteIncDec(instr, m.ISub); break;

                case Opcode.div: RewriteDiv(instr); break;

                case Opcode.emt: RewriteEmt(instr); break;

                case Opcode.halt: RewriteHalt(); break;

                case Opcode.inc: RewriteIncDec(instr, m.IAdd); break;

                case Opcode.jmp: RewriteJmp(instr); break;

                case Opcode.jsr: RewriteJsr(instr); break;

                case Opcode.mov: RewriteMov(instr); break;

                case Opcode.movb: RewriteMov(instr); break;

                case Opcode.neg: RewriteNeg(instr); break;

                case Opcode.nop: m.Nop(); break;

                case Opcode.reset: RewriteReset(); break;

                case Opcode.rol: RewriteRol(instr); break;

                case Opcode.rts: RewriteRts(instr); break;

                case Opcode.sub: RewriteSub(instr); break;

                case Opcode.sxt: RewriteSxt(instr); break;

                case Opcode.trap: RewriteTrap(instr); break;

                case Opcode.tst: RewriteTst(instr); break;

                case Opcode.tstb: RewriteTst(instr); break;

                case Opcode.wait: RewriteWait(); break;

                case Opcode.xor: RewriteXor(instr); break;
                }
                yield return(rtlCluster);
            }
        }
Ejemplo n.º 8
0
        private void RewriteRotate(IntrinsicProcedure rot)
        {
            var dst = OpSrc(instr.Operands[0], arch.DataMemory);

            m.Assign(dst, m.Fn(rot, dst, m.Byte(1)));
        }