xref: /openbmc/qemu/tests/tcg/s390x/ts.c (revision 2e1cacfb)
1 /*
2  * Test the TEST AND SET instruction.
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 #include <assert.h>
7 #include <stdlib.h>
8 
9 static int ts(char *p)
10 {
11     int cc;
12 
13     asm("ts %[p]\n"
14         "ipm %[cc]"
15         : [cc] "=r" (cc)
16         , [p] "+Q" (*p)
17         : : "cc");
18 
19     return (cc >> 28) & 3;
20 }
21 
22 int main(void)
23 {
24     char c;
25 
26     c = 0x80;
27     assert(ts(&c) == 1);
28     assert(c == 0xff);
29 
30     c = 0x7f;
31     assert(ts(&c) == 0);
32     assert(c == 0xff);
33 
34     return EXIT_SUCCESS;
35 }
36