Esempio n. 1
0
        // Regs use uppercase letters, immediates use lowercase letters: [r1] becomes AAAAA, [i1] becomes aaa if length = 3, etc.
        public static string ExpandFormat(EncodingFormat format)
        {
            int    numRegs         = format.NumRegs;
            int    numImmeds       = format.NumImmeds;
            string newFormatBinary = format.Binary;

            for (int i = 0; i < numRegs; i++)
            {
                char   elementTypeChar    = format.RegisterTypes[i];
                string strElementTypeChar = elementTypeChar.ToString();
                int    iPlusOne           = i + 1;
                string strIPlusOne        = iPlusOne.ToString();

                newFormatBinary = newFormatBinary.Replace("[" + strElementTypeChar + strIPlusOne + "]", ASMStringHelper.CreateCharacterString(ASMStringHelper.CreateUpperLetterChar(i), ASMRegisterHelper.GetEncodingBitLength(elementTypeChar)));

                if (format.PartialRegisterSizes != null)
                {
                    newFormatBinary = newFormatBinary.Replace("[" + strElementTypeChar + strIPlusOne + "-1]", ASMStringHelper.CreateCharacterString(ASMStringHelper.CreateUpperLetterChar(i), format.PartialRegisterSizes[0]));
                    newFormatBinary = newFormatBinary.Replace("[" + strElementTypeChar + strIPlusOne + "-2]", ASMStringHelper.CreateCharacterString(ASMStringHelper.CreateUpperLetterChar(i), format.PartialRegisterSizes[1]));
                }
            }
            for (int i = 0; i < numImmeds; i++)
            {
                newFormatBinary = newFormatBinary.Replace("[" + format.ImmediateTypes[i] + (i + 1) + "]", ASMStringHelper.CreateCharacterString(ASMStringHelper.CreateLowerLetterChar(i), format.ImmediateLengths[i]));
            }

            return(newFormatBinary);
        }