qemu/tests/tcg/s390x/ts.c
Ilya Leoshkevich f9b29c6364 tests/tcg/s390x: Test TEST AND SET
Add a small test to prevent regressions.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20240318202722.20675-2-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2024-03-25 15:05:59 +01:00

36 lines
494 B
C

/*
* 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;
}