xref: /openbmc/qemu/tests/tcg/s390x/lae.c (revision 7618fffd)
1 /*
2  * Test the LOAD ADDRESS EXTENDED instruction.
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 #include <assert.h>
7 #include <stdlib.h>
8 
9 int main(void)
10 {
11     unsigned long long ar = -1, b2 = 100000, r, x2 = 500;
12     /*
13      * Hardcode the register number, since clang does not allow using %rN in
14      * place of %aN.
15      */
16     register unsigned long long r2 __asm__("2");
17     int tmp;
18 
19     asm("ear %[tmp],%%a2\n"
20         "lae %%r2,42(%[x2],%[b2])\n"
21         "ear %[ar],%%a2\n"
22         "sar %%a2,%[tmp]"
23         : [tmp] "=&r" (tmp), "=&r" (r2), [ar] "+r" (ar)
24         : [b2] "r" (b2), [x2] "r" (x2)
25         : "memory");
26     r = r2;
27     assert(ar == 0xffffffff00000000ULL);
28     assert(r == 100542);
29 
30     return EXIT_SUCCESS;
31 }
32