예제 #1
0
 public InvOpRec(Opcode opcode, string fmt)
 {
     this.opcode = opcode;
     this.fmt    = fmt;
 }
예제 #2
0
        private Tlcs900Instruction Decode(byte b, Opcode opcode, string fmt)
        {
            var instr = new Tlcs900Instruction
            {
                Opcode  = opcode,
                Address = this.addr,
            };
            var            ops = new List <MachineOperand>();
            MachineOperand op  = null;

            for (int i = 0; i < fmt.Length; ++i)
            {
                switch (fmt[i++])
                {
                case ',': continue;

                case 'C': // condition code
                    var cc = (CondCode)(b & 0xF);
                    if (cc == CondCode.T)
                    {
                        continue;
                    }
                    op = new ConditionOperand(cc);
                    break;

                case 'A':
                    op = new RegisterOperand(Tlcs900Registers.a);
                    break;

                case '3': // Immediate encoded in low 3 bits
                    var c = Constant.Create(Size(fmt[1]), imm3Const[b & 7]);
                    SetSize(fmt[1]);
                    op = new ImmediateOperand(c);
                    break;

                case 'I': // immediate
                    op = Immediate(fmt[i++]);
                    break;

                case 'j': // Relative jump
                    switch (fmt[i++])
                    {
                    case 'b':
                        byte o8;
                        if (!rdr.TryReadByte(out o8))
                        {
                            op = null;
                        }
                        else
                        {
                            op = AddressOperand.Create(rdr.Address + (sbyte)o8);
                        }
                        break;

                    case 'w':
                        short o16;
                        if (!rdr.TryReadLeInt16(out o16))
                        {
                            op = null;
                        }
                        else
                        {
                            op = AddressOperand.Create(rdr.Address + o16);
                        }
                        break;
                    }
                    break;

                case 'J': // Absolute jump
                    switch (fmt[i++])
                    {
                    case 'w': op = AbsoluteDestination(2); break;

                    case 'l': op = AbsoluteDestination(3); break;

                    default: op = null; break;
                    }
                    break;

                case 'R':   // 16 bit register encoded in lsb
                    op = new RegisterOperand(Reg(fmt[i++], b & 0x7));
                    break;

                case 'S': // status/flag register
                    op = StatusRegister(fmt[i++]);
                    break;
                }
                if (op == null)
                {
                    return(Decode(b, Opcode.invalid, ""));
                }
                ops.Add(op);
            }
            if (ops.Count > 0)
            {
                instr.op1 = ops[0];
                if (ops.Count > 1)
                {
                    instr.op2 = ops[1];
                    if (ops.Count > 2)
                    {
                        instr.op3 = ops[2];
                    }
                }
            }
            return(instr);
        }
예제 #3
0
 public OpRec(Opcode opcode, InstrClass iclass, string fmt)
 {
     this.opcode = opcode;
     this.iclass = iclass;
     this.fmt    = fmt;
 }
예제 #4
0
 public SecondOpRec(Opcode opcode, string fmt)
 {
     this.opcode = opcode;
     this.fmt    = fmt;
 }
예제 #5
0
 public OpRec(Opcode opcode, string fmt) : this(opcode, InstrClass.Linear, fmt)
 {
 }
예제 #6
0
 private static OpRec Instr(Opcode opcode, InstrClass iclass, params Mutator <Tlcs900Disassembler>[] mutators)
 {
     return(new OpRec(opcode, iclass, mutators));
 }
예제 #7
0
 public InvOpRec(Opcode opcode, params Mutator <Tlcs900Disassembler>[] mutators)
 {
     this.opcode   = opcode;
     this.mutators = mutators;
 }
예제 #8
0
 public SecondOpRec(Opcode opcode, Mutator <Tlcs900Disassembler> mutator = null)
 {
     this.opcode  = opcode;
     this.mutator = mutator;
 }
예제 #9
0
 public OpRec(Opcode opcode, InstrClass iclass, Mutator <Tlcs900Disassembler>[] mutators)
 {
     this.opcode   = opcode;
     this.iclass   = iclass;
     this.mutators = mutators;
 }