Assembly Part 8 Flashcards

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

Two D array: T A[R][C]
What is the size of the array

A

RCK

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

To get access to a specified nested array

A
  1. Compute th address to the desired row
  2. Compute the offset within the row to the desired element
  3. Add 1 and 2; result is address of desired element
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to get the address of A[i]
Each element of type T requires K bytes

A

Starting address: A + i(CK)

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

How to get address of A[i][j]
Each element is of type T which requires K bytes

A

A + (i(CK)) + jK = A + ((iC) + j)*K

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

Suppose we have
Int *univ[3] = {mit, come, ucb}

MIT, cmu, and ucb are arrays

What is the computation

A

Must do TWO MEMORY READS
Mem[Mem[univ + 8index] + 4digit]

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

a in %rdi, i in %rsi, j in %rdx

Int a[16][16]
Total size of array:

A

16164 = 1024 bytes

Salq $6, %rsi
Addq %rsi, %rdi
Movl (%rdi, %rdx,4), %eax

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

n in %rdi, a in %rsi, i in %rdx, j in %rcx

Non matrix access

A

Imulq %rdx, %rdi. Rdi = ni
Leaq (%rsi, %rdi, 4), %rax. #a + 4
n*i
Movl (%rax, %rcx, 4), %eax
Ret

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