Esempio n. 1
0
 /**
  * Before instruction s, insert code to adjust ESP so that it lies at a particular offset from its
  * usual location.
  *
  * @param s the instruction before which ESP must have the desired offset
  * @param desiredOffset the desired offset
  */
 private void moveESPBefore(Instruction s, int desiredOffset) {
   PhysicalRegisterSet phys = (PhysicalRegisterSet) ir.regpool.getPhysicalRegisterSet();
   Register ESP = phys.getESP();
   int delta = desiredOffset - ESPOffset;
   if (delta != 0) {
     if (canModifyEFLAGS(s)) {
       s.insertBefore(
           MIR_BinaryAcc.create(
               IA32_ADD,
               new RegisterOperand(ESP, PRIMITIVE_TYPE_FOR_WORD),
               VM.BuildFor32Addr ? IC(delta) : LC(delta)));
     } else {
       MemoryOperand M =
           MemoryOperand.BD(
               new RegisterOperand(ESP, PRIMITIVE_TYPE_FOR_WORD),
               Offset.fromIntSignExtend(delta),
               (byte) WORDSIZE,
               null,
               null);
       s.insertBefore(
           MIR_Lea.create(IA32_LEA, new RegisterOperand(ESP, PRIMITIVE_TYPE_FOR_WORD), M));
     }
     ESPOffset = desiredOffset;
   }
 }