Arrays Flashcards
(11 cards)
aggregations of atomic or other structured data types
structured data types
true/false
the variable name is not the only name by which we can reference the location of the array in memory, specified registers can also be used
generally false, but can be true if the address of the array is moved to a register (ex. mov rbx, lst)
base address of the array
array variable
the ith element from the base address is represented by ____
i*size
true/false
the size needed in referencing array elements is in bits
false, the size should be in terms of bytes
how many bytes does each size have?
byte - 1 byte
word - 2 bytes
doubleword - 4 bytes (2x word)
quadword - 8 bytes (4x word)
how can you access the ith element of an array named arr (general form)
[arr+i*size]
is this a valid way to access an array element
mov rsi, 0
mov word[scores+rsi*2], ax
*assume that the data sizes used are correct
yes, a register (usually rsi) can be used instead of an immediate value in place of i/index
what value will we get from this:
qword[arr+32]
the 5th element
explanation:
qword has 8 bytes
32 / 8 = 4
since element accessing is 0-based (we start counting on 0), the element being accessed is the 5th element (0, 1, 2, 3, 4)
is this a valid way of accessing the 3rd element of an array:
dword[arr+3*4]
no, to access the 3rd element it should be dword[arr+2*4] since we use a 0-based counting system (0, 1, 2)
is this a valid way of accessing the 5th element of an array:
qword[arr+4*4]
no, it should be qword[arr+4*8] since quadword has 8 bytes not 4