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

Multiple Value Pushes

8.4.5 Overflow Cases

Both integer and fractional division are subject to division overflow. Overflow is the case where the correct value of the quotient will not fit into the destination available to store it.

For division of fractional numbers, the result must be a 16-bit, signed fractional value greater than or equal to -1.0 and less than 1.0 - 2-[N-1]. In other words, it must satisfy the following:

-1.0 ≤ quotient < +1.0 - 2-[N-1]

For the case where the magnitude of the dividend is larger than the magnitude of the divisor, this inequality will not be true because any result generated will be larger in magnitude than 1.0. Thus, division overflow occurs with fractional numbers for the case where the absolute value of the divisor is less than or equal to the absolute value of the dividend:

|divisor| ≤ |dividend|

If this condition can be true when dividing fractional numbers, it must be prevented from occurring by first scaling the dividend.

For the division of integer numbers, the result must be a 16-bit, signed integer value greater than or equal to -2-[N-1] and less than or equal to [2[N-1] -1], where N is equal to 16. In other words:

-2-[N-1] ≤ quotient ≤ [2[N-1] -1], where N = 16

When integer numbers are being divided, it must be guaranteed that the final result can fit into a signed, 16-bit integer value. Otherwise, to prevent this from occurring, it is first necessary to scale the numerator.

8.5 Multiple Value Pushes

The DSP56800 core currently supports a one-word, one-instruction-cycle POP instruction for removing information from the stack. The PUSH operation, however, is a two-word, two-instruction-cycle macro, which expands to the following code. (This instruction macro works quite well when pushing a single variable.)

;Expansion of the PUSH Instruction Macro

;Emulated in 2 Icyc, 2 Instruction Words

LEA

(SP)+

; Increment the SP (1 Icyc, 1 Word)

MOVE

<register>,X:(SP)

; Place value onto the stack

 

 

; (1 Icyc, 1 Word)

However, there is a better technique when it is necessary to push more than one value onto the software stack. Instead of using consecutive PUSH instruction macros, it is more efficient and saves more instruction words by expanding out the PUSH operation:

;Faster technique for pushing multiple values onto the stack

;Finishes in 5 Icyc, 5 Instruction Words

LEA

(SP)+

; Increment SP

MOVE

X0,X:(SP)+

 

MOVE

Y0,X:(SP)+

 

MOVE

R0,X:(SP)+

 

MOVE

R1,X:(SP)

; No post-increment SP on last MOVE

In this case five instruction cycles and five words are used to push four values onto the software stack. If the PUSH instruction macro had been used instead, it would have performed the same function in eight instruction cycles with eight words.

 

Software Techniques

8-19

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