Viewing an Array as a Block of Memory

The data in an array is stored contiguously in memory. The file (array) instructions typically require a starting address within an array and a length, which determines the elements and how many elements the instruction reads or writes.
NOTE:
If an instruction attempts to read data beyond the end of an array, the instruction reads whatever data happens to be there and processes it as if it were valid data (no error occurs). If an instruction attempts to write data beyond the end of an array, a major fault occurs (type 4, code 20).
These instructions manipulate array data as a contiguous block of memory (the remaining instructions manipulate array data as individual elements):
How the controller stores array data
The following table shows the sequential order of the elements in the examples on Viewing an Array as a Collection of Elements.
One-Dimensional Array Elements (ascending order)
Two-Dimensional Array Elements (ascending order)
Three-Dimensional Array Elements (ascending order)
one_d_array[0]
one_d_array[1]
one_d_array[2]
one_d_array[3]
one_d_array[4]
one_d_array[5]
one_d_array[6]
For an array with only one dimension, tag_name[subscript_0], subscript_0 increments to its maximum value.
two_d_array[0,0]
two_d_array[0,1]
two_d_array[0,2]
two_d_array[0,3]
two_d_array[0,4]
two_d_array[1,0]
two_d_array[1,1]
two_d_array[1,2]
two_d_array[1,3]
two_d_array[1,4]
two_d_array[2,0]
two_d_array[2,1]
two_d_array[2,2]
two_d_array[2,3]
two_d_array[2,4]
two_d_array[3,0]
two_d_array[3,1]
two_d_array[3,2]
two_d_array[3,3]
two_d_array[3,4]
For an array with two dimensions,
tag_name[subscript_0,subscript_1], subscript_0 is held fixed at 0 while subscript_1 increments from 0 to its maximum value. Subscript_0 then increments by 1 (if dimension 0 is greater than 1) and is held fixed while subscript_1 increments through its range again. This pattern continues until both subscripts reach their maximum values.
three_d_array[0,0,0]
three_d_array[0,0,1]
three_d_array[0,0,2]
three_d_array[0,0,3]
three_d_array[0,1,0]
three_d_array[0,1,1]
three_d_array[0,1,2]
three_d_array[0,1,3]
three_d_array[0,2,0]
three_d_array[0,2,1]
three_d_array[0,2,2]
three_d_array[0,2,3]
three_d_array[1,0,0]
three_d_array[1,0,2]
three_d_array[1,0,3]
three_d_array[1,1,0]
three_d_array[1,1,1]
three_d_array[1,1,2]
three_d_array[1,1,3]
three_d_array[1,2,0]
three_d_array[1,2,1]
three_d_array[1,2,2]
three_d_array[1,2,3]
For an array with three dimensions, tag_name[subscript_0, subscript_1, subscript_2], subscript_0 is held fixed at 0 while subscript_1 and subscript_2 increment just like a two- dimensional array. Subscript_0 then increments by 1 (if dimension 0 is greater than 1) and is held fixed until subscript_1 and subscript_2 reach their maximum values. This pattern continues until all three subscripts reach their maximum values.
Varying a dimension
The AVE, SRT, and STD instructions have a Dimension to vary operand. The instruction uses this operand to calculate an offset that the instruction uses to determine which elements of the Array to read or write.
Array
Dimension to vary
Offset
one dimension
0
1
two dimension
0
dimension_1
1
1
three dimension
0
(dimension_1) ? (dimension_2)
1
dimension_2
2
1
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.