Use Direct Variable Memory
The %M direct variable memory area has shared memory across different data types.
-
This can be used to have the XEM CPU automatically convert BYTE arrays into WORD or DWORD arrays.
-
The BYTE array size must be divisible by 2 with no remainder to provide a valid WORD array size.
-
The BYTE array size must be divisible by 4 with no remainder to provide a valid DWORD array size.
-
A WORD array can also be converted to a DWORD and BYTE data.
-
A DWORD array can be converted to a WORD or BYTE array.
Memory Area | Data Type Designator | Memory Direct Variable Name By Data Type |
---|---|---|
M |
X (bit) 1 BIT |
%MX0 - %MX262143 |
B (byte) 8 bits |
%MB0 - %MB32767 | |
W (word) 16 bits |
%MW0 - %MW16383 | |
D (dbl word) 32 bits |
%MD0 - %MD8191 | |
L (long word) 64 bits |
%ML0 - %ML4095 |
This example shows that the BYTE address of %MB0 and %MB1 are contained in WORD address %MW0 and the BYTE addresses of %MB0 through %MB3 are contained in DWORD address %MD0.
Direct Variable Name for a Physical Memory Block
B (byte) 8 bits |
W (word) 16 bits |
D (dbl word) 32 bits |
---|---|---|
%MB0 | %MW0 | %MD0 |
%MB1 | ||
%MB2 | %MW1 | |
%MB3 |
In this example, we are using an array of 32 bytes as an input and 6 bytes as an output to a GS20 VFD.
-
The input arrays can use BYTE, WORD, and DWORD because the original size of 32 is evenly divisible by 2 and 4.
-
The output arrays can only use BYTE and WORD since the original size of 6 is only evenly divisible by 2.
-
The Address Calculator can be used to determine proper memory addresses when converting between data types.
The Address Calculator can be used to determine proper memory addresses when converting between data types. It is in the XG5000 Tools menu.
Connecting to the XEM CPU and starting Monitor Mode will allow us to look at the data being converted to the different data types.
-
The images of the input data conversion show the automatic conversion from BYTE data to WORD and DWORD for the Input Data.
-
The images of the output data conversion shows automatic conversion from BYTE data to WORD data.
Input Data Conversion
Output Data Conversion
Note: DWORD is not done since the original output byte array size of 6 is not evenly divisible by 4.
LP312-1