Beispiel #1
0
 public static Operand GetImmediat(int value)
 {
     return(new Operand()
     {
         Value = value, DataType = (DataType)MathHelp.length(value)
     });
 }
Beispiel #2
0
 public Operand(bool asImmediat_Memory, int value, DataType datatype = DataType.None)
     : this()
 {
     if (asImmediat_Memory)
     {
         OperandType = Bases.OperandType.imm;
         Value       = value;
         DataType    = datatype == Bases.DataType.None ? (DataType)MathHelp.length(value) : DataType = datatype;
     }
     else
     {
         OperandType = OperandType.Mem;
         Value       = new Nbit(4, -1) << 28 | new Nbit(28, value).Value;
     }
 }
Beispiel #3
0
        public static Operand Parse(string s)
        {
            var o = new Operand
            {
                Value = Registers.GetHasheCode(s)
            };
            int r = 0;

            o.OperandType = Parser.Parse.IsNumbre(s, out r)
                ? OperandType.imm
                : (s[0] == '[' | o.Value == -1 ? OperandType.Mem : OperandType.Reg);

            if (o.OperandType == OperandType.Mem)
            {
                o.Value = Parser.Parse.MemOperandType(s.Substring(1, s.Length - 2));
            }
            else if (o.OperandType == OperandType.imm)
            {
                o.Value    = r;
                o.DataType = (DataType)(s.Length > 2 && s[1] == 'x' ? MathHelp.SRound(Math.Log(s.Length - 2, 2)) : MathHelp.length(r));
            }
            return(o);
        }