Swap - GE PACSystems RX7i Cpu Programmer's Reference Manual

Hide thumbs Also See for PACSystems RX7i:
Table of Contents

Advertisement

4.8.18

Swap

The SWAP function is used to swap two bytes within a word (SWAP
WORD) or two words within a double word (SWAP DWORD). The SWAP
can be performed over a wide range of memory by specifying a length
greater than 1. If that is done, the data in each word or double word
within the specified length is swapped.
When the SWAP function receives power flow, it swaps the data in reference IN and places the
swapped data into output reference Q. The function passes power to the right whenever it receives
power.
PACSystems CPUs use the Intel convention for storing word data in bytes. They store the least
significant byte of a word in address n and the most significant byte in address n+1. Many VME
modules follow the Motorola convention of storing the most significant byte in address n and the
least significant byte in address n+1.
The PACSystems CPU assigns byte address 1 to the same storage location regardless of the byte
convention used by the other device. However, because of the difference in byte significance, word
and multiword data, for example, 16-bit integers (INT, UINT), 32-bit integers (DINT) or floating point
(REAL) numbers, must be adjusted when being transferred to or from Motorola-convention modules.
In these cases, the two bytes in each word must be swapped, either before or after the transfer. In
addition, for multiword data items, the words must be swapped end-for-end on a word basis. For
example, a 64-bit real number transferred to the PACSystems CPU from a Motorola-convention
module must be byte-swapped and word-reversed, either before or after reading, as shown below:
B1
B2
B3
Character (ASCII) strings or BCD data require no adjustment since the Intel and Motorola
conventions for storage of character strings are identical.
Operands for Swap
The two parameters, IN and Q, must both be the same type, WORD or DWORD.
Parameter Description
Length (??) The number of WORDs or DWORDs to operate on.
1  Length  256
IN
Reference for data to be swapped. (must be the same type as Q) All
Q
Reference for swapped data. (must be the same type as IN)
Example for Swap
Two bytes located in bits %I00033 through %I00048 are swapped.
The result is stored in %L00007.
GFK-2950C
B4
B5
B6
February 2018
Chapter 4. Ladder Diagram (LD) Programming
B7
B8
Allowed Operands Optional
Constant
All except S
Other
mnemonic:
SWAP_WORD
No
No
No
171

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pacsystems rx3iPacsystems rsti-ep

Table of Contents