1.
Assuming
a) all variables are held in registers
b) all variables are held on the stack
write ARM code for
int a1, a2, a3, a4, b, c, d, i, j, k; . . . a1 = b * 10 + c; a2 = b + 15 * c; a3 = (b + c) * d / (i + j * k); a4 = -b + c;
2. Assuming i, j and k are in registers, but a is on the stack, write ARM code for
int i, j, k, a[3][4][5]; . . . a[i][j][k]= 6;
3. Assuming all variables are in registers, write ARM code for
do statement; while (a<b); . . . for (i=0; i<100; i++) statement;
4. Show the stack layout for the following declaration
struct vehicle {
char make[10];
int cc;
boolean taxed;
char regno[7];
enum {red,blue,white} colour;
struct {
int unladen_weight;
int gross_weight;
} weight;
} mycar;
5. Show the stack layout and write down the ARM code for the following C function.
int test(void)
{
int i, j, k, m, x, y;
j= k= m= 1;
for (i= 100; i>=90; i--)
while (j<100)
if (k==1)
if (m==2) j++;
else j+= 10;
x= 1;
y= i+x * (j+k/10);
return 0;
}