5.49 · exercise

Quiz: Arrays and Structures - Advanced

Work through offset arithmetic for multi-dimensional arrays and padded structures, scaled register addressing, and the constant that allocates an aligned stack frame.

0 of 5 correct

Knowledge Check

An array is declared int ia[2][3][4]. Which expression gives the byte offset of ia[i][j][k] from the base of the array?

Knowledge Check

The base address of an int array is in x21 and a 64-bit index is in x20. Which line stores w22 into the element at that index in one instruction?

Knowledge Check

The same array base is in x21, but the index is now a signed 32-bit value in w20. Which line stores w22 into the element at that index?

Knowledge Check

Given struct rec { int id; char tag; short flag; }; and struct rec table[8];, what byte offset from the start of table does table[3].flag sit at?

Knowledge Check

A function needs a frame record plus room for the locals a, b, and the array ia. Which equate gives a constant that makes add sp, sp, alloc reserve at least that much space and leave sp 16-byte aligned?