Panasonic MN103001G/F01K User Manual
Page 84

Extension Instruction Specifications
3-28
SWAP (Data swapping instruction that swaps bytes [high-order to low-order and vice versa] in four-byte data)
[Instruction Format (Macro Name)]
SWAP
Dm, Dn
[Assembler Mnemonic]
udf08
Dm, Dn
[Operation]
This instruction swaps the positions of the high-order and low-order 8-bit bytes within the respective high- and
low-order 16-bit half-words within the 32-bit data stored in Dm, and then swaps the positions of the high-order and
low-order 16-bit half-words, and then stores the result in Dn. As a result, bits 31 through 24 of Dm are stored in bits
7 through 0 in Dn, bits 23 through 16 of Dm are stored in bits 15 through 8 in Dn, bits 15 through 8 of Dm are stored
in bits 23 through 16 in Dn, and bits 7 through 0 of Dm are stored in bits 31 through 24 in Dn.
The sample of execution
Before execution:
0x12345678
After execution:
0x78563412
Bit 31
Bit 0
MSB
LSB
Dm before execution
Dn after execution
Dm[31:24]
Dm[23:16]
Dm[15:8]
Dm[7:0]
Bit 31
Bit 0
MSB
LSB
Dm[7:0]
Dm[15:8]
Dm[23:16]
Dm[31:24]