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

Software Techniques

8.1.1.4 JVS, JVC, BVS, and BVC Operations

Although there is no instruction for jumping or branching on overflow, such an operation can be emulated as shown in the following code. Note that the carry bit will be destroyed by this operation since it receives the result of the BFTSTH instruction. The following code shows JVS and BVC.

Example 8-4. JVS, JVC, BVS and BVC

;JVS Operation

;Emulated in 5 Icyc (4 Icyc if false), 4 Instruction Words

BFTSTH

#$0002,SR

;

Test V

bit in SR

JCS

label

;

16-bit

jump address allowed

;BVC Operation

;Emulated in 5 Icyc (4 Icyc if false), 3 Instruction Words

BFTSTH

#$0002,SR

;

Test V bit in SR

BCC

label

;

7-bit signed PC relative offset allowed

 

 

 

 

8.1.1.5 Other Jumps and Branches on Condition Codes

Jumping and branching using some of the other condition codes (PL, MI, EC, ES, LC, LS) can be accomplished in the same manner as for overflow; see Section 8.1.1.4, “JVS, JVC, BVS, and BVC Operations.” Remember that this technique destroys the value in the carry bit. The following code shows JPL and BES.

Example 8-5. JPL and BES

;JPL Operation

;Emulated in 5 Icyc (4 Icyc if false), 4 Instruction Words

BFTSTH

#$0008,SR

;

Test the N bit in SR

JCC

label

;

16-bit jump address allowed

;BES Operation

;Emulated in 5 Icyc (4 Icyc if false), 3 Instruction Words

BFTSTH

#$0020,SR

;

Test E bit in SR

BCS

label

;

7-bit signed PC relative offset allowed

 

 

 

 

Similar code can be written for JMI, JEC, JES, JLMC, JLMS, BPL, BMI, BEC, BLMC, and BLMS. The JLMS and JLMC are used for “jump if limit set” and “jump if limit clear,” respectively; this is done to avoid any confusion with the JLS (“jump if lower or same”) instruction.

8.1.2 Negation Operations

The NEGW operation can be used to negate the upper two registers of the accumulator. The NEG operation can be used to negate the X0, Y0, or Y1 data ALU registers, negate an AGU register, or negate a memory location.

8.1.2.1 NEGW Operation

The NEGW operation can be emulated as shown in the following code:

;20-bit NEGW Operation

;Operates on EXT:MSP, Clears LSP, 3 Icyc

MOVE

#0,A0

; Clear LSP

NEG

A

; Now negates upper 20 bits of accumulator

 

 

; since A0 = 0

This correctly negates the upper 20 bits of the accumulator, but also destroys the A0 register.

8-4

DSP56800 Family Manual

 

Useful Instruction Operations

The NEG instruction can be used directly, executing in one instruction cycle, in cases where it is already known that the least significant portion (LSP) of an accumulator is $0000. This is true immediately after a value is moved to the A or B accumulator from memory or a register, as shown in the following code:

;Example of 1 Icyc NEGW Operation

;Works because A0 is already equal to $0000

MOVE

X:(R0),A

; Move a 16-bit value to an accumulator,

 

 

; clearing

A0 register

 

NEG

A

; Now negates upper 20

bits of accumulator

 

 

; since A0

= 0

 

The technique shown in the following code can be used for cases when 16-bit data is being processed and when it can be guaranteed that the LSP or extension register of the accumulator contains no required information:

;16-bit NEGW Operation

;Operates on MSP, Forces EXT to sign extension, LSP to $0, 2 Icyc

MOVE

A1,A

; Force A2

to sign extension,

 

 

; force

A0

cleared

NEG

A

; Now negates upper 20 bits of accumulator

 

 

; since

A0

= 0

The following technique may be used for the case where the CC bit in the SR is set to a 1, the LSP may not be $0000, and the user is not interested in the values in the accumulator extension registers:

;16-bit NEGW Operation

;CC bit must be set, operates on MSP, doesn’t affect A0, 2 Icyc

NOT

A

;

One’s-complement

of A1, A2 unchanged

INCW

A

;

Increment to get

two’s-complement,

;A2 may be incorrect

8.1.2.2Negating the X0, Y0, or Y1 Data ALU registers

Although the NEG instruction is supported on accumulators only, NEG can be emulated to perform a negation of the data ALU’s X0, Y0, or Y1 registers, as shown in the following code:

;NEG Operation

;Emulated at 2 Icyc

NOT

Y0

INCW

Y0

8.1.2.3 Negating an AGU register

It is possible to negate one of the AGU registers (Rn) without destroying any other register, as shown in the following code:

;NEG Operation

;Emulated at 3 Icyc

NOTC

R0

LEA

(R0)+

8.1.2.4 Negating a Memory Location

It is possible to negate a memory location, as shown in the following code:

;NEG Operation

;Emulated at 5 Icyc

NOTC

X:$19

INCW

X:$19

When an accumulator is available, it may be faster to do this operation simply by moving the value to an accumulator, performing the operation there, and moving the result back to memory.

 

Software Techniques

8-5

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