Mitsubishi QD51 Programming Manual page 182

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
• The BSWAP instruction swaps two values in byte units starting from the address specified
Description
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.
• 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)
30 A%(0)=&H924
40 A%(1)=&H1159
50 PRINT "Before swap"
60 PRINT "A%(0)=&H";HEX$(A%(0))
70 PRINT "A%(1)=&H";HEX$(A%(1))
80 BSWAP A%( ),0,A%( ),2,2
90 PRINT "After swap"
100 PRINT " A%(0)=&H";HEX$(A%(0))
110 PRINT " A%(1)=&H";HEX$(A%(1))
120 END
11 - 12
A%
C8
BSWAP A%( ),0,A%( ),1,1
H
(0)
BSWAP A%( ),2,A%( ),3,1
00
H
64
H
(1)
00
H
:
' Defines the array
:
' Defines a numeric value to the array
:
' Displays the value before swapping
:
' Swaps
:
' Displays the value after swapping
MELSEC-Q
A%
00
H
(0)
C8
H
00
H
(1)
64
H
11 - 12

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents