- 作业标题:CSCI 2122 - Systems Programming - A4
- 课程名称:Dalhouse University CSCI 2122 Systems Programming
- 完成周期:2天
1. Description
(1) The following code transposes the elements of an M × M array, where M is a constant defined by # define:
void transpose(long A[M][M]) { |
When compiled, with optimization level −O1, GCC generates the following code
for the inner loop of the function.
1 .L1: |
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?
(2) (a) The assembly code of the table below 2c was generated by compiling the C
code of Table 1.
(b) Find the expression for the unknown macro expressions (A) and (B) appearing
in Table 1. [Hint: they are both only in terms of variable ‘n’.]
(c) Identify the line numbers in the assembly code that correspond to the following
operations from the C code:
- long result = 0;
- result += A[i][j];
- i < NR(n);
Assembly code for mystery function. Note that the line numbers in the first
column have no functional value, but are supplied to help you answer the problem
1. col sum: |
Table 1. C code for column-sum function. (A) and (B) represent the unknown definitions for the macro expressions that you are required to find.
|