Question: A. Which registers are used to hold program values x, y, and n? B. How has the compiler eliminated the need for pointer variable p

For the C code short dw_loop (short x) { short y = x/9; short *p=&x; short do { } n 4*x; = x += y; (*p) += 5;

1 2 23 4 5 6 7 8 9 10 11 short dw_loop (short x) x initially in /rdi dw_loop: movq movq idivq leaq .L2: %rdi,

A. Which registers are used to hold program values x, y, and n?

B. How has the compiler eliminated the need for pointer variable p and the pointer dereferencing implied by the expression (*p)+=5?

C. Add annotations to the assembly code describing the operation of the program, similar to those shown in Figure 3.19(c).

Figure 3.19(c) 

(c) Corresponding assembly-language code long fact_do (long n) n in %rdi 1 2 3 4 5 6 7 8 fact_do: movl .L2:

For the C code short dw_loop (short x) { short y = x/9; short *p=&x; short do { } n 4*x; = x += y; (*p) += 5; n = 2; while (n > 0); return x; GCC generates the following assembly code:

Step by Step Solution

3.35 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code generated when compiling loops can be tricky to analyze because the compiler can perform ma... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Systems A Programmers Perspective Questions!