示例#1
0
        private static bool PcRel(uint wOpcode, Pdp11Disassembler dasm)
        {
            var uAddr = (int)dasm.rdr.Address.ToLinear() + 2 * (sbyte)(wOpcode & 0xFF);

            dasm.ops.Add(new AddressOperand(Address.Ptr16((ushort)uAddr)));
            return(true);
        }
示例#2
0
            public override Pdp11Instruction Decode(ushort opcode, Pdp11Disassembler dasm)
            {
                foreach (var m in mutators)
                {
                    if (!m(opcode, dasm))
                    {
                        return new Pdp11Instruction
                               {
                                   Opcode = Opcode.illegal,
                                   IClass = InstrClass.Invalid,
                               }
                    }
                    ;
                }
                var instr = new Pdp11Instruction
                {
                    Opcode    = this.opcode,
                    IClass    = iclass,
                    DataWidth = dasm.dataWidth,
                    op1       = dasm.ops.Count > 0 ? dasm.ops[0] : null,
                    op2       = dasm.ops.Count > 1 ? dasm.ops[1] : null,
                };

                return(instr);
            }
        }
示例#3
0
        // I4 - low order 4 bits.
        private static bool I4(uint wOpcode, Pdp11Disassembler dasm)
        {
            var op = ImmediateOperand.Byte((byte)(wOpcode & 0x0F));

            dasm.ops.Add(op);
            return(true);
        }
示例#4
0
        private static bool I(uint wOpcode, Pdp11Disassembler dasm)
        {
            var op = dasm.Imm6((ushort)wOpcode);

            dasm.ops.Add(op);
            return(true);
        }
示例#5
0
        private static bool r(uint wOpcode, Pdp11Disassembler dasm)
        {
            var op = new RegisterOperand(dasm.arch.GetRegister(((int)wOpcode >> 6) & 7));

            dasm.ops.Add(op);
            return(true);
        }
示例#6
0
        private static bool f(uint wOpcode, Pdp11Disassembler dasm)
        {
            var op = dasm.FpuAccumulator(wOpcode);

            if (op == null)
            {
                return(false);
            }
            dasm.ops.Add(op);
            return(true);
        }
示例#7
0
        private static bool F(uint wOpcode, Pdp11Disassembler dasm)
        {
            var op = dasm.DecodeOperand(wOpcode, true);

            if (op == null)
            {
                return(false);
            }
            dasm.ops.Add(op);
            return(true);
        }
示例#8
0
            public override Pdp11Instruction Decode(uint uInstr, Pdp11Disassembler dasm)
            {
                foreach (var m in mutators)
                {
                    if (!m(uInstr, dasm))
                    {
                        return(dasm.CreateInvalidInstruction());
                    }
                }
                var instr = new Pdp11Instruction
                {
                    Mnemonic         = this.opcode,
                    InstructionClass = iclass,
                    DataWidth        = dasm.dataWidth,
                    Operands         = dasm.ops.ToArray()
                };

                return(instr);
            }
示例#9
0
 private static MachineOperand Reg(int bits, Pdp11Disassembler dasm)
 {
     return(new RegisterOperand(dasm.arch.GetRegister(bits & 7)));
 }
