public Operand(bool asImmediat_Memory, int value, DataType datatype = DataType.None) : this() { if (asImmediat_Memory) { this.OperandType = OperandType.imm; this.Value = value; this.DataType = datatype == DataType.None ? (DataType)MathHelp.length(value) : this.DataType = datatype; } else { this.OperandType = OperandType.Mem; this.Value = new Nbit(4, -1) << 28 | new Nbit(28, value).Value; } }
public static Operand Parse(string s) { var o = new Operand { Value = Registers.GetHasheCode(s) }; var r = 0; o.OperandType = Qs.Parse.IsNumbre(s, out r) ? OperandType.imm : (s[0] == '[' | o.Value == -1 ? OperandType.Mem : OperandType.Reg); if (o.OperandType == OperandType.Mem) { o.Value = Qs.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); }