Exemplo n.º 1
0
        private static void ThreadFun()
        {
            if (enableRun < 0)
            {
                isEnd = true;
                return;
            }
            string strArg1 = Register.GetRegisterValue("pc");
            PC = (Int32)CommonTool.StrToNum(TypeCode.Int32, strArg1, 16);
            //获取指令
            code = RunTimeCode.GetCode(PC);

            //设置NPC
            switch (code.codeType)
            {
                case CodeType.OVER:
                    {
                        enableRun = -1;
                        NPC = PC;
                        ifOverOrNop = true;
                        break;
                    }
                case CodeType.NOP:
                    {
                        PC = PC + 4;
                        NPC = PC;
                        ifOverOrNop = true;
                        break;
                    }
                case CodeType.ERR:
                    {
                        Form1.Message(code.codeStr);
                        RunTimeCode.codeList.Clear();
                        break;
                    }
                default:
                    {
                        PC = PC + 4;
                        NPC = PC;
                        mDEStage.code =mIFStage.code;
                        mDEStage.args = new object[1] { NPC };
                        mDEStage.enableRun++;
                        break;
                    }
            }
            if (MipsSimulator.Program.mode==1)
            {
                if (code.codeType != CodeType.OVER)
                {
                    int colorIndex = (int)cmdMode.lineTable[mIFStage.code.Index];
                    Form1.codeColor(colorIndex, 1);
                }
            }

            isEnd = true;
            return;
        }
Exemplo n.º 2
0
 //添加指令段
 public static void Add(Code[] codes)
 {
     for (int i = 0; i < codes.Length; i++)
     {
         DataRow dr = CodeT.NewRow();
         string address = "0x" + codes[i].address.ToString("X8");
         dr["Address"] = address;
         dr["Code"] = codes[i].machineCode;
         dr["Source"] = codes[i].codeStr;
         CodeT.Rows.Add(dr);
         codes[i].Index = codeIndex;
         codeIndex++;
     }
     // codeList.AddRange(codes);
 }
Exemplo n.º 3
0
        //添加单条指令
        public static void Add(Code code)
        {
            //code.Index = codeIndex;
            //codeIndex++;
            //codeList.Add(code);

            DataRow dr = CodeT.NewRow();
            if (code.address < 0)
            {
                dr["Address"] = "";
            }
            else
            {
                string address = "0x" + code.address.ToString("X8");
                dr["Address"] = address;
            }
            dr["Code"] = code.machineCode;
            dr["Source"] = code.codeStr;
            CodeT.Rows.Add(dr);
        }
Exemplo n.º 4
0
 //获取指令
 public static Code GetCode(Int32 codeCurrentAddress)
 {
     if ((codeCurrentAddress - CodeStartAddress) % 4 != 0)
     {
         Code code = new Code();
         code.codeType = CodeType.ERR;
         code.codeStr = "地址未对齐";
         // code.Index = -1;
         return code;
     }
     int index = Convert.ToInt32((codeCurrentAddress - CodeStartAddress) / 4);
     if (index < 0 || index >= codeList.Count)
     {
         Code code = new Code();
         code.codeType = CodeType.OVER;
         // code.Index = -1;
         return code;
     }
     return codeList[index];
 }