1// MAC test program. 2// Test basic edge values 3// SIGNED FRACTIONAL mode 4// test ops: "+=" "-=" "=" "NOP" 5# mach: bfin 6 7.include "testutils.inc" 8 start 9 10 11// load r0=0x80007fff 12// load r1=0x80007fff 13// load r2=0xf0000000 14// load r3=0x0000007f 15// load r4=0x00000080 16 loadsym P0, data0; 17 R0 = [ P0 ++ ]; 18 R1 = [ P0 ++ ]; 19 R2 = [ P0 ++ ]; 20 R3 = [ P0 ++ ]; 21 R4 = [ P0 ++ ]; 22 23// 0x7fff * 0x7fff = 0x007ffe0002 24 R7 = 0; 25 ASTAT = R7; 26 A1 = A0 = 0; 27 A1 += R0.L * R1.L, A0 += R0.L * R1.L; 28 R6 = A1.w; 29 _DBG ASTAT; 30 _DBG A0; 31 R7.L = A1.x; 32 _DBG ASTAT; 33 DBGA ( R6.L , 0x0002 ); 34 DBGA ( R6.H , 0x7ffe ); 35 DBGA ( R7.L , 0x0000 ); 36 CC = AZ; R7 = CC; DBGA ( R7.L , 0x0 ); 37 CC = AN; R7 = CC; DBGA ( R7.L , 0x0 ); 38 CC = AC0; R7 = CC; DBGA ( R7.L , 0x0 ); 39 CC = AV0; R7 = CC; DBGA ( R7.L , 0x0 ); 40 CC = AV1; R7 = CC; DBGA ( R7.L , 0x0 ); 41 42// 0x8000 * 0x7fff = 0xff80010000 43 R7 = 0; 44 ASTAT = R7; 45 A1 = A0 = 0; 46 A1 += R0.H * R1.L, A0 += R0.H * R1.L; 47 R6 = A1.w; 48 R7.L = A1.x; 49 DBGA ( R6.L , 0x0000 ); 50 DBGA ( R6.H , 0x8001 ); 51 DBGA ( R7.L , 0xffff ); 52 _DBG ASTAT; 53 R7 = ASTAT; 54 DBGA (R7.H, 0x0); 55 DBGA (R7.L, 0x0); 56 57// 0x8000 * 0x8000 = 0x007fffffff 58 R7 = 0; 59 ASTAT = R7; 60 A1 = A0 = 0; 61 A1 += R0.H * R1.H, A0 += R0.H * R1.H; 62 R6 = A1.w; 63 R7.L = A1.x; 64 DBGA ( R6.L , 0x0000 ); 65 DBGA ( R6.H , 0x8000 ); 66 DBGA ( R7.L , 0x0000 ); 67 CC = AZ; R7 = CC; DBGA ( R7.L , 0x0 ); 68 CC = AN; R7 = CC; DBGA ( R7.L , 0x0 ); 69 CC = AC0; R7 = CC; DBGA ( R7.L , 0x0 ); 70 CC = AV0; R7 = CC; DBGA ( R7.L , 0x0 ); 71 CC = AV1; R7 = CC; DBGA ( R7.L , 0x0 ); 72 73// saturate positive by first loading large value into accums 74// expected value is 0x7fffffffff 75 R7 = 0; 76 ASTAT = R7; 77 A1 = A0 = 0; 78 A1.w = R2; 79 A1.x = R3.L; 80 A0.w = R2; 81 A0.x = R3.L; 82 A1 += R0.L * R1.L, A0 += R0.L * R1.L; 83 R6 = A1.w; 84 R7.L = A1.x; 85 DBGA ( R6.L , 0xffff ); 86 DBGA ( R6.H , 0xffff ); 87 DBGA ( R7.L , 0x007f ); 88 CC = AZ; R7 = CC; DBGA ( R7.L , 0x0 ); 89 CC = AN; R7 = CC; DBGA ( R7.L , 0x0 ); 90 CC = AC0; R7 = CC; DBGA ( R7.L , 0x0 ); 91 CC = AV0; R7 = CC; DBGA ( R7.L , 0x1 ); 92 CC = AV1; R7 = CC; DBGA ( R7.L , 0x1 ); 93 94// saturate negative 95// expected value is 0x8000000000 96 R7 = 0; 97 ASTAT = R7; 98 A1 = A0 = 0; 99 A1.x = R4.L; 100 A0.x = R4.L; 101 A1 += R0.L * R1.H, A0 += R0.L * R1.H; 102 R6 = A1.w; 103 _DBG ASTAT; 104 R7.L = A1.x; 105 _DBG ASTAT; 106 DBGA ( R6.L , 0x0000 ); 107 DBGA ( R6.H , 0x0000 ); 108 DBGA ( R7.L , 0xff80 ); 109 CC = AZ; R7 = CC; DBGA ( R7.L , 0x0 ); 110 CC = AN; R7 = CC; DBGA ( R7.L , 0x0 ); 111 CC = AC0; R7 = CC; DBGA ( R7.L , 0x0 ); 112 CC = AV0; R7 = CC; DBGA ( R7.L , 0x1 ); 113 CC = AV1; R7 = CC; DBGA ( R7.L , 0x1 ); 114 115// saturate positive with "-=" 116// expected value is 0x7fffffffff 117 R7 = 0; 118 ASTAT = R7; 119 A1 = A0 = 0; 120 A1.w = R2; 121 A1.x = R3.L; 122 A0.w = R2; 123 A0.x = R3.L; 124 A1 -= R0.H * R1.L, A0 -= R0.H * R1.L; 125 R6 = A1.w; 126 R7.L = A1.x; 127 DBGA ( R6.L , 0xffff ); 128 DBGA ( R6.H , 0xffff ); 129 DBGA ( R7.L , 0x007f ); 130 CC = AZ; R7 = CC; DBGA ( R7.L , 0x0 ); 131 CC = AN; R7 = CC; DBGA ( R7.L , 0x0 ); 132 CC = AC0; R7 = CC; DBGA ( R7.L , 0x0 ); 133 CC = AV0; R7 = CC; DBGA ( R7.L , 0x1 ); 134 CC = AV1; R7 = CC; DBGA ( R7.L , 0x1 ); 135 136// saturate negative with "-=" 137// expected value is 0x8000000000 138 R7 = 0; 139 ASTAT = R7; 140 A1 = A0 = 0; 141 A1.x = R4.L; 142 A0.x = R4.L; 143 A1 -= R0.L * R1.L, A0 -= R0.L * R1.L; 144 R6 = A1.w; 145 _DBG ASTAT; 146 R7.L = A1.x; 147 _DBG ASTAT; 148 DBGA ( R6.L , 0x0000 ); 149 DBGA ( R6.H , 0x0000 ); 150 DBGA ( R7.L , 0xff80 ); 151 CC = AZ; R7 = CC; DBGA ( R7.L , 0x0 ); 152 CC = AN; R7 = CC; DBGA ( R7.L , 0x0 ); 153 CC = AC0; R7 = CC; DBGA ( R7.L , 0x0 ); 154 CC = AV0; R7 = CC; DBGA ( R7.L , 0x1 ); 155 CC = AV1; R7 = CC; DBGA ( R7.L , 0x1 ); 156 157// 0x8000 * 0x8000 = 0xff80000001 with "-=" 158 R7 = 0; 159 ASTAT = R7; 160 A1 = A0 = 0; 161 A1 -= R0.H * R1.H, A0 -= R0.H * R1.H; 162 R6 = A1.w; 163 _DBG ASTAT; 164 R7.L = A1.x; 165 _DBG ASTAT; 166 167 DBGA ( R6.L , 0x0000 ); 168 DBGA ( R6.H , 0x8000 ); 169 DBGA ( R7.L , 0xffff ); 170 CC = AZ; R7 = CC; DBGA ( R7.L , 0x0 ); 171 CC = AN; R7 = CC; DBGA ( R7.L , 0x0 ); 172 CC = AC0; R7 = CC; DBGA ( R7.L , 0x0 ); 173 CC = AV0; R7 = CC; DBGA ( R7.L , 0x0 ); 174 CC = AV1; R7 = CC; DBGA ( R7.L , 0x0 ); 175 176// 0x7fff * 0x7fff = 0x007ffe0002 with "=" 177 R7 = 0; 178 ASTAT = R7; 179 A1 = A0 = 0; 180 A1 += R0.L * R1.L, A0 += R0.L * R1.L; 181 A1 = R0.L * R1.L, A0 = R0.L * R1.L; 182 R6 = A1.w; 183 R7.L = A1.x; 184 DBGA ( R6.L , 0x0002 ); 185 DBGA ( R6.H , 0x7ffe ); 186 DBGA ( R7.L , 0x0000 ); 187 CC = AZ; R7 = CC; DBGA ( R7.L , 0x0 ); 188 CC = AN; R7 = CC; DBGA ( R7.L , 0x0 ); 189 CC = AC0; R7 = CC; DBGA ( R7.L , 0x0 ); 190 CC = AV0; R7 = CC; DBGA ( R7.L , 0x0 ); 191 CC = AV1; R7 = CC; DBGA ( R7.L , 0x0 ); 192 193// 0x7fff * 0x7fff = 0x007ffe0002 with "NOP" 194 R7 = 0; 195 ASTAT = R7; 196 A1 = A0 = 0; 197 A1 += R0.L * R1.L; 198 R6 = A1.w; 199 R7.L = A1.x; 200 DBGA ( R6.L , 0x0002 ); 201 DBGA ( R6.H , 0x7ffe ); 202 DBGA ( R7.L , 0x0000 ); 203 R6 = A0.w; 204 R7.L = A0.x; 205 DBGA ( R6.L , 0x0000 ); 206 DBGA ( R6.H , 0x0000 ); 207 DBGA ( R7.L , 0x0000 ); 208 CC = AZ; R7 = CC; DBGA ( R7.L , 0x0 ); 209 CC = AN; R7 = CC; DBGA ( R7.L , 0x0 ); 210 CC = AC0; R7 = CC; DBGA ( R7.L , 0x0 ); 211 CC = AV0; R7 = CC; DBGA ( R7.L , 0x0 ); 212 CC = AV1; R7 = CC; DBGA ( R7.L , 0x0 ); 213 214// 0x8000 * 0x8000 = 0x007fffffff with "NOP" 215 R7 = 0; 216 ASTAT = R7; 217 A1 = A0 = 0; 218 A1 += R0.H * R1.H; 219 _DBG A1; 220 R6 = A1.w; 221 R7.L = A1.x; 222 DBGA ( R6.L , 0x0000 ); 223 DBGA ( R6.H , 0x8000 ); 224 DBGA ( R7.L , 0x0000 ); 225 226 R6 = A0.w; 227 _DBG ASTAT; 228 R7.L = A0.x; 229 _DBG ASTAT; 230 DBGA ( R6.L , 0x0000 ); 231 DBGA ( R6.H , 0x0000 ); 232 DBGA ( R7.L , 0x0000 ); 233 R7 = ASTAT; _dbg astat; 234//AV1 AV1S should be 0. 235 DBGA ( R7.H , 0x0000 ); 236 DBGA ( R7.L , 0x0000 ); 237 238 _DBG ASTAT; 239 A1 = A0 = 0; 240 _DBG A1; 241 _DBG R0; _DBG R1; 242 A1 += R0.L * R1.L; // make sure overflow flag is not set to zero 243 _DBG A1; 244 _DBG ASTAT; 245 R7 = ASTAT; 246//AV1S should be 0. 247 DBGA ( R7.H, 0x0000 ); 248 DBGA ( R7.L, 0x0000 ); 249 250 pass 251 252 .data 253data0: 254 .dw 0x7fff 255 .dw 0x8000 256 .dw 0x7fff 257 .dw 0x8000 258 .dw 0x0000 259 .dw 0xf000 260 .dw 0x007f 261 .dw 0x0000 262 .dw 0x0080 263 .dw 0x0000 264