Software Techniques
8.1.3
Register Exchanges
The XCHG operation can be emulated as shown in the following code:
; XCHG Operation
; Emulated at 4 Icyc
PUSH
MOVE
POP
If a register is available, the exchange of any two registers can be emulated as shown in the following code:
; XCHG Operation
; Emulated at 3 Icyc
MOVE
MOVE
MOVE
A faster exchange of any two registers can be emulated using one address register when N equals 0, as
shown in the following code:
; XCHG Operation
; N register is 0, Emulated at 2 Icyc
MOVE
TFR
8.1.4
Minimum and Maximum Values
The MAX operation returns the maximum of two values; the MIN operation return the minimum.
8.1.4.1
MAX Operation
The MAX operation can be emulated as shown in the following code:
; MAX Operation
MAX
;
------ becomes ------
; MAX operation
; Emulated at 4 Icyc
CMP
TGT
8-6
X0
A,X0
A
X0,N
A,X0
N,A
A,X:(R0)
X0,A
X:(R0)+N,X0
X0,A
X0,A
X0,A
; (can also use TGE if desired)
DSP56800 Family Manual