aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/mips/mips64-dsp/mthlip.c
blob: 957cd426f0012c9f912375c833b528b53df75ff3 (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
#include "io.h"

int main(void)
{
    long long rs, ach, acl, dsp;
    long long result, resulth, resultl;

    dsp = 0x07;
    ach = 0x05;
    acl = 0xB4CB;
    rs  = 0x00FFBBAA;
    resulth = 0xB4CB;
    resultl = 0x00FFBBAA;
    result  = 0x27;

    __asm
        ("wrdsp %0, 0x01\n\t"
         "mthi %1, $ac1\n\t"
         "mtlo %2, $ac1\n\t"
         "mthlip %3, $ac1\n\t"
         "mfhi %1, $ac1\n\t"
         "mflo %2, $ac1\n\t"
         "rddsp %0\n\t"
         : "+r"(dsp), "+r"(ach), "+r"(acl)
         : "r"(rs)
        );
    dsp = dsp & 0x3F;
    if ((dsp != result) || (ach != resulth) || (acl != resultl)) {
        printf("mthlip wrong\n");

        return -1;
    }

    dsp = 0x3f;
    ach = 0x05;
    acl = 0xB4CB;
    rs  = 0x00FFBBAA;
    resulth = 0xB4CB;
    resultl = 0x00FFBBAA;
    result  = 0x3f;

    __asm
        ("wrdsp %0, 0x01\n\t"
         "mthi %1, $ac1\n\t"
         "mtlo %2, $ac1\n\t"
         "mthlip %3, $ac1\n\t"
         "mfhi %1, $ac1\n\t"
         "mflo %2, $ac1\n\t"
         "rddsp %0\n\t"
         : "+r"(dsp), "+r"(ach), "+r"(acl)
         : "r"(rs)
        );
    dsp = dsp & 0x3F;
    if ((dsp != result) || (ach != resulth) || (acl != resultl)) {
        printf("mthlip wrong\n");

        return -1;
    }

    return 0;
}