11 - 11 11 - 11
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
BSWAP
Instruction
Byte SWAP
• Swaps two values in byte units.
BSWAP <variable 1> , <swap starting address of variable 1> ,
<variable 2> , <swap starting address of variable 2> , <swap count>
variable 1, variable 2
• • • •
Specify the variables to be swapped.
swap start address of
variable 1, variable 2
• • • •
Specify the swap start address of variable1 and
variable2.
Syntax
swap count
• • • •
Specify the number of items to swap in byte units.
BSWAP A%( ), 0, A%( ), 1, 1
• • • •
Swaps the upper one byte and lower one byte of
A%(0).
(0)
(1)
• •
•
C8
H
00
H
A%
Before swap
Lower one byte
Higher one byte
Lower one byte
Higher one byte
64
H
00
H
(0)
(1)
C8
H
00
H
A%
After swap
64
H
00
H
• •
•
• •
•
• •
•
BSWAP A$, 2, B%( ), 1, 2
• • • •
Swaps two bytes of character array A$(2), A$(3) and
other two bytes that are the upper one byte of the
integer array B%(0) and the lower one byte of B%(1).
Examples
After swap
(0)
(1)
B%
Lower one byte
Higher one byte
Lower one byte
Higher one byte
00
H
43
H
44
H
10
H
(0)
(1)
41
H
(A)
42
H
(B)
59
H
(Y)
50
H
(P)
(2)
(3)
A$
Before swap
(0)
(1)
B%
00
H
10
H
(0)
(1)
• •
•
41
H
(A)
42
H
(B)
(2)
(3)
A$
43
H
(C)
44
H
(D)
59
H
50
H
• •
•
• •
•
• •
•
• •
•