_bittestandcomplement、_bittestandcomplement64

Microsoft 专用

生成可以检查地址 b 的位 a 的指令,返回其当前值,然后将位设置为该值的补充值。

语法

unsigned char _bittestandcomplement(
   long *a,
   long b
);
unsigned char _bittestandcomplement64(
   __int64 *a,
   __int64 b
);

参数

a
[in, out] 指向要检查的内存的指针。

b
[in] 要测试的位位置。

返回值

指定位置的位。

要求

Intrinsic 体系结构
_bittestandcomplement x86、ARM、x64、ARM64
_bittestandcomplement64 x64、ARM64

头文件<intrin.h>

注解

此例程仅可用作内部函数。

示例

// bittestandcomplement.cpp
// processor: x86, IPF, x64
#include <stdio.h>
#include <intrin.h>

#pragma intrinsic(_bittestandcomplement)
#ifdef _M_AMD64
#pragma intrinsic(_bittestandcomplement64)
#endif

int main()
{
   long i = 1;
   __int64 i64 = 0x1I64;
   unsigned char result;
   printf("Initial value: %d\n", i);
   printf("Testing bit 1\n");
   result = _bittestandcomplement(&i, 1);
   printf("Value changed to %d, Result: %d\n", i, result);
#ifdef _M_AMD64
   printf("Testing bit 0\n");
   result = _bittestandcomplement64(&i64, 0);
   printf("Value changed to %I64d, Result: %d\n", i64, result);
#endif
}
Initial value: 1
Testing bit 1
Value changed to 3, Result: 0
Testing bit 0
Value changed to 0, Result: 1

结束 Microsoft 专用

另请参阅

编译器内部函数