public static Instruction Create(uint regdst, Parsing.ValBase value) { if (value is Parsing.ValReg) { var ins = new T { RegDst = regdst, RegSrc = (value as Parsing.ValReg).Index }; return(ins); } else if (value is Parsing.ValInstant) { var val = (value as Parsing.ValInstant).Val; if (val < -(1 << 15) || val >= 1 << 15) { return(Failed.OutOfRange); } var ins = new AsmBinaryOpInstant <T> { RegDst = regdst, Value = (value as Parsing.ValInstant).Val }; return(ins); } else { return(Failed.NotImplemented); } }
public static new Instruction Create(uint regdst, Parsing.ValBase value) { var ins = AsmMovCompressed.Create(regdst, value); if (ins.Success) { return(ins); } return(AsmBinaryOp <AsmMov> .Create(regdst, value)); }
public static Instruction Create(uint regdst, Parsing.ValBase value) { if (value is not Parsing.ValInstant) { return(Failed.InvalidArgument); } var val = (value as Parsing.ValInstant).Val; if (val < -(1 << 6) || val >= 1 << 6) { return(Failed.OutOfRange); } return(new AsmMovCompressed { RegDst = regdst, Value = val }); }
public static Instruction Create(uint regdst, Parsing.ValBase value) { if (value is Parsing.ValReg) { return(Failed.InvalidArgument); } else if (value is Parsing.ValInstant) { var val = (value as Parsing.ValInstant).Val; if (val < 0 || val >= 1 << 4) { return(Failed.OutOfRange); } var ins = new AsmBinaryOpInstant <T>(); ins.RegDst = regdst; ins.Value = val; return(ins); } else { return(Failed.NotImplemented); } }