/* Decode a 32-bit index to determine the offset. */
INT32 VmReadIndex32(IN VM_CONTEXT *VmPtr, IN UINT32 CodeOffset)
/* Decode a 32-bit index to determine the offset. */
INT32 VmReadIndex32(IN VM_CONTEXT *VmPtr, IN UINT32 CodeOffset)
{
  UINT32  Index;
  INT32   Offset;
  INT32   ConstUnits;
  INT32   NaturalUnits;
  INT32   NBits;
  INT32   Mask;
  Index = VmReadImmed32 (VmPtr, CodeOffset);
  NBits = (Index & 0x70000000) >> 28;
  NBits *= 4;
  Mask = (INT32) ~0 << NBits;
  NaturalUnits = Index &~Mask;
  ConstUnits = ((Index &~0xF0000000) & Mask) >> NBits;
  Offset = NaturalUnits * sizeof (UINTN) + ConstUnits;
  if ((Index & 0x80000000) != 0) {
    Offset = Offset * -1;
  }
  return Offset;
}