Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fill in the table. For column 3, always assume that the given array is stored at

ID: 3603349 • Letter: F

Question

Fill in the table. For column 3, always assume that the given array is stored at address 0x100 (256) Answer in either hex or decimal. If you use hex, you MUST prefix with Ox. rray declaration Size (in bytes) int A [10)[12] int "B[8]15] ddress assuming array is stored at 0x100 (256) Address A[3][6] ress B[4][4] dress C[8][6] = har C[12110] The code segment below is to get the value of AOND for an integer array AIN]M] for some constant values N and M. Assume the address of the array is in dx, the row s in %rdi and the column is in %rsi lea (%rsi,%rax,4),%rax mov (%rdx,%rax,4),%eax Which of the following statements is true? O The array has 80 rows (N-80) All of the statements are false The array has 80 columns (M-80) O The array has 20 rows (N 20) O The array has 20 columns (M -20)

Explanation / Answer

Solution:

a)

1. int A[10][12]

size of 1 int = 4 bytes

size of A = 10*12* 4= 480 bytes

Address(A[J,K]) = Base(A) + w[N(J-1)+(k-1))] where N is the number of columns and w is the size of 1 element in row major order

Address(A[8][6]) = 256 +4(6(7)+(5)) = 256 +4(42+5) = 256 +4(47) = 256 + 188 = 444

2.

int *B[8][5]

size of 1pointer to int = 4bytes

size of B = 8*5*4 = 160 bytes

Address(B[4][4]) = 256 + 4(5(4-1) + (4-1)) = 256 + 4(5(3) +3) = 256 + 4(18) = 256 + 72 = 328

3.

char C[12][10]

size of 1 char = 1

size of C = 12*10*1 = 120 bytes

Address(C[8][6]) = 256 + 1(10(7) +5) = 256 + 75 = 331

b)

The answer is option 3

that is , the array has 80 rows(n=80)

Explanation:

1)

rax = rdi + rdi*4

rax = rdi * 5

2)

rax = rsi + tax * 4

= rsi + (rdi*5) * 4

= rsi + rdi * 20

3)

eax = rds + rax +*4

= rdx + (rsi + rdi * 4) * 20

eax = rdx + 4 * rsi + 80 * rdi

I hope this helps, please let me know in case of any doubt. Thumbs up if this helped.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote