Exemple #1
0
 private static Dictionary<string, FXRegister> GetFXRegisters(XmlNode attributeNode)
 {
     Dictionary<string, FXRegister> registerList = new Dictionary<string, FXRegister>();
     XmlNodeList registerNodeList = attributeNode.SelectSingleNode("RegisterList").ChildNodes;
     foreach (XmlNode registerNode in registerNodeList)
     {
         if (registerNode.NodeType == XmlNodeType.Element)
         {
             FXRegister register = new FXRegister();
             register.Name = registerNode.Attributes["name"].Value;
             register.AddrFrom = Convert.ToInt32(registerNode.Attributes["addrFrom"].Value);
             register.AddrTo = Convert.ToInt32(registerNode.Attributes["addrTo"].Value);
             register.Offset = Convert.ToInt32(registerNode.Attributes["offset"].Value);
             if (registerNode.Attributes["comment"] != null)
                 register.Comment = registerNode.Attributes["comment"].Value;
             if (registerNode.Attributes["step"] != null)
                 register.Step = Convert.ToInt32(registerNode.Attributes["step"].Value);
             else
                 register.Step = 1;
             if (registerNode.Attributes["format"] != null)
                 register.NameFormatType = (FXRegisterNameFormatType)Convert.ToInt32(registerNode.Attributes["format"].Value);
             else
                 register.NameFormatType = FXRegisterNameFormatType.Dec;
             register.From = Convert.ToInt32(registerNode.Attributes["from"].Value, (int)register.NameFormatType);
             register.To = Convert.ToInt32(registerNode.Attributes["to"].Value, (int)register.NameFormatType);
             if (registerNode.Attributes["canForce"] != null)
                 register.CanForce = Convert.ToBoolean(registerNode.Attributes["canForce"].Value);
             else
                 register.CanForce = false;
             if (registerNode.Attributes["forceFrom"] != null)
                 register.ForceFrom = Convert.ToInt32(registerNode.Attributes["forceFrom"].Value);
             else
                 register.ForceFrom = register.From;
             if (registerNode.Attributes["forceTo"] != null)
                 register.ForceTo = Convert.ToInt32(registerNode.Attributes["forceTo"].Value);
             else
                 register.ForceTo = register.To;
             if (registerNode.HasChildNodes)
             {
                 XmlNodeList registerMNNodeList = registerNode.ChildNodes;
                 foreach (XmlNode registerMNNode in registerMNNodeList)
                 {
                     if (registerMNNode.NodeType == XmlNodeType.Element)
                     {
                         FXRegisterMN mn = new FXRegisterMN();
                         mn.From = Convert.ToInt32(registerMNNode.Attributes["from"].Value);
                         mn.To = Convert.ToInt32(registerMNNode.Attributes["to"].Value);
                         mn.M = Convert.ToInt32(registerMNNode.Attributes["m"].Value);
                         mn.N = Convert.ToInt32(registerMNNode.Attributes["n"].Value);
                         if (registerMNNode.Attributes["isPoint"] != null)
                             mn.IsPoint = Convert.ToBoolean(registerMNNode.Attributes["isPoint"].Value);
                         else
                             mn.IsPoint = false;
                         if (registerMNNode.Attributes["offset"] != null)
                             mn.Offset = Convert.ToInt32(registerMNNode.Attributes["offset"].Value);
                         else
                             mn.Offset = 0;
                         if (registerMNNode.Attributes["step"] != null)
                             mn.Step = Convert.ToInt32(registerMNNode.Attributes["step"].Value);
                         else
                             mn.Step = 1;
                         register.MN.Add(mn);
                     }
                 }
             }
             registerList.Add(register.Name, register);
         }
     }
     return registerList;
 }
Exemple #2
0
 private static FXRegisterMN GetRegisterMN(OperandDetails details, Dictionary<string, FXRegister> registerList, ref int valueValue)
 {
     if (details.Name.Equals(FXConfigReader.KCONSTANT, StringComparison.CurrentCultureIgnoreCase))          //如果是K常数
     {
         FXRegisterMN mn = new FXRegisterMN();
         mn.M = 0;
         mn.N = 0;
         mn.From = 0;
         mn.To = 0;
         valueValue = Convert.ToInt32(details.Value, 10);
         return mn;
     }
     if (details.Name.Equals(FXConfigReader.HCONSTANT, StringComparison.CurrentCultureIgnoreCase))          //如果是H常数
     {
         FXRegisterMN mn = new FXRegisterMN();
         mn.M = 2;
         mn.N = 0;
         mn.From = 0;
         mn.To = 0;
         valueValue = Convert.ToInt32(details.Value, 16);
         return mn;
     }
     if (registerList.ContainsKey(details.Name))
     {
         FXRegister register = registerList[details.Name];
         int detailsValue = Convert.ToInt32(details.Value, (int)register.NameFormatType);
         foreach (FXRegisterMN mn in register.MN)
         {
             if (detailsValue >= mn.From && detailsValue <= mn.To)
             {
                 if (!mn.IsPoint)
                 {
                     //valueValue = (detailsValue - mn.From + mn.Offset) * 2;
                     valueValue = ((detailsValue - mn.From) * mn.Step + mn.Offset) * 2;
                     return mn;
                 }
                 else
                 {
                     valueValue = detailsValue - register.From + register.AddrFrom + register.Offset;
                     FXRegisterMN tempMN = new FXRegisterMN();
                     tempMN.From = mn.From;
                     tempMN.To = mn.To;
                     tempMN.IsPoint = mn.IsPoint;
                     tempMN.Offset = mn.Offset;
                     tempMN.M = 4;
                     tempMN.N = details.Bits / 2;
                     return tempMN;
                 }
             }
         }
         throw new Exception("No Such Operand Value! " + details.Value + ". At " + FXComplier.m_nowProcessLine.BasicLineStr);
     }
     else
         throw new Exception("No Such Operand Name! " + details.Name + ". At " + FXComplier.m_nowProcessLine.BasicLineStr);
 }