xref: /openbmc/qemu/tests/tcg/s390x/larl.c (revision 6fdc5bc1)
1 /*
2  * Test the LARL instruction.
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 #include <stdlib.h>
7 
8 int main(void)
9 {
10     long algfi = (long)main;
11     long larl;
12 
13     /*
14      * The compiler may emit larl for the C addition, so compute the expected
15      * value using algfi.
16      */
17     asm("algfi %[r],0xd0000000" : [r] "+r" (algfi) : : "cc");
18     asm("larl %[r],main+0xd0000000" : [r] "=r" (larl));
19 
20     return algfi == larl ? EXIT_SUCCESS : EXIT_FAILURE;
21 }
22