Esempio n. 1
0
        public ASMDecoder(ASMDecoder decoder)
        {
            FormatHelper = new ASMFormatHelper(decoder.FormatHelper);
            RegHelper    = decoder.RegHelper;

            _errorTextBuilder = new StringBuilder();
        }
Esempio n. 2
0
        public ASMDecoder(ASMFormatHelper formatHelper, ASMRegisterHelper regHelper)
        {
            FormatHelper = formatHelper;
            RegHelper    = regHelper;

            _errorTextBuilder = new StringBuilder();
        }
Esempio n. 3
0
        public ASMEncoder(ASMEncoder encoder)
        {
            PseudoHelper = new ASMPseudoHelper(encoder.PseudoHelper);
            ValueHelper  = PseudoHelper.ValueHelper;
            FormatHelper = ValueHelper.LabelHelper.FormatHelper;
            RegHelper    = encoder.RegHelper;

            _errorTextBuilder = new StringBuilder();
        }
Esempio n. 4
0
        public ASMEncoder(ASMPseudoHelper pseudoHelper, ASMValueHelper valueHelper, ASMFormatHelper formatHelper, ASMRegisterHelper regHelper)
        {
            PseudoHelper = pseudoHelper;
            ValueHelper  = valueHelper;
            FormatHelper = formatHelper;
            RegHelper    = regHelper;

            _errorTextBuilder = new StringBuilder();
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }