51
Precautions for Instructions with Operands Specifying the First or Last of Multiple
Section 2-5
Array Variables
The result depends on the following conditions.
Size to Be Processed by Instruction Is Fixed
If the size to be processed by the instruction is a fixed operand, and this size
does not match the number of array elements, the CX-Programmer will output
a compile error.
Example: LINE TO COLUMN(064) instruction; COLM
S
D
N
(S: Bit number, D: First destination word, N: Source word)
E.g., COLM
a
b[0]
c
If an array for a WORD data type with 10 array elements is specified in D
when it should be for 16 array elements, the CX-Programmer will output an
error when compiling.
Size to Be Processed by Instruction Is Not Fixed
When the operand size to be processed by the instruction is not fixed (when
the size is specified by another operand in the instruction), make sure that the
number of array elements is the same or greater than the size specified in the
other operand (i.e., size to be processed by the instruction).
Other Operand Specifying Size: Constant
The CX-Programmer will output an error when compiling.
Example: BLOCK TRANSFER: XFER
W
S D
(W: Number of words, S: First source word; D: First destination word)
When
&20
is specified in W, array variable
a
with data type WORD and 10
elements is specified in S, and array variable
b
with data type WORD and 10
elements is specified in D:
XFER
&20
a[0]
b[0]
Even though the array variables a[0] and b[0] are both 10 words, the
XFER(070) instruction will execute transfer processing for the 20 words spec-
ified in W. As a result, the XFER(070) instruction will perform read/write pro-
cessing for the I/O memory area following the number of array elements that
was allocated, as shown in the following diagram.
Therefore, if a[10 elements] is internally allocated words (e.g., H700 to H709),
and b[10 elements] is internally allocated words (e.g., H800 to H809),
XFER(070) will transfer data in words H700 to H719 to words H800 to H819.
In this operation, if another internally allocated variable (e.g., c), is allocated
words in H810 to H819, the words will be overwritten, causing unexpected
operation to occur. To transfer 20 words, make sure that the number of ele-
ments is specified as 20 elements for both array variable
a
and
b
.
Summary of Contents for CS1-H Series
Page 3: ...iv...
Page 5: ...vi...
Page 7: ...viii TABLE OF CONTENTS...
Page 15: ...xvi Application Precautions 4...
Page 151: ...136 Procedures Section 3 2...
Page 153: ...138 Data Types Appendix A...
Page 177: ...162 External Variables Appendix C...
Page 181: ...166 Revision History...