コード例 #1
0
        /// <summary>
        /// 利用toolString来生成代码
        /// </summary>
        /// <param name="toolString"></param>
        /// <returns></returns>
        public string GenerateAssemblyCode(ToolString toolString, bool defineSomeTarget, bool multipDevInfTarget)
        {
            string resultCode = "";

            if (writeOrRead == 2)  //rw
            {
                resultCode += GenerateAssemblyCode_writeOrRead(toolString, 1);
                resultCode += GenerateAssemblyCode_writeOrRead(toolString, 0);
            }
            else if (writeOrRead == 1) //r
            {
                resultCode += GenerateAssemblyCode_writeOrRead(toolString, 1);
            }
            else if (writeOrRead == 0)  //w
            {
                resultCode += GenerateAssemblyCode_writeOrRead(toolString, 0);
            }
            if (setModeType && defineSomeTarget && !multipDevInfTarget)
            {
                for (int i = 0; i < setModeType_AvailableValueSet.availableValueSet.Count; i++)
                {
                    toolString.GenerateDefineCode(baseAddrName, regName, setModeType_AvailableValueSet.availableValueSet[i], modeStringSet[i]);
                }
            }
            return(resultCode);
        }
コード例 #2
0
        /// <summary>
        /// 这是调用最终生成的汇编的函数的启动器
        /// </summary>
        /// <param name="toolString"></param>
        /// <param name="writeOrRead"></param>
        /// <returns></returns>
        private string GenerateAssemblyCode_writeOrRead(ToolString toolString, int writeOrRead)
        {
            string resultCode = "";

            if (enableType)
            {
                if (lowIndexBit == 0 && highIndexBit == 0)  //采用不可能出现的? + * 来表示生成有错,这是用户用的时候才知道的(假设真的出错)
                {
                    resultCode += toolString.RunBackAssemblyFunc(writeOrRead, seizeReg, 2, 1, 3, baseAddrName, regName,
                                                                 enableBit.ToString(), bitName, "?", "??", false, setModeType_AvailableValueSet.availableValueSet, "???", "1");
                    resultCode += toolString.RunBackAssemblyFunc(writeOrRead, seizeReg, 1, 1, 1, baseAddrName, regName,
                                                                 enableBit.ToString(), bitName, "?", "??", false, setModeType_AvailableValueSet.availableValueSet, "???", "1");
                }
                else
                {
                    resultCode += toolString.RunBackAssemblyFunc(writeOrRead, seizeReg, 2, 1, 4, baseAddrName, regName,
                                                                 enableBit.ToString(), bitName, "?", "??", false, setModeType_AvailableValueSet.availableValueSet, "???", "1");
                    resultCode += toolString.RunBackAssemblyFunc(writeOrRead, seizeReg, 1, 1, 2, baseAddrName, regName,
                                                                 enableBit.ToString(), bitName, "?", "??", false, setModeType_AvailableValueSet.availableValueSet, "???", "1");
                }
            }
            else if (setValueType)
            {
                if (setValueLocalScope)
                {
                    resultCode += toolString.RunBackAssemblyFunc(writeOrRead, seizeReg, 3, 2, 2, baseAddrName, regName,
                                                                 lowIndexBit.ToString(), bitName, setValueType_AvailableValueSet.maxValueInt.ToString(), "+", setValueLocalScope, setValueType_AvailableValueSet.availableValueSet, "++", setValueType_AvailableValueSet.availableBit.ToString());
                }
                else
                {
                    resultCode += toolString.RunBackAssemblyFunc(writeOrRead, seizeReg, 3, 2, 1, baseAddrName, regName,
                                                                 lowIndexBit.ToString(), bitName, setValueType_AvailableValueSet.maxValueInt.ToString(), "+", setValueLocalScope, setValueType_AvailableValueSet.availableValueSet, "++", setValueType_AvailableValueSet.availableBit.ToString());
                }
            }
            else if (setModeType)
            {
                if (setModeSingleType)
                {
                    for (int i = 0; i < setModeType_AvailableValueSet.availableValueSet.Count; i++)
                    {
                        resultCode += toolString.RunBackAssemblyFunc(writeOrRead, seizeReg, 5, 3, 2, baseAddrName, regName,
                                                                     lowIndexBit.ToString(), bitName, setModeType_AvailableValueSet.maxValueInt.ToString(), setModeType_AvailableValueSet.availableValueSet[i], false,
                                                                     setModeType_AvailableValueSet.availableValueSet, modeStringSet[i], setModeType_AvailableValueSet.availableBit.ToString());
                        if (writeOrRead == 1)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    resultCode += toolString.RunBackAssemblyFunc(writeOrRead, seizeReg, 4, 3, 1, baseAddrName, regName,
                                                                 lowIndexBit.ToString(), bitName, setModeType_AvailableValueSet.maxValueInt.ToString(), "*", false,
                                                                 setModeType_AvailableValueSet.availableValueSet, "**", setModeType_AvailableValueSet.availableBit.ToString());
                }
            }
            return(resultCode);
        }
コード例 #3
0
 /// <summary>
 /// 生成宏定义
 /// </summary>
 /// <param name="toolString"></param>
 /// <param name="defineSomeTarget"></param>
 public void GenerateAssemblyCode_Define(ToolString toolString, bool defineSomeTarget)
 {
     if (setModeType && defineSomeTarget)
     {
         for (int i = 0; i < setModeType_AvailableValueSet.availableValueSet.Count; i++)
         {
             toolString.GenerateDefineCode(baseAddrName, regName, setModeType_AvailableValueSet.availableValueSet[i], modeStringSet[i]);
         }
     }
 }