Rev. 1.50, 10/04, page 257 of 448
10.1.29 MAC.W (Multiply and Accumulate Word): Arithmetic Instruction
Format
Operation
Instruction Code
Cycle
T Bit
MAC.W @Rm+,@Rn+
MAC @Rm+,@Rn+
Signed,
(Rn)
×
(Rm) + MAC
→
MAC
Rn + 2
→
Rn, Rm + 2
→
Rm
0100nnnnmmmm1111
4 —
Description:
This instruction performs signed multiplication of the 16-bit operands whose
addresses are the contents of general registers Rm and Rn, adds the 32-bit result to the MAC
register contents, and stores the result in the MAC register. Operands Rm and Rn are each
incremented by 2 each time they are read.
If the S bit is 0, a 16
×
16 + 64
→
64-bit multiply-and-accumulate operation is performed, and the
64-bit result is stored in the linked MACH and MACL registers.
If the S bit is 1, a 16
×
16 + 32
→
32-bit multiply-and-accumulate operation is performed, and the
addition to the MAC register contents is a saturation operation. In a saturation operation, only the
MACL register is valid, and the result range is limited to H'80000000 (minimum value) to
H'7FFFFFFF (maximum value). If overflow occurs, the LSB of the MACH register is set to 1.
H'80000000 (minimum value) is stored in the MACL register if the result overflows in the
negative direction, and H'7FFFFFFF (maximum value) is stored if the result overflows in the
positive direction
Notes:
If the S bit is 0, a 16
×
16 + 64
→
64-bit multiply-and-accumulate operation is performed.
Operation:
MACW(long m, long n) /* MAC.W @Rm+,@Rn+ */
{
long tempm,tempn,dest,src,ans;
unsigned long templ;
tempn = (long)Read_Word(R[n]);
R[n] += 2;
tempm = (long)Read_Word(R[m]);
R[m] += 2;
templ = MACL;
tempm = ((long)(short)tempn*(long)(short)tempm);
if ((long)MACL>=0) dest = 0;
else dest = 1;
Summary of Contents for SuperH SH-4A
Page 2: ...Rev 1 50 10 04 page ii of xx ...
Page 8: ...Rev 1 50 10 04 page viii of xx ...
Page 116: ...Rev 1 50 10 04 page 96 of 448 ...
Page 178: ...Rev 1 50 10 04 page 158 of 448 ...
Page 206: ...Rev 1 50 10 04 page 186 of 448 ...
Page 231: ...Rev 1 50 10 04 page 211 of 448 Possible Exceptions Slot illegal instruction exception ...
Page 235: ...Rev 1 50 10 04 page 215 of 448 Possible Exceptions Slot illegal instruction exception ...
Page 238: ...Rev 1 50 10 04 page 218 of 448 Possible Exceptions Slot illegal instruction exception ...
Page 408: ...Rev 1 50 10 04 page 388 of 448 Possible Exceptions Inexact Not generated when FPSCR PR 1 ...
Page 446: ...Rev 1 50 10 04 page 426 of 448 ...
Page 468: ...Rev 1 50 10 04 page 448 of 448 ...
Page 471: ......
Page 472: ...SH 4A Software Manual ...