aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/mips/mips64-dsp/addq_s_ph.c
blob: ad84cdcfe0c93bd932d8dba35ad82d51cbfa4e0e (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 "io.h"

int main(void)
{
    long long rd, rs, rt;
    long long dsp;
    long long result;

    rs     = 0xFFFFFFFF;
    rt     = 0x10101010;
    result = 0x100F100F;
    __asm
        ("addq_s.ph   %0, %1, %2\n\t"
         : "=r"(rd)
         : "r"(rs), "r"(rt)
        );
    if (rd != result) {
        printf("1 addq_s.ph wrong\n");

        return -1;
    }

    rs     = 0x3712847D;
    rt     = 0x0031AF2D;
    result = 0x37438000;
    __asm
        ("addq_s.ph   %0, %1, %2\n\t"
         : "=r"(rd)
         : "r"(rs), "r"(rt)
        );

    __asm
        ("rddsp %0\n\t"
         : "=r"(dsp)
        );

    if ((rd != result) || (((dsp >> 20) & 0x01) != 1)) {
        printf("2 addq_s.ph wrong\n");

        return -1;
    }

    rs     = 0x7fff847D;
    rt     = 0x0031AF2D;
    result = 0x7fff8000;
    __asm
        ("addq_s.ph   %0, %1, %2\n\t"
         : "=r"(rd)
         : "r"(rs), "r"(rt)
        );

    __asm
        ("rddsp %0\n\t"
         : "=r"(dsp)
        );

    if ((rd != result) || (((dsp >> 20) & 0x01) != 1)) {
        printf("3 addq_s.ph wrong\n");

        return -1;
    }

    rs     = 0x8030847D;
    rt     = 0x8a00AF2D;
    result = 0xffffffff80008000;
    __asm
        ("addq_s.ph   %0, %1, %2\n\t"
         : "=r"(rd)
         : "r"(rs), "r"(rt)
        );

    __asm
        ("rddsp %0\n\t"
         : "=r"(dsp)
        );

    if ((rd != result) || (((dsp >> 20) & 0x01) != 1)) {
        printf("4 addq_s.ph wrong\n");

        return -1;
    }

    return 0;
}