Home | History | Annotate | Download | only in amd64
      1 
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <assert.h>
      5 
      6 #define JZ_NEXT ".byte 0x74,0x00"  /* jz the-next-insn */
      7 
      8 int main ( void )
      9 {
     10    char* junk = malloc(48);
     11    assert(junk);
     12 
     13 
     14    /* --- INTEGER --- */
     15 
     16    printf("\nComplain int64\n");
     17    __asm__ __volatile__(
     18       "movq   0(%0), %%rax\n\t"
     19       "movq   8(%0), %%r8\n\t"
     20       "xorq   %%r8, %%rax\n\t"
     21       JZ_NEXT
     22       : : "r"(junk) : "r8", "rax", "cc"
     23    );
     24 
     25    printf("\nNo complain int64\n");
     26    __asm__ __volatile__(
     27       "movq   0(%0), %%rax\n\t"
     28       "movq   8(%0), %%r8\n\t"
     29       "xorq   %%rax, %%rax\n\t"
     30       JZ_NEXT
     31       : : "r"(junk) : "r8", "rax", "cc"
     32    );
     33 
     34 
     35    /* --- MMX --- */
     36 
     37    printf("\nComplain mmx\n");
     38    __asm__ __volatile__(
     39       "emms\n\t"
     40       "movq   0(%0), %%mm0\n\t"
     41       "movq   8(%0), %%mm7\n\t"
     42       "pxor   %%mm7, %%mm0\n\t"
     43       "movq   %%mm0, 16(%0)\n\t"
     44       "cmpq   $0,16(%0)\n\t"
     45       JZ_NEXT
     46       : : "r"(junk) : "mm7", "mm0", "cc", "memory"
     47    );
     48 
     49    printf("\nNo complain mmx\n");
     50    __asm__ __volatile__(
     51       "emms\n\t"
     52       "movq   0(%0), %%mm0\n\t"
     53       "movq   8(%0), %%mm7\n\t"
     54       "pxor   %%mm0, %%mm0\n\t"
     55       "movq   %%mm0, 16(%0)\n\t"
     56       "cmpq   $0,16(%0)\n\t"
     57       JZ_NEXT
     58       : : "r"(junk) : "mm7", "mm0", "cc", "memory"
     59    );
     60 
     61 
     62    /* --- SSE1 --- */
     63 
     64    printf("\nComplain sse xorps\n");
     65    __asm__ __volatile__(
     66       "movups   0(%0),  %%xmm0\n\t"
     67       "movups   16(%0), %%xmm8\n\t"
     68       "xorps    %%xmm8, %%xmm0\n\t"
     69       "movups   %%xmm0, 32(%0)\n\t"
     70       "movq 32(%0), %%rax\n\t"
     71       "addq 40(%0), %%rax\n\t"
     72       JZ_NEXT
     73       : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
     74    );
     75 
     76    printf("\nNo complain sse xorps\n");
     77    __asm__ __volatile__(
     78       "movups   0(%0),  %%xmm0\n\t"
     79       "movups   16(%0), %%xmm8\n\t"
     80       "xorps    %%xmm0, %%xmm0\n\t"
     81       "movups   %%xmm0, 32(%0)\n\t"
     82       "movq 32(%0), %%rax\n\t"
     83       "addq 40(%0), %%rax\n\t"
     84       JZ_NEXT
     85       : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
     86    );
     87 
     88 
     89    /* --- SSE2 --- */
     90 
     91    printf("\nComplain sse2 pxor\n");
     92    __asm__ __volatile__(
     93       "movups   0(%0),  %%xmm0\n\t"
     94       "movups   16(%0), %%xmm8\n\t"
     95       "pxor     %%xmm8, %%xmm0\n\t"
     96       "movups   %%xmm0, 32(%0)\n\t"
     97       "movq 32(%0), %%rax\n\t"
     98       "addq 40(%0), %%rax\n\t"
     99       JZ_NEXT
    100       : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
    101    );
    102 
    103    printf("\nNo complain sse2 pxor\n");
    104    __asm__ __volatile__(
    105       "movups   0(%0),  %%xmm0\n\t"
    106       "movups   16(%0), %%xmm8\n\t"
    107       "pxor     %%xmm0, %%xmm0\n\t"
    108       "movups   %%xmm0, 32(%0)\n\t"
    109       "movq 32(%0), %%rax\n\t"
    110       "addq 40(%0), %%rax\n\t"
    111       JZ_NEXT
    112       : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
    113    );
    114 
    115 
    116    printf("\nComplain sse2 xorpd\n");
    117    __asm__ __volatile__(
    118       "movups   0(%0),  %%xmm0\n\t"
    119       "movups   16(%0), %%xmm8\n\t"
    120       "xorpd    %%xmm8, %%xmm0\n\t"
    121       "movups   %%xmm0, 32(%0)\n\t"
    122       "movq 32(%0), %%rax\n\t"
    123       "addq 40(%0), %%rax\n\t"
    124       JZ_NEXT
    125       : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
    126    );
    127 
    128    printf("\nNo complain sse2 xorpd\n");
    129    __asm__ __volatile__(
    130       "movups   0(%0),  %%xmm0\n\t"
    131       "movups   16(%0), %%xmm8\n\t"
    132       "xorpd    %%xmm0, %%xmm0\n\t"
    133       "movups   %%xmm0, 32(%0)\n\t"
    134       "movq 32(%0), %%rax\n\t"
    135       "addq 40(%0), %%rax\n\t"
    136       JZ_NEXT
    137       : : "r"(junk) : "rax", "xmm8", "xmm0", "cc", "memory"
    138    );
    139 
    140 
    141    free(junk);
    142    return 0;
    143 }
    144