Example #1
0
        private uint EncodeInvertedSingleBitVFPURegister(string register, int vfpuRegisterMode)
        {
            int regNum = RegHelper.TranslateRegister(register, ASMElementTypeCharacter.VFPURegister, vfpuRegisterMode);

            ASMDebugHelper.assert(regNum <= ASMRegisterHelper.MaxValues.VFPURegister, "Invalid VFPU register index: " + regNum.ToString());
            //string binary = ASMValueHelper.UnsignedToBinary_WithLength((uint)regNum, ASMRegisterHelper.EncodingBitLengths.VFPURegister);

            /*
             * char[] binaryChars = binary.ToCharArray();
             * int invertIndex = ASMRegisterHelper.VFPUInvertSingleBitStringIndex;
             * int digitOffset = ASMStringHelper.CharOffsets.Digit;
             * binaryChars[invertIndex] = (char)(1 - (binaryChars[invertIndex] - digitOffset) + digitOffset);
             * return new string(binaryChars);
             */

            return((uint)(regNum ^ ASMRegisterHelper.VFPUInvertedSingleBitMask));
        }
        public uint LabelToUnsigned(string label, bool skipAssertion = false)
        {
            string newLabel   = ASMStringHelper.RemoveSpaces(label).ToUpper();
            string lowerLabel = newLabel.ToLower();

            if (((lowerLabel.StartsWith("%hi(")) || (lowerLabel.StartsWith("%lo("))) && (lowerLabel.Substring(3).Contains(")")))
            {
                string newValue = lowerLabel.Substring(4, lowerLabel.IndexOf(")") - 4).Trim();
                uint   uValue   = GetAnyUnsignedValue(newValue, skipAssertion);
                return(lowerLabel.StartsWith("%hi(") ? ProcessHi(uValue) : ProcessLo(uValue));
            }

            if (!skipAssertion)
            {
                ASMDebugHelper.assert(LabelDict.ContainsKey(newLabel), "Label not found: " + label);
            }

            return((uint)(LabelDict.ContainsKey(newLabel) ? LabelDict[newLabel] : 0));
        }
        /*
         *      public int LabelToUnsigned(string label)
         *      {
         *              string newLabel = ASMStringHelper.RemoveSpaces(label).ToUpper();
         *              ASMDebugHelper.assert(LabelDict.ContainsKey(newLabel), "Label not found: " + label);
         *              return LabelDict[newLabel];
         *      }
         */

        public uint GetAnyUnsignedValue(string val, bool skipLabelAssertion = false)
        {
            if ((val.StartsWith("0x")) || (val.StartsWith("-0x")))
            {
                return(ASMValueHelper.HexToUnsigned_AnySign(val, 32));
            }
            else if (ASMStringHelper.StringIsNumeric(val))
            {
                return(Convert.ToUInt32(val));
            }
            else if ((val.StartsWith("-")) && (val.Length > 1))
            {
                string str_uvalue = val.Substring(1);
                bool   isNumeric  = ASMStringHelper.StringIsNumeric(str_uvalue);
                ASMDebugHelper.assert(isNumeric, "Could not parse negative value: " + val);
                if (isNumeric)
                {
                    uint uvalue = Convert.ToUInt32(str_uvalue);
                    if (uvalue == 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return((uint)(0x100000000 - uvalue));
                    }
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(LabelToUnsigned(val, skipLabelAssertion));
            }
        }