Topic: DMD0029

SWAPB - Swap Bytes


The Swap Bytes (SWAPB) instruction is used to swap the Bytes and/or the Words in the designated range of locations. This instruction will begin at the first Source location and swap the Bytes and/or Words, then store the result in the first destination location. This operation will be repeated the number of times specified by the Elements value on successive Source locations.

 

Parameters:

Note: Use the F9 key (Element Browser) or Down-Arrow key (Auto-Complete) at any time to see a complete list of the memory locations that are valid in the current field of the instruction.

 

Source -  designates the first location to operate on. This can be any readable numeric block location

 

Destination - designates the first location to store the result. This can be any writable numeric block location.

Note:
Source and Destination do not have to be the same Type but they must be the same Element Size, that is, they both must consist of Word (16-bit) or DWord (32-bit) size elements. If the Source and Destination are different sizes use the Translate from Do-more (PUBLISH) and Translate to Do-more (SUBSCRIB) instructions to perform the Byte Swap.

 

Elements - specifies how many successive Word or DWord elements the Swap Bytes instruction will operate on

 

Swap Byte - select this option to swap the Bytes in each of the Words or DWord elements

 

Swap Word - select this option to swap the Words in each of the DWord elements

 

Only Swap Bytes, Word elements, V0 -> V100

 

V0

0x1234

V100

0x3412

V0

0x5678

V100

0x7856

V0

0xABCD

V100

0xCDAB

 

 

Only Swap Bytes, DWord elements, D0 -> D100

 

D0

0x12345678

D100

0x34127856

D0

0x90ABCDEF

D100

0xAB90EFCD

 

 

Only Swap Words, DWord elements, D0 -> D100

 

D0

0x12345678

D100

0x56781234

D0

0x90ABCDEF

D100

0xCDEF90AB

 

 

Swap Words and Bytes, DWord elements, D0 -> D100

 

D0

0x12345678

D100

0x78562412

D0

0x90ABCDEF

D100

0xEFCDAB90

 


See Also:

 


Related Topics:

 


Rung Example: