Publication 1766-RM001A-EN-P - October 2008
286
File Instructions
SWP - Swap
Instruction Type: output
Use the SWP instruction to swap the low and high bytes of a specified
number of words in a bit, integer, or string file. The SWP instruction has 2
operands:
•
Source is the word address containing the words to be swapped.
•
Length is the number of words to be swapped, regardless of the file
type. The address is limited to integer constants. For bit and integer
filetypes, the length range is 1…128. For the string filetype, the
length range is 1…41. Note that this instruction is restricted to a
single string element and cannot cross a string element boundary.
Addressing Modes and File Types can be used as shown in the following
table:
Example:
Source Value before executing SWP instruction: a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g
Source Value before executing SWP instruction: b a d c f e h g j i l k n m p o r q t s v u x w z y a b c d e f g
The underlined characters show the 13 words where the low byte was
swapped with the high byte.
SWP
Swap
Source
#ST10:1.DATA[0]
Length
13
SWP
Execution Time for the SWP Instruction
Controller
When Rung Is:
True
False
MicroLogix 1400
1.0728 µs
0.1963 µs
SWP Instruction Valid Addressing Modes and File Types
For definitions of the terms used in this table see Using the Instruction Descriptions on page 92.
Parameter
Data Files
Function Files
CS
- Comms
IO
S - I/O
DL
S
-
D
a
ta
L
o
g
Address
(1)
Mode
Address Level
O
I
S
B
T,
C
, R
N
F
ST
L
MG,
PD
RI
/RIX
PL
S
RTC
HS
C
PTO
X
, PWMX
STI
EII
BH
I
MMI
LC
D
Im
mediate
Dir
ect
Indir
e
c
t
Bi
t
Wo
rd
Lo
ng
W
o
rd
Elemen
t
Source
•
•
•
•
•
•
Length
•
•
(1) See Important note about indirect addressing.
IMPORTANT
You cannot use indirect addressing with: S, MG, PD, RTC, HSC, PTOX,
PWMX, STI, EII, BHI, MMI, CS, IOS, and DLS files.
SWP
Swap
Source
#ST10:1.DATA[0]
Length
13
SWP
efesotomasyon.com - Allen Bradley,Rockwell,plc,servo,drive