Exemple #1
0
        protected override Instruction GetInstruction(string value)
        {
            Instruction instruction;

            Instructions.TryGetValue(value, out instruction);
            return(instruction);
        }
        private void disassemble(ushort start, ushort end)
        {
            Generic.DataStructures.InstructionTemplate instTemplate;
            Instruction inst;

            Memory mem = (Memory)Source.Memory;
            InstructionDictionary instructions = ((Processor)Source.Processor).Instructions;

            sb.Length = 0;

            List <object> dumpArgs = new List <object>();

            const int instWidth = 17;

            ushort opcode;

            for (int i = start; i <= end; i += 2)
            {
                dumpArgs.Clear();
                dumpArgs.Add(i);

                if (i == end)
                {
                    dumpArgs.Add(String.Format("{0:X2}  ", mem[end]));
                    dumpArgs.Add("".PadRight(instWidth, ' '));
                    dumpArgs.Add(getDrawingBytes((ushort)(mem[end] << 8)));
                }
                else
                {
                    opcode = (ushort)((mem[i] << 8) | mem[i + 1]);

                    instructions.TryGetValue(opcode, out instTemplate);
                    inst = (Instruction)instTemplate.FormInstruction(opcode);

                    dumpArgs.Add(String.Format("{0:X4}", opcode));
                    dumpArgs.Add(inst.ToString().PadRight(instWidth, ' '));
                    dumpArgs.Add(getDrawingBytes(opcode));
                }

                sb.Append(String.Format("0x{0:X4}:  0x{1}  {2}  {3}", dumpArgs.ToArray()));

                if (i < end - 1)
                {
                    sb.Append(Environment.NewLine);
                }
            }

            txtDisasm.Text = sb.ToString();
        }