Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
46
Добавлен:
27.04.2015
Размер:
4.26 Mб
Скачать

Fractional and Integer Data ALU Arithmetic

Signed Integer

Input Operands

Signed

Intermediate

Multiplier Result

 

 

Input Operand 1

 

 

Input Operand 2

 

 

 

 

s

 

 

 

 

s

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

16 Bits

 

 

 

 

 

16 Bits

 

 

 

 

 

 

 

 

 

 

16 Bits

 

 

 

 

 

s

 

 

 

0

 

 

 

 

 

31 Bits

S Ext.

Signed Integer

EXP

MSP

Unchanged

Output

16 Bits

AA0044

Figure 3-12. Integer Multiplication (IMPY)

At other times it is necessary to maintain the full 32-bit precision of an integer multiplication. To obtain integer results, an MPY instruction is used, immediately followed by an ASR instruction. The 32-bit long integer result is then correctly located into the MSP and LSP of an accumulator with correct sign extension in the extension register of the same accumulator (see Example 3-9).

Example 3-9. Multiplying Two Signed Integer Values with Full Precision

MPY

X0,Y0,A

; Generates correct answer shifted

 

 

; 1 bit to the left

ASR

A

; Leaves Correct 32-bit Integer

 

 

; Result in the A Accumulator

 

 

; and the A2 register contains

 

 

; correct sign extension

 

 

 

When a multiply-accumulate is performed on a set of integer numbers, there is a faster way for generating the result than performing an ASR instruction after each multiply. The technique is to use fractional multiply-accumulates for the bulk of the computation and to then convert the final result back to integer. See Example 3-10.

Example 3-10. Fast Integer MACs using Fractional Arithmetic

MOVE

 

 

X:(R0)+,Y0

X:(R3)+,X0

DO

#N,LABEL

 

 

MAC

X0,Y0,A

X:(R0)+,Y0

X:(R3)+,X0

LABEL

 

 

 

 

ASR

A

; Convert to Integer only after MACs are

 

 

; completed

 

 

 

 

 

 

3.3.6 Division

Fractional and integer division of both positive and signed values is supported using the DIV instruction. The dividend (numerator) is a 32-bit fractional or 31-bit integer value, and the divisor (denominator) is a 16-bit fractional or integer value, respectively. See Section 8.4, “Division,” on page 8-13 for a complete discussion of division.

Data Arithmetic Logic Unit

3-21

Соседние файлы в папке DSP568xx