Programs stored in rom devices are often referred to

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: max(int x, int y) { return (x < y) ? y : x; } Homework Problem 5.13 [Category 2]: Using conditional moves, the general technique for translating a statement of the form: val = cond-expr ? then-expr : else-expr; is to generate code of the form: val = then-expr; temp = else-expr; test = cond-expr; if (test) val = temp; where the last line is implemented with a conditional move instruction. Using the example of Practice Problem 5.5 as a guide, state the general requirements for this translation to be valid. Homework Problem 5.14 [Category 2]: The following function computes the sum of the elements in a linked list: 1 2 3 4 5 6 7 8 static int list_sum(list_ptr ls) { int sum = 0; for (; ls; ls = ls->next) sum += ls->data; return sum; } The assembly code for the loop, and its translation of the first iteration into operations yields the following: Assembly Instructions .L43: addl 4(%edx),%eax movl (%edx),%edx testl %edx,%edx jne .L43 Execution Unit Operations movl 4(%edx.0) addl t.1,%eax.0 load (%edx.0) testl %...
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