Appendices
A-92
NJ-series CPU Unit Software User’s Manual (W501)
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.
Specific examples of the rules for memory allocation for variables of each data type are given below.
Variables with One-Byte Alignments (e.g., BYTE)
One byte of memory is allocated for the one-byte alignment.
Example: Two consecutive BYTE variables
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
Variables with Four-byte Alignments (e.g., DWORD)
Four bytes of memory are allocated for the four-byte alignment.
The location of the first byte of data in memory is an integer multiple of four bytes. Therefore, if a
variable with a two-byte alignment, such as WORD data, is inserted, two bytes of unused memory
will remain.
Example: Consecutive variables in the following order: DWORD, WORD, and DWORD
Basic Data Types