March 2010
Beginner
760 pages
18h 51m
English
Well, you've seen the formulas for computing the address of a multidimensional array element. Now it's time to see how to access elements of those arrays using assembly language.
The mov, shl, and intmul instructions make short work of the various equations that compute offsets into multidimensional arrays. Let's consider a two-dimensional array first.
static
i: int32;
j: int32;
TwoD: int32[ 4, 8 ];
.
.
.
// To perform the operation TwoD[i,j] := 5; you'd use code like the following.
// Note that the array index computation is (i*8 + j)*4.
mov( i, ebx );
shl( 3, ebx ); // Multiply by 8 (shl by 3 is a multiply by 8).
add( j, ebx );
mov( 5, TwoD[ ebx*4 ] );Note that this code does ...