Assembly Language for Beginners

(nextflipdebug2) #1

1.20. ARRAYS


Row filling example


Let’s fill the second row with these values 0..3:


Listing 1.244: Row filling example

#include <stdio.h>


char a[3][4];


int main()
{
int x, y;


// clear array
for (x=0; x<3; x++)
for (y=0; y<4; y++)
a[x][y]=0;

// fill second row by 0..3:
for (y=0; y<4; y++)
a[1][y]=y;
};


All three rows are marked with red. We see that second row now has values 0, 1, 2 and 3:


Figure 1.92:OllyDbg: array is filled

Column filling example


Let’s fill the third column with values: 0..2:


Listing 1.245: Column filling example

#include <stdio.h>


char a[3][4];


int main()
{
int x, y;


// clear array
for (x=0; x<3; x++)
for (y=0; y<4; y++)
a[x][y]=0;

// fill third column by 0..2:
for (x=0; x<3; x++)
a[x][2]=x;
};


The three rows are also marked in red here.


We see that in each row, at third position these values are written: 0, 1 and 2.


Figure 1.93:OllyDbg: array is filled
Free download pdf