11 - 12 11 - 12
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
Description
• The BSWAP instruction swaps two values in byte units starting from the address specified
by the variable.
Especially, this instruction is used in order to rearrange the I/O data that is communicated
with the external device so that it conforms to the data format of the device used.
A%
C8
H
00
H
64
H
00
H
(0)
(1)
A%
00
H
C8
H
00
H
64
H
(0)
(1)
BSWAP A%( ),0,A%( ),1,1
BSWAP A%( ),2,A%( ),3,1
• An error occurs if the swap starting address in the variable is larger than the array size
specified by the DIM instruction.
• The same variable can be specified to <variable1> and <variable2>.
• Specify the number of swap counts in bytes to <swap count>.
Program Example
10 ' Swaps the contents of array A%(0) and A%(1)
20 DIM A%(1)
:
' Defines the array
30 A%(0)=&H924
:
' Defines a numeric value to the array
40 A%(1)=&H1159
50 PRINT "Before swap"
:
' Displays the value before swapping
60 PRINT "A%(0)=&H";HEX$(A%(0))
70 PRINT "A%(1)=&H";HEX$(A%(1))
80 BSWAP A%( ),0,A%( ),2,2
:
' Swaps
90 PRINT "After swap"
:
' Displays the value after swapping
100 PRINT " A%(0)=&H";HEX$(A%(0))
110 PRINT " A%(1)=&H";HEX$(A%(1))
120 END
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...