Question: A. Write a goto version in C that performs the same computation and mimics the control flow of the assembly code, in the style shown

A. Write a goto version in C that performs the same computation and mimics the control flow of the assembly code, in the style shown in Figure 3.16(b). You might find it helpful to first annotate the assembly code as we have done in our examples.
B. Explain why the assembly code contains two conditional branches, even though the C code has only one if statement.
Figure 3.16(b)

When given the C code void cond(short a, short *p) { } if (a && *p < a) *p = a; GCC generates the following assembly code: void cond(short a, short *p) a in %rdi, p in %rsi cond: testq %rdi, %rdi je .L1 cmpq %rsi, (%rdi) jle .L1 movq %rdi, (%rsi) .L1: rep; ret
Step by Step Solution
3.49 Rating (159 Votes )
There are 3 Steps involved in it
Annotating assembly code and writing C code that mimic... View full answer
Get step-by-step solutions from verified subject matter experts
