aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/s390x/ts.c
blob: 441faf30d98c8fc40213fb612e3e6422d10a7b76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Test the TEST AND SET instruction.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */
#include <assert.h>
#include <stdlib.h>

static int ts(char *p)
{
    int cc;

    asm("ts %[p]\n"
        "ipm %[cc]"
        : [cc] "=r" (cc)
        , [p] "+Q" (*p)
        : : "cc");

    return (cc >> 28) & 3;
}

int main(void)
{
    char c;

    c = 0x80;
    assert(ts(&c) == 1);
    assert(c == 0xff);

    c = 0x7f;
    assert(ts(&c) == 0);
    assert(c == 0xff);

    return EXIT_SUCCESS;
}