ia-32_instruction-set-ref_a-m

Ac0 if a memory operand effective address is outside

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: e destination operand (a general-purpose register). When an immediate value is used as an operand, it is sign-extended to the length of the destination operand format. The CF and OF flags are set when significant bit (including the sign bit) are carried into the upper half of the result. The CF and OF flags are cleared when the result (including the sign bit) fits exactly in the lower half of the result. The three forms of the IMUL instruction are similar in that the length of the product is calculated to twice the length of the operands. With the one-operand form, the product is stored exactly in the destination. With the two- and three- operand forms, however, the result is truncated to the length of the destination before it is stored in the destination register. Because of this truncation, the CF or OF flag should be tested to ensure that no significant bits are lost. The two- and three-operand forms may also be used with unsigned operands because the lower half of the product is the same regardless if the operands are Vol. 2 3-453 INSTRUCTION SET REFERENCE, A-M signed or unsigned. The CF and OF flags, however, cannot be used to determine if the upper half of the result is non-zero. In 64-bit mode, the instruction's default operation size is 32 bits. Use of the REX.R prefix permits access to additional registers (R8-R15). Use of the REX.W prefix promotes operation to 64 bits. Use of REX.W modifies the three forms of the instruction as follows. One-operand form --The source operand (in a 64-bit general-purpose register or memory location) is multiplied by the value in the RAX register and the product is stored in the RDX:RAX registers. Two-operand form -- The source operand is promoted to 64 bits if it is a register or a memory location. If the source operand is an immediate, it is sign extended to 64 bits. The destination operand is promoted to 64 bits. Three-operand form -- The first source operand (either a register or a memory location) and destination operand are promoted to 64 bits. Operation IF (NumberOfOperands = 1) THEN IF (OperandSize = 8) THEN AX AL SRC (* Signed multiplication *) IF AL = AX THEN CF 0; OF 0; ELSE CF 1; OF 1; FI; ELSE IF OperandSize = 16 THEN DX:AX AX SRC (* Signed multiplication *) IF sign_extend_to_32 (AX) = DX:AX THEN CF 0; OF 0; ELSE CF 1; OF 1; FI; ELSE IF OperandSize = 32 THEN EDX:EAX EAX SRC (* Signed multiplication *) IF EAX = EDX:EAX THEN CF 0; OF 0; ELSE CF 1; OF 1; FI; ELSE (* OperandSize = 64 *) RDX:RAX RAX SRC (* Signed multiplication *) IF RAX = RDX:RAX THEN CF 0; OF 0; ELSE CF 1; OF 1; FI; FI; FI; ELSE IF (NumberOfOperands = 2) 3-454 Vol. 2 INSTRUCTION SET REFERENCE, A-M THEN temp DEST SRC (* Signed multiplication; temp is double DEST size *) DEST DEST SRC (* Signed multiplication *) IF temp DEST THEN CF 1; OF 1; ELSE CF 0; OF 0; FI; ELSE (* NumberOfOperands = 3 *) DEST SRC1 SRC2 (* Signed multiplication *) temp SRC1 SRC2 (* Signed multiplication; temp is double SRC1 size *) IF temp DEST THEN CF 1; OF 1; E...
View Full Document

This note was uploaded on 10/01/2013 for the course CPE 103 taught by Professor Watlins during the Winter '11 term at Mississippi State.

Ask a homework question - tutors are online