Qdatasheet_Logo
Integrated circuits, Transistor, Semiconductors Search and Datasheet PDF Download Site

ST20-C1 View Datasheet(PDF) - STMicroelectronics

Part Name
Description
MFG CO.
ST20-C1
ST-Microelectronics
STMicroelectronics ST-Microelectronics
'ST20-C1' PDF : 205 Pages View PDF
4.5 Forming addresses
Access to a component of an array can be split into two sections; first the address of
the component must be constructed, and then the transfer of data to or from that
component must be performed.
Evaluating a subscript
Array subscripts can be evaluated efficiently using the smul or mul instruction. If array
A has been declared by
int A[S1] . . . [Sn];
where Si (i = 1..n) are the dimensions, then one way of arranging this in memory is to
have all elements of the array in a contiguous block. For the purposes of this section,
suppose that the elements in the last dimension are stored adjacently; otherwise
change the order of the dimension subscripts. For example Figure 4.1 shows the
elements of a particular three dimensional array (Array) stored in this way.
int Array[2][2][3];
Increasing
memory
addresses
Array[1][1][2]
Array[1][1][1]
Array[1][1][0]
Array[1][0][2]
Array[1][0][1]
Array[1][0][0]
Array[0][1][2]
Array[0][1][1]
Array[0][1][0]
Array[0][0][2]
Array[0][0][1]
Array[0][0][0]
Contiguous
locations for
words in
memory
space
Figure 4.1 A possible method of storing an array of integers
If an access is required to the following array element
A[e1] . . . [en]
then the code to evaluate the subscript is
e1;
ldc S2; mul; e2; add;
ldc S3; mul; e3; add;
. ..
ldc Sn; mul; en; add;
For example to evaluate the subscript for element Array[x][y][z], (where Array
is declared as in Figure 4.1) the code sequence is
ld x;
ldc 2; mul; ld y; add;
ldc 3; mul; ld z; add;
If x is 1, y is 0 and z is 2, then this evaluates to 8, which as can be seen from Figure
4.1, is the correct offset from the base of the array.
42/205
®
Share Link: GO URL

All Rights Reserved © qdatasheet.com  [ Privacy Policy ] [ Contact Us ]