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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
// MAC test program.
// Test basic edge values
// UNSIGNED FRACTIONAL mode U
// test ops: "+=" "-="
# mach: bfin
.include "testutils.inc"
start
// load r0=0x80007fff
// load r1=0x80007fff
// load r2=0xf0000000
// load r3=0x0000007f
// load r4=0x00000080
// load r5=0xffffffff
loadsym P0, data0;
R0 = [ P0 ++ ];
R1 = [ P0 ++ ];
R2 = [ P0 ++ ];
R3 = [ P0 ++ ];
R4 = [ P0 ++ ];
R5 = [ P0 ++ ];
dbga(r0.h, 0x8000);
dbga(r0.l, 0x7fff);
dbga(r1.h, 0x8000);
dbga(r1.l, 0x7fff);
dbga(r2.h, 0xf000);
dbga(r2.l, 0);
// 0x8000 * 0x7fff = 0x003fff8000
A1 = A0 = 0;
A1 += R0.H * R1.L, A0 += R0.H * R1.L (FU);
R6 = A1.w;
R7.L = A1.x;
DBGA ( R6.L , 0x8000 );
DBGA ( R6.H , 0x3fff );
DBGA ( R7.L , 0x0000 );
R6 = A0.w;
R7.L = A0.x;
DBGA ( R6.L , 0x8000 );
DBGA ( R6.H , 0x3fff );
DBGA ( R7.L , 0x0000 );
// 0x8000 * 0x8000 = 0x0040000000
A1 = A0 = 0;
A1 += R0.H * R1.H, A0 += R0.H * R1.H (FU);
R6 = A1.w;
R7.L = A1.x;
DBGA ( R6.L , 0x0000 );
DBGA ( R6.H , 0x4000 );
DBGA ( R7.L , 0x0000 );
R6 = A0.w;
R7.L = A0.x;
DBGA ( R6.L , 0x0000 );
DBGA ( R6.H , 0x4000 );
DBGA ( R7.L , 0x0000 );
// 0xffff * 0xffff = 0x00fffe0001
A1 = A0 = 0;
A1 += R5.H * R5.H, A0 += R5.H * R5.H (FU);
R6 = A1.w;
R7.L = A1.x;
DBGA ( R6.L , 0x0001 );
DBGA ( R6.H , 0xfffe );
DBGA ( R7.L , 0x0000 );
R6 = A0.w;
R7.L = A0.x;
DBGA ( R6.L , 0x0001 );
DBGA ( R6.H , 0xfffe );
DBGA ( R7.L , 0x0000 );
// saturate high by first loading large value into accums
// expected value is 0xffffffffff
A1 = A0 = 0;
A1.w = R5;
A1.x = R5.L;
A0.w = R5;
A0.x = R5.L;
A1 += R5.H * R5.H, A0 += R5.H * R5.H (FU);
R6 = A1.w;
R7.L = A1.x;
DBGA ( R6.L , 0xffff );
DBGA ( R6.H , 0xffff );
DBGA ( R7.L , 0xffff );
R6 = A0.w;
R7.L = A0.x;
DBGA ( R6.L , 0xffff );
DBGA ( R6.H , 0xffff );
DBGA ( R7.L , 0xffff );
// saturate low with "-="
// expected value is 0x0000000000
A1 = A0 = 0;
A1 -= R4.L * R4.L, A0 -= R4.L * R4.L (FU);
R6 = A1.w;
R7.L = A1.x;
DBGA ( R6.L , 0x0000 );
DBGA ( R6.H , 0x0000 );
DBGA ( R7.L , 0x0000 );
R6 = A0.w;
R7.L = A0.x;
DBGA ( R6.L , 0x0000 );
DBGA ( R6.H , 0x0000 );
DBGA ( R7.L , 0x0000 );
// saturate low with "-="
// expected value is 0x0000000000
A1 = A0 = 0;
A1 -= R1.H * R0.H, A0 -= R1.H * R0.H (FU);
R6 = A1.w;
R7.L = A1.x;
DBGA ( R6.L , 0x0000 );
DBGA ( R6.H , 0x0000 );
DBGA ( R7.L , 0x0000 );
R6 = A0.w;
R7.L = A0.x;
DBGA ( R6.L , 0x0000 );
DBGA ( R6.H , 0x0000 );
DBGA ( R7.L , 0x0000 );
pass
.data
data0:
.dw 0x7fff
.dw 0x8000
.dw 0x7fff
.dw 0x8000
.dw 0x0000
.dw 0xf000
.dw 0x007f
.dw 0x0000
.dw 0x0080
.dw 0x0000
.dw 0xffff
.dw 0xffff
|