__OFSUB__宏

生成(x-y)的溢出标志

定义如下:

// overflow flag of subtraction (x-y)
template int8 __OFSUB__(T x, U y)
{
  if ( sizeof(T) < sizeof(U) )
  {
    U x2 = x;
    int8 sx = __SETS__(x2);
    return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y));
  }
  else
  {
    T y2 = y;
    int8 sx = __SETS__(x);
    return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x-y2));
  }
}

中间使用的__SETS__如下:

// sign flag
template int8 __SETS__(T x)
{
  if ( sizeof(T) == 1 )
    return int8(x) < 0;
  if ( sizeof(T) == 2 )
    return int16(x) < 0;
  if ( sizeof(T) == 4 )
    return int32(x) < 0;
  return int64(x) < 0;
}

使用到的结构如下

typedef          char    int8;
typedef   signed char    sint8;
typedef unsigned char    uint8;
typedef          short   int16;
typedef   signed short   sint16;
typedef unsigned short   uint16;
typedef          int     int32;
typedef   signed int     sint32;
typedef unsigned int     uint32;
typedef __int64          int64;
typedef __int64          sint64;
typedef unsigned __int64 uint64;

参考链接:https://stackoom.com/question/1ZDLT/IDA-PRO%E5%B0%86C-%E4%BB%A3%E7%A0%81%E8%BD%AC%E6%8D%A2%E4%B8%BAC%E4%BB%A3%E7%A0%81-OFSUB-%E5%AE%8F

你可能感兴趣的:(反汇编,IDA,__OFSUB__,__SETS__)