Esempio n. 1
0
        private void GenerateNextInstruction(int pc)
        {
            OpCode oc       = kernel.CPU.PreFetch();
            int    ocLength = oc.Length;

            byte[] command = new byte[ocLength];
            for (int i = 0; i < ocLength; i++)
            {
                command[i] = kernel.MemMgr.RAM.ReadByte(pc + i);
            }
            string opcodes = oc.ToString(kernel.CPU.ReadSignature(ocLength, pc));
            //string status = "";
            DebugLine line = new DebugLine(pc);

            line.SetOpcodes(command);
            line.SetMnemonic(opcodes);
            if (!lastLine.InvokeRequired)
            {
                lastLine.Text = line.ToString();
            }
            else
            {
                try
                {
                    lastLine.Invoke(new lastLineDelegate(ShowLastLine), new object[] { line.ToString() });
                }
                finally
                { }
            }
            // find the proper place to insert the line, based on the PC
            int  index     = 0;
            bool lineAdded = false;

            for (index = 0; index < codeList.Count; index++)
            {
                DebugLine l = codeList[index];
                if (l.PC > pc)
                {
                    codeList.Insert(index, line);
                    lineAdded = true;
                    break;
                }
            }
            if (!lineAdded)
            {
                codeList.Add(line);
            }
        }