Recall that the result of the function is returned in

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: of C, the compiler must use the different types of jump instructions we have just seen. We will go through the most common constructs, starting from simple conditional branches, and then considering loops and switch statements. 3.6.4 Translating Conditional Branches Conditional statements in C are implemented using combinations of conditional and unconditional jumps. For example, Figure 3.11 shows the C code for a function that computes the absolute value of the difference of two numbers (a). G CC generates the assembly code shown as (c). We have created a version in C, called gotodiff (b), that more closely follows the control flow of this assembly code. It uses the goto statement in C, which is similar to the unconditional jump of assembly code. The statement goto less on line 6 causes a jump to the label less on line 8, skipping the statement on line 7. Note that using goto statements is generally considered a bad programming style, since their use can make code very difficult to rea...
View Full Document

Ask a homework question - tutors are online