Home | History | Annotate | Download | only in amd64
      1 
      2 #include <stdio.h>
      3 
      4 typedef unsigned long long int ULong;
      5 
      6 ULong do_clc ( void )
      7 {
      8   ULong res;
      9   __asm__ __volatile__(
     10      "pushq $0x8d5\n\t" /* OSZACP */
     11      "popfq\n\t"
     12      "clc\n\t"
     13      "pushfq\n\t"
     14      "popq %0"
     15      : "=r"(res)
     16      :
     17      : "memory", "cc"
     18      );
     19   return res;
     20 }
     21 
     22 ULong do_stc ( void )
     23 {
     24   ULong res;
     25   __asm__ __volatile__(
     26      "pushq $0x0\n\t"
     27      "popfq\n\t"
     28      "stc\n\t"
     29      "pushfq\n\t"
     30      "popq %0"
     31      : "=r"(res)
     32      :
     33      : "memory", "cc"
     34      );
     35   return res;
     36 }
     37 
     38 ULong do_cmc ( void )
     39 {
     40   ULong res;
     41   __asm__ __volatile__(
     42      "pushq $0x0\n\t"
     43      "popfq\n\t"
     44      "stc\n\t"
     45      "cmc\n\t"
     46      "pushfq\n\t"
     47      "popq %0"
     48      : "=r"(res)
     49      :
     50      : "memory", "cc"
     51      );
     52   return res;
     53 }
     54 
     55 int main ( void )
     56 {
     57   printf("clc: 0x%016llx\n", 0x8d5 & do_clc());
     58   printf("stc: 0x%016llx\n", 0x8d5 & do_stc());
     59   printf("cmc: 0x%016llx\n", 0x8d5 & do_cmc());
     60   return 0;
     61 }
     62