Advanced Function Instruction
7-21
FUN 46 P
SWAP
BYTE
SWAP
FUN 46 P
SWAP
D : Register for byte data swap
D may combine with V, Z, P0~P9 to serve indirect address
application
WY WM WS TMR CTR HR OR SR ROR DR XR
Range
Ope-
rand
WY0
∣
WY240
WM0
∣
WM1896
WS0
∣
WS984
T0
∣
T255
C0
∣
C255
R0
∣
R3839
R3904
∣
R3967
R3968
∣
R4167
R5000
∣
R8071
D0
∣
D4095
V、Z
P0~P9
D ○ ○ ○ ○ ○ ○ ○ ○* ○* ○ ○
z When swap control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, swap the data of the low
byte, Byte 0 (B0~B7), and the high byte, Byte 1 (B8~B15), in the 16 bit register specified by D.
B15 B8 B7 B0
Byte 1(high) Byte 0(low)
X0
46P
SWAP
R 0
EN
z The instruction at left swaps the data of the low byte
(B0~B7) and the high byte (B8~B15) in R0. The results
are as follows:
Byte1 Byte0
D R0 0 0 11001111110000
B15 B8 B7 B0
Ø
X0=
B15
B0
D R0 1 1 11000000110011