aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/openrisc/test_lx.c
blob: 792e3d5c7fcbd051502aa0f6a4212e2fee17eeb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <stdio.h>

int main(void)
{
    int a;
    int p[50];
    int result;

    result = 0x23;
    __asm
    ("l.ori r8, r0, 0x123\n\t"
     "l.sb  0x4 + %1, r8\n\t"
     "\n\t"
     "l.lbz %0, 0x4 + %1\n\t"
     : "=r"(a), "+m"(*p)
    );
    if (a != result) {
        printf("lbz error, %x\n", a);
        return -1;
    }

    result = 0x23;
    __asm
    ("l.lbs %0, 0x4 + %1\n\t"
     : "=r"(a)
     : "m"(*p)
    );
    if (a != result) {
        printf("lbs error\n");
        return -1;
    }

    result = 0x1111;
    __asm
    ("l.ori r8, r0, 0x1111\n\t"
     "l.sh  0x20 + %1, r8\n\t"
     "\n\t"
     "l.lhs %0, 0x20 + %1\n\t"
     : "=r"(a), "=m"(*p)
    );
    if (a != result) {
        printf("lhs error, %x\n", a);
        return -1;
    }

    result = 0x1111;
    __asm
    ("l.lhz %0, 0x20 + %1\n\t"
     : "=r"(a)
     : "m"(*p)
    );
    if (a != result) {
        printf("lhz error\n");
        return -1;
    }

    result = 0x1111233;
    __asm
    ("l.ori r8, r0, 0x1233\n\t"
     "l.movhi r1, 0x111\n\t"
     "l.or  r8, r8, r1\n\t"
     "l.sw  0x123 + %1, r8\n\t"
     "\n\t"
     "l.lws %0, 0x123 + %1\n\t"
     : "=r"(a), "+m"(*p)
    );
    if (a != result) {
        printf("lws error, %x\n", a);
        return -1;
    }

    result = 0x1111233;
    __asm
    ("l.lwz %0, 0x123 + %1\n\t"
     : "=r"(a)
     : "m"(*p)
    );
    if (a != result) {
        printf("lwz error\n");
        return -1;
    }

    return 0;
}