Home | History | Annotate | Download | only in s390x
      1 #include <stdint.h>
      2 #include <stdio.h>
      3 #include <string.h>
      4 
      5 void
      6 test(int64_t op1_init, int64_t op2_init, int64_t op3_init, int expected_cc)
      7 {
      8    register int64_t op1 asm("8") = op1_init;
      9    register int64_t op3 asm("9") = op3_init;
     10 
     11    int64_t op2 = op2_init;
     12    int cc = 1 - expected_cc;
     13 
     14    printf("before op1 = %#lx\n", op1);
     15    printf("before op2 = %#lx\n", op2);
     16    printf("before op3 = %#lx\n", op3);
     17 
     18    __asm__ volatile (
     19            "csg     8,9,%1\n\t"
     20            "ipm     %0\n\t"
     21            "srl     %0,28\n\t"
     22            : "=d" (cc), "+Q" (op2), "+d"(op1), "+d"(op3)
     23            :
     24            : "cc");
     25 
     26    printf("after  op1 = %#lx\n", op1);
     27    printf("after  op2 = %#lx\n", op2);
     28    printf("after  op3 = %#lx\n", op3);
     29    printf("cc = %d\n", cc);
     30 
     31    if (cc != expected_cc) {
     32       printf("condition code is incorrect\n");
     33    }
     34    if (expected_cc == 0) {
     35       if (op2 != op3) {
     36          printf("operand #2 not updated\n");
     37       }
     38    } else {
     39       if (op1 != op2) {
     40          printf("operand #1 not updated\n");
     41       }
     42    }
     43 }
     44 
     45 int main ()
     46 {
     47    test(0x1000000000000000ull, 0x1000000000000000ull, 0x1234567887654321ull, 0);
     48    test(0x1000000000000000ull, 0x2000000000000000ull, 0x1234567887654321ull, 1);
     49 
     50    return 0;
     51 }
     52