This preview shows page 1. Sign up to view the full content.
Unformatted text preview: d and debug. We use them in our presentation as a way to construct C programs that describe the control ﬂow of assembly-code programs. We call such C programs “goto code.” The assembly code implementation ﬁrst compares the two operands (line 3), setting the condition codes. If the comparison result indicates that x is less than y, it then jumps to a block of code that computes x-y (line 9). Otherwise it continues with the execution of code that computes y-x (lines 5 and 6). In both cases the computed result is stored in register %eax, and ends up at line 10, at which point it executes the stack completion code (not shown). The general form of an if-else statement in C is given by the if-else statement following template: if (test-expr) then-statement else else-statement where test-expr is an integer expression that evaluates either to 0 (interpreted as meaning “false”) or to a nonzero value (interpreted as meaning “true”). Only one of the two branch statements (then-statement or else-statement) is executed. For this general form, the assembly implementation typically follows the form shown below, where we use C syntax to describe the control ﬂow: t = t...
View Full Document
- Spring '10
- The American