示例#1
0
 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 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);
     }
 }