xref: /openbmc/qemu/tests/tcg/s390x/epsw.c (revision f5c2ae71)
1*f5c2ae71SIlya Leoshkevich /*
2*f5c2ae71SIlya Leoshkevich  * Test the EPSW instruction.
3*f5c2ae71SIlya Leoshkevich  *
4*f5c2ae71SIlya Leoshkevich  * SPDX-License-Identifier: GPL-2.0-or-later
5*f5c2ae71SIlya Leoshkevich  */
6*f5c2ae71SIlya Leoshkevich #include <assert.h>
7*f5c2ae71SIlya Leoshkevich #include <stdlib.h>
8*f5c2ae71SIlya Leoshkevich 
main(void)9*f5c2ae71SIlya Leoshkevich int main(void)
10*f5c2ae71SIlya Leoshkevich {
11*f5c2ae71SIlya Leoshkevich     unsigned long r1 = 0x1234567887654321UL, r2 = 0x8765432112345678UL;
12*f5c2ae71SIlya Leoshkevich 
13*f5c2ae71SIlya Leoshkevich     asm("cr %[r1],%[r2]\n"  /* cc = 1 */
14*f5c2ae71SIlya Leoshkevich         "epsw %[r1],%[r2]"
15*f5c2ae71SIlya Leoshkevich         : [r1] "+r" (r1), [r2] "+r" (r2) : : "cc");
16*f5c2ae71SIlya Leoshkevich 
17*f5c2ae71SIlya Leoshkevich     /* Do not check the R and RI bits. */
18*f5c2ae71SIlya Leoshkevich     r1 &= ~0x40000008UL;
19*f5c2ae71SIlya Leoshkevich     assert(r1 == 0x1234567807051001UL);
20*f5c2ae71SIlya Leoshkevich     assert(r2 == 0x8765432180000000UL);
21*f5c2ae71SIlya Leoshkevich 
22*f5c2ae71SIlya Leoshkevich     return EXIT_SUCCESS;
23*f5c2ae71SIlya Leoshkevich }
24