Assembly Part 7 Flashcards

1
Q

Arrays store multiple data objects of______ _______

A

Same type

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

Store sequentially, often accessed as an offset from a pointer which points to _______

A

Beginning of array

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

T A[L]

Continuously allocation region of ________ bytes in memory

A

L*sizeof(T) in memory

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

Static isn’t array[30];
Static int x = array[25]

$ in assembly language with a label gives an address. Array and x must have been define in the ______ section (.data) of the program

A

Data

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

In x86-64, memory to memory moves are _____ allowed

A

NOT

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

Int data[20];
How to allocate space for this on the stack??

A

Subq $80, %rsp. //allocate space on the stack
Leaq (%rsp), %rax //using rax as the base register for the array. So rax stores address of first element in array

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

Stack clean up before return example

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

How to allocate space of the stack

A

We need to subtract the size of the array from the stack
Then we need to store the address of top of the array to some other register (Leaq (%rsp), %rax)

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

What happens if an array holds elements larger than 1 byte? Ex: array of structures were each structure is 20 bytes
Want to access 5th element

A

Movq $5, %rcx
Imulq $20, %rax, %rax

Suppose we want &arr[5]
Leaq (%rbx, %rax), %rdx

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