aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/s390x/larl.c
blob: 7c95f89be73e729030d254a2c19eefbf5c7618ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * Test the LARL instruction.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */
#include <stdlib.h>

int main(void)
{
    long algfi = (long)main;
    long larl;

    /*
     * The compiler may emit larl for the C addition, so compute the expected
     * value using algfi.
     */
    asm("algfi %[r],0xd0000000" : [r] "+r" (algfi) : : "cc");
    asm("larl %[r],main+0xd0000000" : [r] "=r" (larl));

    return algfi == larl ? EXIT_SUCCESS : EXIT_FAILURE;
}