public void Continue(int pcAddr)
 {
     pc = pcAddr;
     while (true)
     {
         try
         {
             //不在中断处理中,使能中断,指令数达到
             if ((icon & 0x02) == 0 && (icon & 0x01) != 0 && operatorCount == 40)
             {
                 operatorCount = 0;
                 icon         |= 0x02;
                 lr            = pc;
                 pc            = 1;
             }
             //没有在中断中
             else if ((icon & 0x02) == 0 && (icon & 0x01) != 0)
             {
                 operatorCount++;
             }
             OperatorLine code = Memory.ReadOperator(pc++);
             optLoader.Run(code);
         }
         catch (VMException e)
         {
             if (e.VMFaultException == VMFault.NormalExit)
             {
                 break;
             }
             throw e;
         }
     }
 }
示例#2
0
        /// <summary>
        /// 从内存中读取一个指令
        /// </summary>
        /// <param name="Address"></param>
        /// <returns></returns>
        public OperatorLine ReadOperator(int Address)
        {
            if (Address < 0 || Address > 1024)
            {
                throw new VMException(VMFault.InvalidAddr, $"无效的内存地址:{Address}");
            }
            if (memoryAttribute[Address] != MemoryAttribute.CODE)
            {
                throw new VMException(VMFault.InvalidAddr, $"访问冲突,该地址不是代码地址:{Address}");
            }

            OperatorLine opt = new OperatorLine();

            opt.opt     = memoryPool[Address];
            opt.args[0] = memoryPool[Address * 4 + ParamBaseAddress];
            opt.args[1] = memoryPool[Address * 4 + ParamBaseAddress + 1];
            opt.args[2] = memoryPool[Address * 4 + ParamBaseAddress + 2];
            int dataType = memoryPool[Address * 4 + ParamBaseAddress + 3];

            // 1-数据 0-寄存器
            opt.argTypes[2] = (char)(dataType & 0x04);
            opt.argTypes[1] = (char)(dataType & 0x02);
            opt.argTypes[0] = (char)(dataType & 0x01);
            return(opt);
        }
示例#3
0
        /// <summary>
        /// 根据业务员编码取得当前组织生效的业务员
        /// </summary>
        /// <param name="Code">业务员编码</param>
        /// <returns></returns>
        public Operators GetOperators(string Code)
        {
            string       path   = string.Format(" Operators.Effective.IsEffective=1 and Operators.Effective.EffectiveDate < getdate() and Operators.Effective.DisableDate >= getdate() and Operators.Code = '{0}' and Operators.Org.ID={1} ", Code, Context.LoginOrg.ID.ToString());
            OperatorLine opLine = OperatorLine.Finder.Find(path, new OqlParam[] { });

            if (opLine == null)
            {
                return(null);
            }
            return(opLine.Operators);
        }
示例#4
0
 public void Run(OperatorLine opt)
 {
     RunMap[opt.opt].Run(Runtime, opt.args, opt.argTypes);
 }
示例#5
0
        /// <summary>
        /// 解析行
        /// </summary>
        /// <param name="Line">代码行</param>
        /// <returns>一条指令</returns>
        public OperatorLine ParseLine(string Line)
        {
            string OpCode = "";

            string[] Args = { "", "", "" };
            //string[] FirstParse = Line.Split(' ');
            int index = 0;

            for (int i = 0; i < (int)Line.Length; i++)
            {
                if (index == 0 && Line.ToCharArray()[i] == ' ')
                {
                    index++;
                    continue;
                }
                if (Line.ToCharArray()[i] == ',')
                {
                    index++;
                    continue;
                }

                if (index == 0)
                {
                    OpCode += Line.ToCharArray()[i];
                }
                else if (index > 3)
                {
                    throw new VMException(VMFault.ArgsError, $"指令的参数最多三个:{Line}");
                }
                else
                {
                    Args[index - 1] += Line.ToCharArray()[i];
                }
            }
            OperatorLine CodeLine = new OperatorLine();

            CodeLine.opt = optLoader.GetOptCode(OpCode);
            if (CodeLine.opt == -1)
            {
                throw new VMException(VMFault.InvalidInstructions, $"无效的指令:{Line}");
            }

            for (int i = 0; i < index; i++)
            {
                if (SectionMap.ContainsKey(Args[i]))
                {
                    CodeLine.args[i]     = SectionMap[Args[i]];
                    CodeLine.argTypes[i] = 'd';
                }
                else if (RegisterMap.ContainsKey((Args[i])))
                {
                    CodeLine.args[i]     = RegisterMap[Args[i]];
                    CodeLine.argTypes[i] = 'r';
                }
                else
                {
                    if (int.TryParse(Args[i], out CodeLine.args[i]))
                    {
                        CodeLine.argTypes[i] = 'd';
                    }
                    else
                    {
                        throw new VMException(VMFault.ArgsError, $"参数错误:{Line}->参数{i + 1}");
                    }
                }
            }
            return(CodeLine);
        }