Some instructions have synonyms alternate names for

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: cussion With the exception of the right shift operations, none of the instructions distinguish between signed and unsigned operands. Two’s complement arithmetic has the same bit-level behavior as unsigned arithmetic for all of the instructions listed. Figure 3.7 shows an example of a function that performs arithmetic operations and its translation into assembly. As before, we have omitted the stack set-up and completion portions. Function arguments x, y, and z are stored in memory at offsets 8, 12, and 16 relative to the address in register %ebp, respectively. Instruction 3 implements the expression x+y, getting one operand y from register %eax (which was fetched by instruction 1) and the other directly from memory. Instructions 4 and 5 perform the computation z*48, first using the leal instruction with a scaled-indexed addressing mode operand to compute ´Þ · ¾Þ µ ¿Þ , and then shifting this value left 4 bits to compute ¾ ¡¿Þ Þ . The C compiler often generates combinations of add and shift instructions to perform multiplications by constant factors, as was discussed in Sectio...
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