Problem 618 solution pg 331 this problem is just a

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: ves you a chance to test your understanding of operands and the arithmetic instructions. Instruction addl %ecx,(%eax) subl %edx,4(%eax) imull $16,(%eax,%edx,4) incl 8(%eax) decl %ecx subl %edx,%eax Problem 3.5 Solution: [Pg. 107] This exercise gives you a chance to generate a little bit of assembly code. The solution code was generated by GCC. By loading parameter n in register %ecx, it can then use byte register %cl to specify the shift amount for the sarl instruction. 1 2 3 4 ·Ü Ü·Ý Ü· Ý ·Ü ½¼ · Ý · Ü · ¾Ý Result Destination 0x100 0x104 0x10C 0x108 %ecx %eax Value 0x100 0xA8 0x110 0x14 0x0 0xFD movl movl sall sarl 12(%ebp),%ecx 8(%ebp),%eax $2,%eax %cl,%eax Get x Get n x <<= 2 x >>= n Problem 3.6 Solution: [Pg. 108] This instruction is used to set register %edx to 0, exploiting the property that corresponds to the C statement i = 0. ÜˆÜ ¼ for any Ü. It This is an example of an assembly language idiom—a fragment of code that is often generated to fulfill a special purpose. Recognizing such idioms is one step in becoming proficient at read...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online