CS261 - Midterm 2 Flashcards
Elements of an array are next to each other in memory
True
Does A[i] = *(A+i)?
True
C has always supported variable sized multidimensional arrays?
False
How big will int C[5] be if ints are 32 bits?
It will be 20 bytes long.
Assume array long B[10] starts at address x. What address will be B[5] be?
x + 40
Assume the address of int C[5] is in %rdx, and i is in %rcx. What is the address for C[i]?
(%rdx, %rcx, 4)
%rdx = base register of C[5] %rcx = index register i 4 = an integer is 4 bytes, so the scale is going to be 4
Memory Addressing Mode
D(Rb, Ri, S) D = Constant "displacment" of Rb = Base register Ri = Index Register: Any, except for %rsp S = Scale: 1,2,4,8
Assume long A[4][6]. What will the size of A be?
8 * 4 * 6
long = 8 bytes
4 * 6 = 24 cells
Assuming long A[4][6] has base address x. What will the address of A[1][0] be?
x + 6*8
All pointers in C are the same type?
False, like in *p; char *c;
Adding 1 to a pointer will always add 1 byte
False
Pointers can point to functions
True
All pointers are how many bytes?
8
To add 2 operands in y86, the must both be
registers
y86 instructions are all the same size
False, 1-10 bytes