A good strategy is to start by looking carefully at

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: locations with offsets 8, 12, and 16 relative to the address in register %ebp. The code stores the return value in register %eax. Write C code for decode2 that will have an effect equivalent to our assembly code. You can test your solution by compiling your code with the -S switch. Your compiler may not generate identical code, but it should be functionally equivalent. Homework Problem 3.32 [Category 2]: The following C code is almost identical to that in Figure 3.11: 1 2 3 4 5 6 7 8 9 10 int absdiff2(int x, int y) { int result; if (x < y) result = y-x; else result = x-y; return result; } When compiled, however, it gives a different form of assembly code: 1 2 3 4 5 6 7 8 9 movl 8(%ebp),%edx movl 12(%ebp),%ecx movl %edx,%eax subl %ecx,%eax cmpl %ecx,%edx jge .L3 movl %ecx,%eax subl %edx,%eax .L3: A. What subtractions are performed when Ü Ý? When Ü Ý? B. In what way does this code deviate from the standard implementation of if-else described previously? C. Using C syntax (including goto’s), show the general form...
View Full Document

Ask a homework question - tutors are online