Compute compare compute ab t1 ba t2 ca t3 compare ac

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: omitted. Parameters x and n are stored at memory locations with offsets 8 and 12, respectively, relative to the address in register %ebp. 1 2 3 4 movl 12(%ebp),%ecx movl 8(%ebp),%eax _____________ _____________ Get x Get n x <<= 2 x >>= n Fill in the missing instructions, following the annotations on the right. The right shift should be performed arithmetically. 108 CHAPTER 3. MACHINE-LEVEL REPRESENTATION OF C PROGRAMS code/asm/arith.c 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 10 11 int arith(int x, int y, int z) { int t1 = x+y; int t2 = z*48; int t3 = t1 & 0xFFFF; int t4 = t2 * t3; return t4; } code/asm/arith.c movl 12(%ebp),%eax movl 16(%ebp),%edx addl 8(%ebp),%eax leal (%edx,%edx,2),%edx sall $4,%edx andl $65535,%eax imull %eax,%edx movl %edx,%eax Get y Get z Compute t1 = x+y Compute z*3 Compute t2 = z*48 Compute t3 = t1&0xFFFF Compute t4 = t2*t3 Set t4 as return val (a) C code (b) Assembly code Figure 3.7: C and Assembly Code for Arithmetic Routine Body. The stack set-up and completion portions have been omitted. 3.5.4 Dis...
View Full Document

Ask a homework question - tutors are online