Tag: intel

未定义引用`WinMain @ 16’colle2.exe:错误:ld返回1退出状态

我使用eclipse CDT测试Intel指令,下面是我的程序: #define cpuid(func,ax,bx,cx,dx)\ __asm__ __volatile__ (“cpuid”:\ “=a” (ax), “=b” (bx), “=c” (cx), “=d” (dx) : “a” (func)); int Check_CPU_support_AES() { unsigned int a,b,c,d; cpuid(1, a,b,c,d); return (c & 0x2000000); } 当我编译上面的代码时,我得到链接错误: Info: Internal Builder is used for build gcc -O0 -g3 -Wall -c -fmessage-length=0 -o “src\\Intel.o” “..\\src\\Intel.c” gcc -o Intel.exe “src\\Intel.o” c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference […]

__m128i变量是零吗?

如何测试__m128i变量在SSE-2和更早版本的处理器上是否具有任何非零值?

对齐和SSE奇怪的行为

我尝试与SSE合作,我遇到了一些奇怪的行为。 我编写简单的代码来比较两个字符串与SSE内在函数,运行它并且它工作。 但后来我明白了,在我的代码中,一个指针仍未对齐,但我使用_mm_load_si128指令,这需要指针在16字节边界上对齐。 //Compare two different, not overlapping piece of memory __attribute((target(“avx”))) int is_equal(const void* src_1, const void* src_2, size_t size) { //Skip tail for right alignment of pointer [head_1] const char* head_1 = (const char*)src_1; const char* head_2 = (const char*)src_2; size_t tail_n = 0; while (((uintptr_t)head_1 % 16) != 0 && tail_n < […]

检查是否设置了进位标志

使用内联汇编程序[gcc,intel,c],如何在操作后检查进位标志是否设置?

除非Haswell指明,否则GCC会很难编制前导零数

GCC支持__builtin_clz(int x) builtin,它计算参数中前导零 (连续最重要的零)的数量。 除了0之外 ,这对于有效地实现lg(unsigned int x)函数非常有用,它取lg(unsigned int x)的基数为2的对数,向下舍入为1 : /** return the base-2 log of x, where x > 0 */ unsigned lg(unsigned x) { return 31U – (unsigned)__builtin_clz(x); } 这是直截了当的方式 – 特别是考虑情况x == 1和clz(x) == 31 – 然后x == 2^0所以lg(x) == 0和31 – 31 == 0我们得到正确的结果。 较高的x值类似地起作用。 假设内置程序有效实现,这比其他纯C解决方案更好。 现在,它发生了, 计数前导零操作本质上是x86中bsr指令的双重。 返回参数中最重要的1位2的索引。 因此,如果有10个前导零,则第一个1位位于参数的第21位。 […]