A useful measure for many programs is cycles per

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: d_ele (Figure 3.24(b)) is not optimal. Write code for this function based on a hybrid of procedures fix_prod_ele_opt (Figure 3.23) and var_prod_ele_opt (Figure 3.24) that is correct for all values of n, but compiles into code that can keep all of its temporary data in registers. Recall that the processor only has six registers available to hold temporary data, since registers %ebp and %esp cannot be used for this purpose. One of these registers must be used to hold the result of the multiply instruction. Hence, you must reduce the number of local variables in the loop from six (result, Aptr, B, nTjPk, n, and cnt) to five. Homework Problem 3.36 [Category 2]: 198 CHAPTER 3. MACHINE-LEVEL REPRESENTATION OF C PROGRAMS You are charged with maintaining a large C program, and you come across the following code: code/asm/structprob-ans.c 1 2 3 4 5 6 7 8 9 10 11 12 typedef struct { int left; a_struct a[CNT]; int right; } b_struct; void test(int i, b_struct *bp) { int n = bp->left + bp->right; a_struct *ap = &bp->a[i]; ap->x[ap->idx] = n; } code/asm/structprob-ans.c Unfortunatel...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online