Ejemplo n.º 1
0
        /// <summary>
        /// DevInf生成汇编代码调用的函数,这是层层嵌套到,devInf提供的是外围设备的基地址和外围设备的名字,结合UI就可以知道了
        /// </summary>
        /// <param name="toolString"></param>
        /// <returns></returns>
        public string GenerateCode_DevInf(ToolString toolString)
        {
            string resultCode = "";

            //这是用来生成.equ PWM0,0x20001000的这里伪指令的
            List <string> baseAddrSet    = new List <string>();
            List <string> baseAddrNumSet = new List <string>();
            List <string> regNameSet     = new List <string>();
            List <string> regNameNumSet  = new List <string>();

            if (multipleDevCheckBox.Checked)  //多个相同类型的设备
            {
                for (int i = 0; i < sameDevBaseAddrTable.devBaseAddrNameSet.Count; i++)
                {
                    baseAddrSet.Add(sameDevBaseAddrTable.devBaseAddrNameSet[i]);
                    baseAddrNumSet.Add(sameDevBaseAddrTable.devBaseAddrNumSet[i]);
                }
            }
            else
            {
                baseAddrSet.Add(baseAddrNameTextBox.Text);  //就是开头那两个文本框就是设备名字
                baseAddrNumSet.Add(baseAddrNumTextBox.Text);
            }
            for (int i = 0; i < regInfSet.Count; i++)  //寄存器和寄存器的偏移地址很好获取
            {
                regNameSet.Add(regInfSet[i].GetRegName());
                regNameNumSet.Add(regInfSet[i].GetRegNameNum());
            }
            //生成伪指令.equ
            resultCode += toolString.GeneratePseudoIR(baseAddrSet, baseAddrNumSet, regNameSet, regNameNumSet) + "\n\n";


            if (multipleDevCheckBox.Checked)
            {
                for (int i = 0; i < sameDevBaseAddrTable.devBaseAddrNameSet.Count; i++)  //多了这个循环,就是其他相同类型设备生成而已
                {
                    for (int j = 0; j < regInfSet.Count; j++)
                    {
                        resultCode += regInfSet[j].GenerateCode_RegInf(toolString, sameDevBaseAddrTable.devBaseAddrNameSet[i], true);
                    }
                }
                for (int j = 0; j < regInfSet.Count; j++)
                {
                    regInfSet[j].GenerateCode_RegInf(toolString, baseAddrNameTextBox.Text, false);
                }
            }
            else
            {
                for (int i = 0; i < regInfSet.Count; i++)
                {
                    resultCode += regInfSet[i].GenerateCode_RegInf(toolString, baseAddrNameTextBox.Text, true);
                }
            }
            return(resultCode);
        }