1 #include<stdio.h>
2 #include<assert.h>
3
main()4 int main()
5 {
6 int rd, rs, rt;
7 int dsp;
8 int result;
9
10 rs = 0xFFFFFFFF;
11 rt = 0x10101010;
12 result = 0x100F100F;
13 __asm
14 ("addq.ph %0, %1, %2\n\t"
15 : "=r"(rd)
16 : "r"(rs), "r"(rt)
17 );
18 assert(result == rd);
19
20 rs = 0x3712847D;
21 rt = 0x0031AF2D;
22 result = 0x374333AA;
23 __asm
24 ("addq.ph %0, %1, %2\n\t"
25 : "=r"(rd)
26 : "r"(rs), "r"(rt)
27 );
28 assert(result == rd);
29
30 rs = 0x7fff847D;
31 rt = 0x0031AF2D;
32 result = 0x803033AA;
33 __asm
34 ("addq.ph %0, %1, %2\n\t"
35 : "=r"(rd)
36 : "r"(rs), "r"(rt)
37 );
38 assert(result == rd);
39
40 __asm("rddsp %0\n\t"
41 : "=r"(dsp)
42 );
43 assert(((dsp >> 20) & 0x01) == 1);
44
45 return 0;
46 }
47