Precautions for Correct Use
Amount of Memory That Is Allocated for BOOL Arrays
Two bytes are allocated in memory for individual BOOL variables, BOOL structure members, and
BOOL union variables.
However, for a BOOL array, two bytes of memory are not allocated for each element. One bit is
allocated in order for each element. For the entire array, a multiple of two bytes of memory is allo-
cated (including unused bits).
Variable Table
Name
A
B
C
Data type
BOOL
ARRAY[1..5]OF BOOL
ARRAY[0..18]OF BOOL
Variable A
Variable B
Variable C
Bytes
Memory
First byte
First byte + 1
First byte + 2
First byte + 3
First byte + 4
First byte + 5
First byte + 6
First byte + 7
Two bytes are allocated.
Two bytes are allocated
for 5 elements.
Four bytes are allocated
for 19 elements.
Therefore, the following formula gives the amount of memory that is allocated for a BOOL array.
For 1 to 16 elements, 2 bytes are allocated. For 17 to 32 elements, 4 bytes are allocated.
Amount of memory = 2
Truncate the decimal portion of the result
of the calculation in brackets.
Number of
elements − 1
16
+2
Specific examples of the rules for memory allocation for variables of each data type are given below.
Basic Data Types
Variables with One-Byte Alignments (e.g., BYTE)
One byte of memory is allocated for the one-byte alignment.
Example: Two consecutive BYTE variables
Variable A, 1 byte
Variable B, 1 byte
Variable Table
Name
A
B
Data type
BYTE
BYTE
Bytes
Memory
First byte
First byte + 1
Variables with Two-byte Alignments (e.g., BOOL and WORD)
Two bytes of memory are allocated for the two-byte alignment.
Example: Two consecutive BOOL variables
Appendices
A-48
NJ/NX-series CPU Unit Built-in EtherNet/IP Port User’s Manual (W506)
Summary of Contents for Sysmac NX1P2-10 1 Series
Page 8: ...Manual Structure 6 NJ NX series CPU Unit Built in EtherNet IP Port User s Manual W506...
Page 34: ...Revision History 32 NJ NX series CPU Unit Built in EtherNet IP Port User s Manual W506...
Page 388: ...9 Socket Service 9 34 NJ NX series CPU Unit Built in EtherNet IP Port User s Manual W506...
Page 430: ...12 FTP Client 12 14 NJ NX series CPU Unit Built in EtherNet IP Port User s Manual W506...
Page 569: ...I Index I 1 NJ NX series CPU Unit Built in EtherNet IP Port User s Manual W506 I...
Page 576: ...Index I 8 NJ NX series CPU Unit Built in EtherNet IP Port User s Manual W506...
Page 577: ......