3 // NEC specific instructions
6 // Integer Instructions
7 // --------------------
9 // MulAcc is the Multiply Accumulator.
10 // This register is mapped on the the HI and LO registers.
11 // Upper 32 bits of MulAcc is mapped on to lower 32 bits of HI register.
12 // Lower 32 bits of MulAcc is mapped on to lower 32 bits of LO register.
15 :function:::unsigned64:MulAcc:
17 unsigned64 result = U8_4 (HI, LO);
21 :function:::void:SET_MulAcc:unsigned64 value
23 *AL4_8 (&HI) = VH4_8 (value);
24 *AL4_8 (&LO) = VL4_8 (value);
27 :function:::signed64:SignedMultiply:signed32 l, signed32 r
29 signed64 result = (signed64) l * (signed64) r;
33 :function:::unsigned64:UnsignedMultiply:unsigned32 l, unsigned32 r
35 unsigned64 result = (unsigned64) l * (unsigned64) r;
39 :function:::unsigned64:Low32Bits:unsigned64 value
41 unsigned64 result = (signed64) (signed32) VL4_8 (value);
45 :function:::unsigned64:High32Bits:unsigned64 value
47 unsigned64 result = (signed64) (signed32) VH4_8 (value);
53 // Multiply, Accumulate
54 000000,5.RS,5.RT,00000,00000,101000::::MAC
57 // start-sanitize-vr4320
59 // end-sanitize-vr4320
61 SET_MulAcc (SD_, MulAcc (SD_) + SignedMultiply (SD_, GPR[RS], GPR[RT]));
65 // D-Multiply, Accumulate
66 000000,5.RS,5.RT,00000,00000,101001::::DMAC
69 // start-sanitize-vr4320
71 // end-sanitize-vr4320
73 LO = LO + SignedMultiply (SD_, GPR[RS], GPR[RT]);
77 // start-sanitize-vr4320
78 // Count Leading Zeros
79 000000,5.RS,00000,5.RD,00000,110101::::CLZ
81 // end-sanitize-vr4320
82 // start-sanitize-vr4320
84 // end-sanitize-vr4320
85 // start-sanitize-vr4320
87 unsigned32 t = Low32Bits (SD_, GPR[RS]);
90 while (! (t & ( 1 << 31))
101 // end-sanitize-vr4320
102 // start-sanitize-vr4320
103 // D-Count Leading Zeros
104 000000,5.RS,00000,5.RD,00000,111101::::DCLZ
106 // end-sanitize-vr4320
107 // start-sanitize-vr4320
109 // end-sanitize-vr4320
110 // start-sanitize-vr4320
112 unsigned64 t = GPR[RS];
115 while (! (t & ( (unsigned64)1 << 63))
122 printf("lo %d\n", (int) c);
132 // end-sanitize-vr4320
133 // start-sanitize-vrXXXX
134 // Multiply and Move LO.
135 000000,5.RS,5.RT,5.RD,00100,101000::::MUL
136 "mul r<RD>, r<RS>, r<RT>"
137 // end-sanitize-vrXXXX
138 // start-sanitize-vr4320
140 // end-sanitize-vr4320
141 // start-sanitize-vr5400
143 // end-sanitize-vr5400
144 // start-sanitize-vrXXXX
146 SET_MulAcc (SD_, 0 + SignedMultiply (SD_, GPR[RS], GPR[RT]));
147 GPR[RD] = Low32Bits (SD_, MulAcc (SD_));
151 // end-sanitize-vrXXXX
152 // start-sanitize-vrXXXX
153 // Unsigned Multiply and Move LO.
154 000000,5.RS,5.RT,5.RD,00101,101000::::MULU
155 "mulu r<RD>, r<RS>, r<RT>"
156 // end-sanitize-vrXXXX
157 // start-sanitize-vr4320
159 // end-sanitize-vr4320
160 // start-sanitize-vr5400
162 // end-sanitize-vr5400
163 // start-sanitize-vrXXXX
165 SET_MulAcc (SD_, 0 + UnsignedMultiply (SD_, GPR[RS], GPR[RT]));
166 GPR[RD] = Low32Bits (SD_, MulAcc (SD_));
170 // end-sanitize-vrXXXX
171 // start-sanitize-vrXXXX
172 // Multiply and Move HI.
173 000000,5.RS,5.RT,5.RD,01100,101000::::MULHI
174 "mulhi r<RD>, r<RS>, r<RT>"
175 // end-sanitize-vrXXXX
176 // start-sanitize-vr4320
178 // end-sanitize-vr4320
179 // start-sanitize-vr5400
181 // end-sanitize-vr5400
182 // start-sanitize-vrXXXX
184 SET_MulAcc (SD_, 0 + SignedMultiply (SD_, GPR[RS], GPR[RT]));
185 GPR[RD] = High32Bits (SD_, MulAcc (SD_));
189 // end-sanitize-vrXXXX
190 // start-sanitize-vrXXXX
191 // Unsigned Multiply and Move HI.
192 000000,5.RS,5.RT,5.RD,01101,101000::::MULHIU
193 "mulhiu r<RD>, r<RS>, r<RT>"
194 // end-sanitize-vrXXXX
195 // start-sanitize-vr4320
197 // end-sanitize-vr4320
198 // start-sanitize-vr5400
200 // end-sanitize-vr5400
201 // start-sanitize-vrXXXX
203 SET_MulAcc (SD_, 0 + UnsignedMultiply (SD_, GPR[RS], GPR[RT]));
204 GPR[RD] = High32Bits (SD_, MulAcc (SD_));
208 // end-sanitize-vrXXXX
209 // start-sanitize-vr5400
210 // Multiply, Negate and Move LO.
211 000000,5.RS,5.RT,5.RD,00011,011000::::MULS
212 "muls r<RD>, r<RS>, r<RT>"
213 // end-sanitize-vr5400
214 // start-sanitize-vr5400
216 // end-sanitize-vr5400
217 // start-sanitize-vr5400
219 SET_MulAcc (SD_, 0 - SignedMultiply (SD_, GPR[RS], GPR[RT]));
220 GPR[RD] = Low32Bits (SD_, MulAcc (SD_));
224 // end-sanitize-vr5400
225 // start-sanitize-vr5400
226 // Unsigned Multiply, Negate and Move LO.
227 000000,5.RS,5.RT,5.RD,00011,011001::::MULSU
228 "mulsu r<RD>, r<RS>, r<RT>"
229 // end-sanitize-vr5400
230 // start-sanitize-vr5400
232 // end-sanitize-vr5400
233 // start-sanitize-vr5400
235 SET_MulAcc (SD_, 0 - UnsignedMultiply (SD_, GPR[RS], GPR[RT]));
236 GPR[RD] = Low32Bits (SD_, MulAcc (SD_));
240 // end-sanitize-vr5400
241 // start-sanitize-vr5400
242 // Multiply, Negate and Move HI.
243 000000,5.RS,5.RT,5.RD,01011,011000::::MULSHI
244 "mulshi r<RD>, r<RS>, r<RT>"
245 // end-sanitize-vr5400
246 // start-sanitize-vr5400
248 // end-sanitize-vr5400
249 // start-sanitize-vr5400
251 SET_MulAcc (SD_, 0 - SignedMultiply (SD_, GPR[RS], GPR[RT]));
252 GPR[RD] = High32Bits (SD_, MulAcc (SD_));
256 // end-sanitize-vr5400
257 // start-sanitize-vr5400
258 // Unsigned Multiply, Negate and Move HI.
259 000000,5.RS,5.RT,5.RD,01011,011001::::MULSHIU
260 "mulshiu r<RD>, r<RS>, r<RT>"
261 // end-sanitize-vr5400
262 // start-sanitize-vr5400
264 // end-sanitize-vr5400
265 // start-sanitize-vr5400
267 SET_MulAcc (SD_, 0 - UnsignedMultiply (SD_, GPR[RS], GPR[RT]));
268 GPR[RD] = High32Bits (SD_, MulAcc (SD_));
275 // end-sanitize-vr5400
276 // Multiply, Accumulate and Move LO.
277 000000,5.RS,5.RT,5.RD,00010,101000::::MACC
278 "macc r<RD>, r<RS>, r<RT>"
279 // start-sanitize-vr4320
281 // end-sanitize-vr4320
282 // start-sanitize-vr5400
284 // end-sanitize-vr5400
286 SET_MulAcc (SD_, MulAcc (SD_) + SignedMultiply (SD_, GPR[RS], GPR[RT]));
287 GPR[RD] = Low32Bits (SD_, MulAcc (SD_));
291 // start-sanitize-vrXXXX
292 // Unsigned Multiply, Accumulate and Move LO.
293 000000,5.RS,5.RT,5.RD,00011,101000::::MACCU
294 "maccu r<RD>, r<RS>, r<RT>"
295 // end-sanitize-vrXXXX
296 // start-sanitize-vr4320
298 // end-sanitize-vr4320
299 // start-sanitize-vr5400
301 // end-sanitize-vr5400
302 // start-sanitize-vrXXXX
304 SET_MulAcc (SD_, MulAcc (SD_) + UnsignedMultiply (SD_, GPR[RS], GPR[RT]));
305 GPR[RD] = Low32Bits (SD_, MulAcc (SD_));
309 // end-sanitize-vrXXXX
310 // start-sanitize-vrXXXX
311 // Multiply, Accumulate and Move HI.
312 000000,5.RS,5.RT,5.RD,01010,101000::::MACCHI
313 "macchi r<RD>, r<RS>, r<RT>"
314 // end-sanitize-vrXXXX
315 // start-sanitize-vr4320
317 // end-sanitize-vr4320
318 // start-sanitize-vr5400
320 // end-sanitize-vr5400
321 // start-sanitize-vrXXXX
323 SET_MulAcc (SD_, MulAcc (SD_) + SignedMultiply (SD_, GPR[RS], GPR[RT]));
324 GPR[RD] = High32Bits (SD_, MulAcc (SD_));
328 // end-sanitize-vrXXXX
329 // start-sanitize-vrXXXX
330 // Unsigned Multiply, Accumulate and Move HI.
331 000000,5.RS,5.RT,5.RD,01011,101000::::MACCHIU
332 "macchiu r<RD>, r<RS>, r<RT>"
333 // end-sanitize-vrXXXX
334 // start-sanitize-vr4320
336 // end-sanitize-vr4320
337 // start-sanitize-vr5400
339 // end-sanitize-vr5400
340 // start-sanitize-vrXXXX
342 SET_MulAcc (SD_, MulAcc (SD_) + UnsignedMultiply (SD_, GPR[RS], GPR[RT]));
343 GPR[RD] = High32Bits (SD_, MulAcc (SD_));
349 // end-sanitize-vrXXXX
350 // start-sanitize-vr5400
351 // Multiply, Negate, Accumulate and Move LO.
352 000000,5.RS,5.RT,5.RD,00111,011000::::MSAC
353 "msac r<RD>, r<RS>, r<RT>"
354 // end-sanitize-vr5400
355 // start-sanitize-vr5400
357 // end-sanitize-vr5400
358 // start-sanitize-vr5400
360 SET_MulAcc (SD_, MulAcc (SD_) - SignedMultiply (SD_, GPR[RS], GPR[RT]));
361 GPR[RD] = Low32Bits (SD_, MulAcc (SD_));
365 // end-sanitize-vr5400
366 // start-sanitize-vr5400
367 // Unsigned Multiply, Negate, Accumulate and Move LO.
368 000000,5.RS,5.RT,5.RD,00111,011001::::MSACU
369 "msacu r<RD>, r<RS>, r<RT>"
370 // end-sanitize-vr5400
371 // start-sanitize-vr5400
373 // end-sanitize-vr5400
374 // start-sanitize-vr5400
376 SET_MulAcc (SD_, MulAcc (SD_) - UnsignedMultiply (SD_, GPR[RS], GPR[RT]));
377 GPR[RD] = Low32Bits (SD_, MulAcc (SD_));
381 // end-sanitize-vr5400
382 // start-sanitize-vr5400
383 // Multiply, Negate, Accumulate and Move HI.
384 000000,5.RS,5.RT,5.RD,01111,011000::::MSACHI
385 "msachi r<RD>, r<RS>, r<RT>"
386 // end-sanitize-vr5400
387 // start-sanitize-vr5400
389 // end-sanitize-vr5400
390 // start-sanitize-vr5400
392 SET_MulAcc (SD_, MulAcc (SD_) - SignedMultiply (SD_, GPR[RS], GPR[RT]));
393 GPR[RD] = High32Bits (SD_, MulAcc (SD_));
396 // end-sanitize-vr5400
397 // start-sanitize-vr5400
398 // Unsigned Multiply, Negate, Accumulate and Move HI.
399 000000,5.RS,5.RT,5.RD,01111,011001::::MSACHIU
400 "msachiu r<RD>, r<RS>, r<RT>"
401 // end-sanitize-vr5400
402 // start-sanitize-vr5400
404 // end-sanitize-vr5400
405 // start-sanitize-vr5400
407 SET_MulAcc (SD_, MulAcc (SD_) - UnsignedMultiply (SD_, GPR[RS], GPR[RT]));
408 GPR[RD] = High32Bits (SD_, MulAcc (SD_));
412 // end-sanitize-vr5400
413 // start-sanitize-vr5400
415 000000,00001,5.RT,5.RD,5.SHIFT,000010::::ROR
416 "ror r<RD>, r<RT>, <SHIFT>"
417 // end-sanitize-vr5400
418 // start-sanitize-vr5400
420 // end-sanitize-vr5400
421 // start-sanitize-vr5400
424 GPR[RD] = ROTR32 (GPR[RT], s);
428 // end-sanitize-vr5400
429 // start-sanitize-vr5400
430 // Rotate Right Variable.
431 000000,5.RS,5.RT,5.RD,00001,000110::::RORV
432 "rorv r<RD>, r<RT>, <RS>"
433 // end-sanitize-vr5400
434 // start-sanitize-vr5400
436 // end-sanitize-vr5400
437 // start-sanitize-vr5400
439 int s = MASKED (GPR[RS], 4, 0);
440 GPR[RD] = ROTR32 (GPR[RT], s);
444 // end-sanitize-vr5400
445 // start-sanitize-vr5400
446 // Double Rotate Right.
447 000000,00001,5.RT,5.RD,5.SHIFT,111010::::DROR
448 "dror r<RD>, r<RT>, <SHIFT>"
449 // end-sanitize-vr5400
450 // start-sanitize-vr5400
452 // end-sanitize-vr5400
453 // start-sanitize-vr5400
456 GPR[RD] = ROTR64 (GPR[RT], s);
460 // end-sanitize-vr5400
461 // start-sanitize-vr5400
462 // Double Rotate Right Plus 32.
463 000000,00001,5.RT,5.RD,5.SHIFT,111110::::DROR32
464 "dror32 r<RD>, r<RT>, <SHIFT>"
465 // end-sanitize-vr5400
466 // start-sanitize-vr5400
468 // end-sanitize-vr5400
469 // start-sanitize-vr5400
472 GPR[RD] = ROTR64 (GPR[RT], s);
476 // end-sanitize-vr5400
477 // start-sanitize-vr5400
478 // Double Rotate Right Variable.
479 000000,5.RS,5.RT,5.RD,00001,010110::::DRORV
480 "drorv r<RD>, r<RT>, <RS>"
481 // end-sanitize-vr5400
482 // start-sanitize-vr5400
484 // end-sanitize-vr5400
485 // start-sanitize-vr5400
487 int s = MASKED (GPR[RS], 5, 0);
488 GPR[RD] = ROTR64 (GPR[RT], s);
492 // end-sanitize-vr5400