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

Software Techniques

8.2.5 Arithmetic Shifts by a Fixed Amount

Arithmetic shifts (left or right) by a fixed amount can be emulated with the ASRxx operations.

8.2.5.1 Right Shifts (ASR12–ASR20)

For arithmetic right shifts there is a faster way to shift an accumulator for large shift counts. The following code shows how to perform arithmetic right shifts of 12 through 20 bits on an accumulator. This emulation works without destroying any registers on the chip. If desired, it is possible to use this technique for bit shifts greater than 20, but it is not possible to use this technique for shifts of 11 or fewer bits without losing information.

8-10

DSP56800 Family Manual

 

16and 32-Bit Shift Operations

;ASR12 Operation

;Emulated in 8 Icyc, 8 Instruction Words

ASL

A

 

ASL

A

 

ASL

A

 

ASL

A

 

PUSH

A1

; (PUSH is a 2-word, 2 Icyc macro)

MOVE

A2,A

 

POP

A0

 

;ASR13 Operation

;Emulated in 7 Icyc, 7 Instruction Words

ASL

A

 

ASL

A

 

ASL

A

 

PUSH

A1

; (PUSH is a 2-word, 2 Icyc macro)

MOVE

A2,A

 

POP

A0

 

;ASR14 Operation

;Emulated in 6 Icyc, 6 Instruction Words

ASL

A

 

ASL

A

 

PUSH

A1

; (PUSH is a 2-word, 2 Icyc macro)

MOVE

A2,A

 

POP

A0

 

;ASR15 Operation

;Emulated in 5 Icyc, 5 Instruction Words

ASL

A

 

PUSH

A1

; (PUSH is a 2-word, 2 Icyc macro)

MOVE

A2,A

 

POP

A0

 

;ASR16 Operation

;Emulated in 2 Icyc, 2 Instruction Words

MOVE

A1,A0

; (Assumes EXT contains sign extension)

MOVE

A2,A1

 

;ASR17 Operation

;Emulated in 3 Icyc, 3 Instruction Words

ASR

A

 

MOVE

A1,A0

; (Assumes EXT contains sign extension)

MOVE

A2,A1

 

;ASR18 Operation

;Emulated in 4 Icyc, 4 Instruction Words

ASR

A

 

ASR

A

 

MOVE

A1,A0

; (Assumes EXT contains sign extension)

MOVE

A2,A1

 

;ASR19 Operation

;Emulated in 5 Icyc, 5 Instruction Words

ASR

A

 

ASR

A

 

ASR

A

 

MOVE

A1,A0

; (Assumes EXT contains sign extension)

MOVE

A2,A1

 

;ASR20 Operation

;Emulated in 6 Icyc, 6 Instruction Words

ASR

A

ASR

A

ASR

A

ASR

A

 

Software Techniques

8-11

Software Techniques

 

 

MOVE

A1,A0

; (Assumes EXT contains sign extension)

MOVE

A2,A1

 

8.2.5.2 Left Shifts (ASL16–ASL19)

For arithmetic left shifts there is a faster way to shift an accumulator for large shift counts. The following code shows how to perform arithmetic left shifts of 16 through 19 bits on an accumulator. This emulation works without destroying any registers on the chip. If desired, it is possible to use this technique for bit shifts greater than 19, but it is not possible for shifts of 15 or fewer bits without losing information.

;ASL16 Operation

;Emulated in 4 Icyc, 4 Instruction Words

PUSH

A1

; (PUSH is a 2-word, 2 Icyc macro)

MOVE

A0,A

 

POP

A2

 

;ASL17 Operation

;Emulated in 5 Icyc, 5 Instruction Words

ASL

A

 

PUSH

A1

; (PUSH is a 2-word, 2 Icyc macro)

MOVE

A0,A

 

POP

A2

 

;ASL18 Operation

;Emulated in 6 Icyc, 6 Instruction Words

ASL

A

 

ASL

A

 

PUSH

A1

; (PUSH is a 2-word, 2 Icyc macro)

MOVE

A0,A

 

POP

A2

 

;ASL19 Operation

;Emulated in 7 Icyc, 7 Instruction Words

ASL

A

 

ASL

A

 

ASL

A

 

PUSH

A1

; (PUSH is a 2-word, 2 Icyc macro)

MOVE

A0,A

 

POP

A2

 

8-12

DSP56800 Family Manual

 

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