Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is question 3.65 (pg 317) from Book: Computer Systems: A Programmers Perspective (3rd Edition): The following code transposes the elements of an M M

This is question 3.65 (pg 317) from Book: Computer Systems: A Programmers Perspective (3rd Edition):

The following code transposes the elements of an M M array, where M is a constant by #define:

1 void transpose(long A[M] [M] {

2 long i, j;

3 for (i = 0; i < M; i++)

4 for (j = 0; j < i; j++) {

5 long t = A [i] [j];

6 A [i] [j] = A [j] [i];

7 A [j] [i] = t;

8 }

9 }

When compiled with optimization level -O1, gcc generates the following code for the inner loop of the function:

1 .L6

2 movq (%rdx), %rcx

3 movq (%rax, %rsi

4 movq %rsi, (%rdx)

5 movq %rcx, (%rax)

6 addq %8, %rdx

7 addq $120, %rax

8 cmpq %rdi, %rax

9 jne .L6

We can see that GCC has converted the array indexing to pointer code.

A. Which register holds a pointer to array element A [i] [j] ?

B. Which register holds a pointer to array element A [j] [i] ?

C. What is the value of M ?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 3 Lnai 6323

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

3642159389, 978-3642159381

More Books

Students also viewed these Databases questions

Question

My opinions/suggestions are valued.

Answered: 1 week ago