示例#10
0
        private static Pdp11Instruction NonDoubleOperandInstruction(ushort opcode, Pdp11Disassembler dasm)
        {
            switch ((opcode >> 8))
            {
            case 0x01: return(dasm.BranchInstruction(opcode, Opcode.br));

            case 0x02: return(dasm.BranchInstruction(opcode, Opcode.bne));

            case 0x03: return(dasm.BranchInstruction(opcode, Opcode.beq));

            case 0x04: return(dasm.BranchInstruction(opcode, Opcode.bge));

            case 0x05: return(dasm.BranchInstruction(opcode, Opcode.blt));

            case 0x06: return(dasm.BranchInstruction(opcode, Opcode.bgt));

            case 0x07: return(dasm.BranchInstruction(opcode, Opcode.ble));

            case 0x80: return(dasm.BranchInstruction(opcode, Opcode.bpl));

            case 0x81: return(dasm.BranchInstruction(opcode, Opcode.bmi));

            case 0x82: return(dasm.BranchInstruction(opcode, Opcode.bhi));

            case 0x83: return(dasm.BranchInstruction(opcode, Opcode.blos));

            case 0x84: return(dasm.BranchInstruction(opcode, Opcode.bvc));

            case 0x85: return(dasm.BranchInstruction(opcode, Opcode.bvs));

            case 0x86: return(dasm.BranchInstruction(opcode, Opcode.bcc));

            case 0x87: return(dasm.BranchInstruction(opcode, Opcode.bcs));
            }

            var            dataWidth = dasm.DataWidthFromSizeBit(opcode & 0x8000u);
            int            cop       = 1;
            MachineOperand op1       = null;
            MachineOperand op2       = null;
            Opcode         oc        = Opcode.illegal;

            switch ((opcode >> 6) & 0x3FF)
            {
            case 0x000:
                switch (opcode & 0x3F)
                {
                case 0x00: cop = 0; oc = Opcode.halt; break;

                case 0x01: cop = 0; oc = Opcode.wait; break;

                case 0x02: cop = 0; oc = Opcode.rti; break;

                case 0x03: cop = 0; oc = Opcode.bpt; break;

                case 0x04: cop = 0; oc = Opcode.iot; break;

                case 0x05: cop = 0; oc = Opcode.reset; break;

                case 0x06: cop = 0; oc = Opcode.rtt; break;

                case 0x07: cop = 0; oc = Opcode.illegal; break;
                }
                break;

            case 0x001: op1 = dasm.DecodeOperand(opcode); oc = Opcode.jmp; break;

            case 0x002:
                switch (opcode & 0x38)
                {
                case 0: op1 = dasm.DecodeOperand(opcode & 7); oc = Opcode.rts; break;

                case 3: op1 = dasm.DecodeOperand(opcode); oc = Opcode.spl; break;

                case 0x20:
                case 0x28:
                case 0x30:
                case 0x38:
                    return(dasm.DecodeCondCode(opcode));
                }
                break;

            case 0x003:
                oc        = Opcode.swab; op1 = dasm.DecodeOperand(opcode);
                dataWidth = PrimitiveType.Byte;
                break;

            case 0x020:
            case 0x021:
            case 0x022:
            case 0x023:
            case 0x024:
            case 0x025:
            case 0x026:
            case 0x027:
                oc        = Opcode.jsr;
                cop       = 2;
                op1       = Reg(opcode >> 6, dasm);
                op2       = dasm.DecodeOperand(opcode);
                dataWidth = PrimitiveType.Word16;
                break;

            case 0x220:
            case 0x221:
            case 0x222:
            case 0x223:
                oc  = Opcode.emt;
                op1 = new ImmediateOperand(Constant.Byte((byte)opcode));
                break;

            case 0x224:
            case 0x225:
            case 0x226:
            case 0x227:
                oc  = Opcode.trap;
                op1 = new ImmediateOperand(Constant.Byte((byte)opcode));
                break;

            case 0x028:
            case 0x228:
                oc  = dataWidth.Size == 1 ? Opcode.clrb : Opcode.clr;
                op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x029:
            case 0x229:
                oc = Opcode.com; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x02A:
            case 0x22A:
                oc = Opcode.inc; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x02B:
            case 0x22B:
                oc = Opcode.dec; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x02C:
            case 0x22C:
                oc = Opcode.neg; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x02D:
            case 0x22D:
                oc = Opcode.adc; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x02E:
            case 0x22E:
                oc = Opcode.sbc; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x02F:
            case 0x22F:
                oc = Opcode.tst; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x030:
            case 0x230:
                oc = Opcode.ror; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x031:
            case 0x231:
                oc = Opcode.rol; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x032:
            case 0x232:
                oc = Opcode.asr; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x033:
            case 0x233:
                oc = Opcode.asl; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x034:
                oc  = Opcode.mark;
                op1 = new ImmediateOperand(Constant.Byte((byte)opcode));
                break;

            case 0x234:
                oc = Opcode.mtps; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x035:
                oc = Opcode.mfpi; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x235:
                oc = Opcode.mfpd; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x036:
                oc = Opcode.mtpi; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x236:
                oc = Opcode.mtpd; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x037:
                oc = Opcode.sxt; op1 = dasm.DecodeOperand(opcode);
                break;

            case 0x237:
                oc = Opcode.mfps; op1 = dasm.DecodeOperand(opcode);
                break;
            }
            if (cop > 0 && op1 == null ||
                cop > 1 && op2 == null)
            {
                return(new Pdp11Instruction {
                    Opcode = Opcode.illegal
                });
            }
            return(new Pdp11Instruction
            {
                Opcode = oc,
                DataWidth = dataWidth,
                op1 = op1,
                op2 = op2,
            });
        }
示例#11
0
 private static Pdp11Instruction FpuArithmetic(ushort opcode, Pdp11Disassembler dasm)
 {
     return(fpu2Decoders[(opcode >> 8) & 0x0F].Decode(opcode, dasm));
 }
示例#12
0
 public override Pdp11Instruction Decode(ushort opcode, Pdp11Disassembler dasm)
 {
     return(fn(opcode, dasm));
 }
示例#13
0
 public override Pdp11Instruction Decode(ushort opcode, Pdp11Disassembler dasm)
 {
     return(dasm.DecodeOperands(opcode, this.opcode, fmt));
 }
示例#14
0
 public abstract Pdp11Instruction Decode(ushort opcode, Pdp11Disassembler dasm);
示例#15
0
 private static bool w(uint uInstr, Pdp11Disassembler dasm)
 {
     dasm.dataWidth = PrimitiveType.Word16;
     return(true);
 }
示例#16
0
        private static Pdp11Instruction NonDoubleOperandInstruction(ushort opcode, Pdp11Disassembler dasm)
        {
            var iclass = InstrClass.Linear;

            switch ((opcode >> 8))
            {
            case 0x01: return(dasm.BranchInstruction(opcode, Mnemonic.br, InstrClass.Transfer));

            case 0x02: return(dasm.BranchInstruction(opcode, Mnemonic.bne));

            case 0x03: return(dasm.BranchInstruction(opcode, Mnemonic.beq));

            case 0x04: return(dasm.BranchInstruction(opcode, Mnemonic.bge));

            case 0x05: return(dasm.BranchInstruction(opcode, Mnemonic.blt));

            case 0x06: return(dasm.BranchInstruction(opcode, Mnemonic.bgt));

            case 0x07: return(dasm.BranchInstruction(opcode, Mnemonic.ble));

            case 0x80: return(dasm.BranchInstruction(opcode, Mnemonic.bpl));

            case 0x81: return(dasm.BranchInstruction(opcode, Mnemonic.bmi));

            case 0x82: return(dasm.BranchInstruction(opcode, Mnemonic.bhi));

            case 0x83: return(dasm.BranchInstruction(opcode, Mnemonic.blos));

            case 0x84: return(dasm.BranchInstruction(opcode, Mnemonic.bvc));

            case 0x85: return(dasm.BranchInstruction(opcode, Mnemonic.bvs));

            case 0x86: return(dasm.BranchInstruction(opcode, Mnemonic.bcc));

            case 0x87: return(dasm.BranchInstruction(opcode, Mnemonic.bcs));
            }

            var      dataWidth = dasm.DataWidthFromSizeBit(opcode & 0x8000u);
            var      ops       = new List <MachineOperand>();
            Mnemonic oc        = Mnemonic.illegal;

            switch ((opcode >> 6) & 0x3FF)
            {
            case 0x000:
                switch (opcode & 0x3F)
                {
                case 0x00: oc = Mnemonic.halt; iclass = InstrClass.Terminates | InstrClass.Zero; break;

                case 0x01: oc = Mnemonic.wait; break;

                case 0x02: oc = Mnemonic.rti; iclass = InstrClass.Transfer; break;

                case 0x03: oc = Mnemonic.bpt; break;

                case 0x04: oc = Mnemonic.iot; break;

                case 0x05: oc = Mnemonic.reset; iclass = InstrClass.Transfer; break;

                case 0x06: oc = Mnemonic.rtt; iclass = InstrClass.Transfer; break;

                case 0x07: oc = Mnemonic.illegal; break;
                }
                break;

            case 0x001:
                var op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                oc = Mnemonic.jmp; iclass = InstrClass.Transfer; break;

            case 0x002:
                switch (opcode & 0x38)
                {
                case 0:
                    ops.Add(dasm.DecodeOperand(opcode & 7u));
                    oc     = Mnemonic.rts;
                    iclass = InstrClass.Transfer; break;

                case 3:
                    op = dasm.DecodeOperand(opcode);
                    if (op == null)
                    {
                        return(dasm.CreateInvalidInstruction());
                    }
                    ops.Add(op);
                    oc = Mnemonic.spl; break;

                case 0x20:
                case 0x28:
                case 0x30:
                case 0x38:
                    return(dasm.DecodeCondCode(opcode));
                }
                break;

            case 0x003:
                oc = Mnemonic.swab;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                dataWidth = PrimitiveType.Byte;
                break;

            case 0x020:
            case 0x021:
            case 0x022:
            case 0x023:
            case 0x024:
            case 0x025:
            case 0x026:
            case 0x027:
                oc     = Mnemonic.jsr;
                iclass = InstrClass.Transfer | InstrClass.Call;
                ops.Add(Reg(opcode >> 6, dasm));
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                dataWidth = PrimitiveType.Word16;
                break;

            case 0x220:
            case 0x221:
            case 0x222:
            case 0x223:
                oc = Mnemonic.emt;
                ops.Add(new ImmediateOperand(Constant.Byte((byte)opcode)));
                break;

            case 0x224:
            case 0x225:
            case 0x226:
            case 0x227:
                oc     = Mnemonic.trap;
                iclass = InstrClass.Transfer;
                ops.Add(new ImmediateOperand(Constant.Byte((byte)opcode)));
                break;

            case 0x028:
            case 0x228:
                oc = dataWidth.Size == 1 ? Mnemonic.clrb : Mnemonic.clr;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x029:
            case 0x229:
                oc = Mnemonic.com;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x02A:
            case 0x22A:
                oc = Mnemonic.inc;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x02B:
            case 0x22B:
                oc = Mnemonic.dec;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x02C:
            case 0x22C:
                oc = Mnemonic.neg;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x02D:
            case 0x22D:
                oc = Mnemonic.adc;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x02E:
            case 0x22E:
                oc = Mnemonic.sbc;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x02F:
            case 0x22F:
                oc = Mnemonic.tst;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x030:
            case 0x230:
                oc = Mnemonic.ror;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x031:
            case 0x231:
                oc = Mnemonic.rol;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x032:
            case 0x232:
                oc = Mnemonic.asr;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x033:
            case 0x233:
                oc = Mnemonic.asl;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x034:
                oc = Mnemonic.mark;
                ops.Add(new ImmediateOperand(Constant.Byte((byte)opcode)));
                break;

            case 0x234:
                oc = Mnemonic.mtps;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x035:
                oc = Mnemonic.mfpi;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x235:
                oc = Mnemonic.mfpd;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x036:
                oc = Mnemonic.mtpi;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x236:
                oc = Mnemonic.mtpd;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x037:
                oc = Mnemonic.sxt;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;

            case 0x237:
                oc = Mnemonic.mfps;
                op = dasm.DecodeOperand(opcode);
                if (op == null)
                {
                    return(dasm.CreateInvalidInstruction());
                }
                ops.Add(op);
                break;
            }
            return(new Pdp11Instruction
            {
                Mnemonic = oc,
                InstructionClass = iclass,
                DataWidth = dataWidth,
                Operands = ops.ToArray()
            });
        }