Home | History | Annotate | Download | only in x86
      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 int32\n");
     17    __asm__ __volatile__(
     18       "movl   0(%0), %%eax\n\t"
     19       "movl   8(%0), %%edi\n\t"
     20       "xorl   %%edi, %%eax\n\t"
     21       JZ_NEXT
     22       : : "r"(junk) : "edi", "eax", "cc"
     23    );
     24 
     25    printf("\nNo complain int32\n");
     26    __asm__ __volatile__(
     27       "movl   0(%0), %%eax\n\t"
     28       "movl   8(%0), %%edi\n\t"
     29       "xorl   %%eax, %%eax\n\t"
     30       JZ_NEXT
     31       : : "r"(junk) : "edi", "eax", "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       "movl   16(%0), %%esi\n\t"
     45       "addl   20(%0), %%esi\n\t"
     46       JZ_NEXT
     47       : : "r"(junk) : "esi", "mm7", "mm0", "cc", "memory"
     48    );
     49 
     50    printf("\nNo complain mmx\n");
     51    __asm__ __volatile__(
     52       "emms\n\t"
     53       "movq   0(%0), %%mm0\n\t"
     54       "movq   8(%0), %%mm7\n\t"
     55       "pxor   %%mm0, %%mm0\n\t"
     56       "movq   %%mm0, 16(%0)\n\t"
     57       "movl   16(%0), %%esi\n\t"
     58       "addl   20(%0), %%esi\n\t"
     59       JZ_NEXT
     60       : : "r"(junk) : "esi", "mm7", "mm0", "cc", "memory"
     61    );
     62 
     63 
     64    /* --- SSE1 --- */
     65 
     66    printf("\nComplain sse xorps\n");
     67    __asm__ __volatile__(
     68       "movups   0(%0),  %%xmm0\n\t"
     69       "movups   16(%0), %%xmm7\n\t"
     70       "xorps    %%xmm7, %%xmm0\n\t"
     71       "movups   %%xmm0, 32(%0)\n\t"
     72       "movl 32(%0), %%esi\n\t"
     73       "addl 36(%0), %%esi\n\t"
     74       "addl 40(%0), %%esi\n\t"
     75       "addl 44(%0), %%esi\n\t"
     76       JZ_NEXT
     77       : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
     78    );
     79 
     80    printf("\nNo complain sse xorps\n");
     81    __asm__ __volatile__(
     82       "movups   0(%0),  %%xmm0\n\t"
     83       "movups   16(%0), %%xmm7\n\t"
     84       "xorps    %%xmm0, %%xmm0\n\t"
     85       "movups   %%xmm0, 32(%0)\n\t"
     86       "movl 32(%0), %%esi\n\t"
     87       "addl 36(%0), %%esi\n\t"
     88       "addl 40(%0), %%esi\n\t"
     89       "addl 44(%0), %%esi\n\t"
     90       JZ_NEXT
     91       : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
     92    );
     93 
     94 
     95    /* --- SSE2 --- */
     96 #if 0
     97    printf("\nComplain sse2 pxor\n");
     98    __asm__ __volatile__(
     99       "movups   0(%0),  %%xmm0\n\t"
    100       "movups   16(%0), %%xmm7\n\t"
    101       "pxor     %%xmm7, %%xmm0\n\t"
    102       "movups   %%xmm0, 32(%0)\n\t"
    103       "movl 32(%0), %%esi\n\t"
    104       "addl 36(%0), %%esi\n\t"
    105       "addl 40(%0), %%esi\n\t"
    106       "addl 44(%0), %%esi\n\t"
    107       JZ_NEXT
    108       : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
    109    );
    110 
    111    printf("\nNo complain sse2 pxor\n");
    112    __asm__ __volatile__(
    113       "movups   0(%0),  %%xmm0\n\t"
    114       "movups   16(%0), %%xmm7\n\t"
    115       "pxor     %%xmm0, %%xmm0\n\t"
    116       "movups   %%xmm0, 32(%0)\n\t"
    117       "movl 32(%0), %%esi\n\t"
    118       "addl 36(%0), %%esi\n\t"
    119       "addl 40(%0), %%esi\n\t"
    120       "addl 44(%0), %%esi\n\t"
    121       JZ_NEXT
    122       : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
    123    );
    124 
    125 
    126    printf("\nComplain sse2 xorpd\n");
    127    __asm__ __volatile__(
    128       "movups   0(%0),  %%xmm0\n\t"
    129       "movups   16(%0), %%xmm7\n\t"
    130       "xorpd    %%xmm7, %%xmm0\n\t"
    131       "movups   %%xmm0, 32(%0)\n\t"
    132       "movl 32(%0), %%esi\n\t"
    133       "addl 36(%0), %%esi\n\t"
    134       "addl 40(%0), %%esi\n\t"
    135       "addl 44(%0), %%esi\n\t"
    136       JZ_NEXT
    137       : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
    138    );
    139 
    140    printf("\nNo complain sse2 xorpd\n");
    141    __asm__ __volatile__(
    142       "movups   0(%0),  %%xmm0\n\t"
    143       "movups   16(%0), %%xmm7\n\t"
    144       "xorpd    %%xmm0, %%xmm0\n\t"
    145       "movups   %%xmm0, 32(%0)\n\t"
    146       "movl 32(%0), %%esi\n\t"
    147       "addl 36(%0), %%esi\n\t"
    148       "addl 40(%0), %%esi\n\t"
    149       "addl 44(%0), %%esi\n\t"
    150       JZ_NEXT
    151       : : "r"(junk) : "esi", "xmm7", "xmm0", "cc", "memory"
    152    );
    153 #endif
    154 
    155    free(junk);
    156    return 0;
    157 }
    158