5.89 · exercise

Advanced quiz: arrays and structures

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

Multiple choice

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?

Multiple choice

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?

Multiple choice

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?

Multiple choice

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?

Multiple choice

A function needs 16 bytes to save fp and lr, plus room for the locals sum, count, and the array scores. Which definition of alloc makes add sp, sp, alloc reserve at least that much space and leave sp 16-byte aligned?