Exemplo n.º 1
0
 /// <summary>
 /// Determines if the carry flag reaches a using instruction.
 /// </summary>
 /// <param name="instrs"></param>
 /// <param name="i"></param>
 /// <param name="next"></param>
 /// <returns></returns>
 public AddSubCandidate FindUsingInstruction(StatementList stms, int i, AddSubCandidate loInstr)
 {
     for (++i; i < stms.Count; ++i)
     {
         var asc = MatchAdcSbc(stms[i].Instruction);
         if (asc != null)
         {
             Debug.Print("Left sides: [{0}] [{1}]", asc.Left, loInstr.Left);
             if (asc.Left.GetType() != loInstr.Left.GetType())
                 return null;
             asc.StatementIndex = i;
             return asc;
         }
         var ass = stms[i].Instruction as Assignment;
         if (ass == null)
             continue;
         var bin = ass.Src as BinaryExpression;
         if (bin == null)
             continue;
         if (IsCarryFlag(ass.Dst))
             return null;
     }
     return null;
 }
Exemplo n.º 2
0
        public Instruction CreateLongInstruction(AddSubCandidate loCandidate, AddSubCandidate hiCandidate)
        {
            var totalSize = PrimitiveType.Create(
                Domain.SignedInt | Domain.UnsignedInt,
                loCandidate.Dst.DataType.Size + loCandidate.Dst.DataType.Size);
            var left = CreateCandidate(loCandidate.Left, hiCandidate.Left, totalSize);
            var right = CreateCandidate(loCandidate.Right, hiCandidate.Right, totalSize);
            this.dst = CreateCandidate(loCandidate.Dst, hiCandidate.Dst, totalSize);

            if (left == null || right == null || dst == null)
                return null;
        
            var expSum = new BinaryExpression(loCandidate.Op, left.DataType, left, right);
            var idDst = dst as Identifier;
            if (idDst != null)
            {
                return new Assignment(idDst, expSum);
            }
            else
            {
                return new Store(dst, expSum);
            }
        }