Practice problem 314 the following code fragment

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: Figure 3.13(c). D. Write a goto version (in C) of the function that has similar structure to the assembly code, as was done in Figure 3.13(b). 126 For Loops CHAPTER 3. MACHINE-LEVEL REPRESENTATION OF C PROGRAMS The general form of a for loop is as follows: for (init-expr; test-expr; update-expr) body-statement The C language standard states that the behavior of such a loop is identical to the following code using a while loop: init-expr; while (test-expr) body-statement update-expr; That is, the program first evaluates the initialization expression init-expr. It then enters a loop where it first evaluates the test condition test-expr, exiting if the test fails, then executes the body of the loop bodystatement, and finally evaluates the update expression update-expr. The compiled form of this code then is based on the transformation from while to do-while described previously, first giving a do-while form: init-expr; if (!test-expr) goto done; do body-statement update-expr; while (test-expr);...
View Full Document

Ask a homework question - tutors are online