コード例 #1
0
ファイル: ASMLabelHelper.cs プロジェクト: xjamxx/FFTPatcher
        /*
         *      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);
                if (ASMStringHelper.StringIsNumeric(str_uvalue))
                {
                    uint uvalue = Convert.ToUInt32(str_uvalue);
                    if (uvalue == 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return((uint)(0x100000000 - uvalue));
                    }
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(LabelToUnsigned(val, skipLabelAssertion));
            }
        }