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