Arrays Flashcards

(11 cards)

1
Q

aggregations of atomic or other structured data types

A

structured data types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A

generally false, but can be true if the address of the array is moved to a register (ex. mov rbx, lst)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

base address of the array

A

array variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

the ith element from the base address is represented by ____

A

i*size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

true/false

the size needed in referencing array elements is in bits

A

false, the size should be in terms of bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how many bytes does each size have?

A

byte - 1 byte
word - 2 bytes
doubleword - 4 bytes (2x word)
quadword - 8 bytes (4x word)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how can you access the ith element of an array named arr (general form)

A

[arr+i*size]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

yes, a register (usually rsi) can be used instead of an immediate value in place of i/index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what value will we get from this:

qword[arr+32]

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

is this a valid way of accessing the 3rd element of an array:

dword[arr+3*4]

A

no, to access the 3rd element it should be dword[arr+2*4] since we use a 0-based counting system (0, 1, 2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

is this a valid way of accessing the 5th element of an array:

qword[arr+4*4]

A

no, it should be qword[arr+4*8] since quadword has 8 bytes not 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly