Exemplo n.º 1
0
 public static int GetRegisterIncludeMask(char elementTypeChar)
 {
     return(ASMValueHelper.GetIncludeMask(GetEncodingBitLength(elementTypeChar)));
 }
Exemplo n.º 2
0
        public static EncodingFormat FindParameterIndexes(EncodingFormat format)
        {
            List <int>   regPositions        = new List <int>();
            List <int[]> partialRegPositions = new List <int[]>();
            List <int>   immedPositions      = new List <int>();

            List <int>   regIncludeMasks        = new List <int>();
            List <int[]> partialRegIncludeMasks = new List <int[]>();
            List <int>   immedIncludeMasks      = new List <int>();

            string expFormat    = format.ExpandedFormat;
            string formatBinary = format.Binary;

            char currentChar = (char)ASMStringHelper.CharOffsets.UpperLetter;

            for (int i = 0; i < format.NumRegs; i++)
            {
                if (format.RegisterTypes[i] == ASMElementTypeCharacter.PartialVFPURegister)
                {
                    int[] partialPositions    = new int[2];
                    int[] partialIncludeMasks = new int[2];

                    int part1Index = formatBinary.IndexOf("[p" + (i + 1).ToString() + "-1");
                    int part2Index = formatBinary.IndexOf("[p" + (i + 1).ToString() + "-2");

                    int firstIndex      = expFormat.IndexOf(currentChar);
                    int searchPartIndex = firstIndex;
                    for (; expFormat[searchPartIndex] == currentChar; searchPartIndex++)
                    {
                        ;
                    }
                    int secondIndex = expFormat.IndexOf(currentChar, searchPartIndex);

                    if (part1Index > part2Index)
                    {
                        partialPositions[0] = secondIndex;
                        partialPositions[1] = firstIndex;
                    }
                    else
                    {
                        partialPositions[0] = firstIndex;
                        partialPositions[1] = secondIndex;
                    }

                    partialPositions[0] = InstructionBitLength - partialPositions[0] - format.PartialRegisterSizes[0];
                    partialPositions[1] = InstructionBitLength - partialPositions[1] - format.PartialRegisterSizes[1];

                    partialIncludeMasks[0] = ASMValueHelper.GetIncludeMask(format.PartialRegisterSizes[0]);
                    partialIncludeMasks[1] = ASMValueHelper.GetIncludeMask(format.PartialRegisterSizes[1]);

                    partialRegPositions.Add(partialPositions);
                    partialRegIncludeMasks.Add(partialIncludeMasks);
                    regPositions.Add(0);
                    regIncludeMasks.Add(0);
                }
                else
                {
                    regPositions.Add(InstructionBitLength - expFormat.IndexOf(currentChar) - ASMRegisterHelper.GetEncodingBitLength(format.RegisterTypes[i]));
                    regIncludeMasks.Add(ASMRegisterHelper.GetRegisterIncludeMask(format.RegisterTypes[i]));
                    partialRegPositions.Add(null);
                    partialRegIncludeMasks.Add(null);
                }

                currentChar++;
            }

            currentChar = (char)ASMStringHelper.CharOffsets.LowerLetter;
            for (int i = 0; i < format.NumImmeds; i++)
            {
                immedPositions.Add(InstructionBitLength - expFormat.IndexOf(currentChar) - format.ImmediateLengths[i]);
                immedIncludeMasks.Add(ASMValueHelper.GetIncludeMask(format.ImmediateLengths[i]));
                currentChar++;
            }

            format.RegisterPositions        = regPositions;
            format.PartialRegisterPositions = partialRegPositions;
            format.ImmediatePositions       = immedPositions;

            format.RegisterIncludeMasks        = regIncludeMasks;
            format.PartialRegisterIncludeMasks = partialRegIncludeMasks;
            format.ImmediateIncludeMasks       = immedIncludeMasks;

            return(format);
        }