SWPB (Swap Byte) Ladder Logic Instruction

The Swap Byte instruction is a ladder logic rung output instruction that swaps the bytes from the Source value according to the Order Mode and places the result in the Destination tag. The order mode is chosen via a drop down list on the instruction. The instruction is enabled when the preceding logic is true and disabled otherwise. The Source and Destination values must be tags.

If the Source is an INT the Order Mode is irrelevant, all modes will have the same result.

For example:   If the Source (Represented in ASCII) =   ‘AB’ and the Mode = REVERSE, WORD, or HIGH/LOW the Destination will be ‘BA’

If the Source is a DINT or REAL the Order Mode can one of the three.

Source (Represented in ASCII) = ‘ABCD’

            0 or REVERSE Mode:           Destination will be ‘DCBA’
            1 or WORD Mode:                 Destination will be ‘CDAB’
            2 or HIGH/LOW Mode:         Destination will be ‘BADC’


List of possible arguments

SOURCE and DESINATION must follow the rules described below.

If the Source is an INT the Destination must be either an INT or DINT. If the Source is a DINT or REAL the Destination must be a DINT or REAL respectively.

Note: You can either select the Order Mode from the drop down list or enter a 0 for Reverse, 1 for Word, or 2 for High/Low.

Leave a Comment