
Instruction Set
4-65
IMUL
IMUL
Flag Settings After Instruction
Examples
This example uses the single-operand form of IMUL to multiply an 8-bit integer in memory
by an integer in AL.
/* (continued) */
if (operands() == 2)
/* substitute ”product” for multiplicand */
multiplicand = product;
if (operands() >= 2)
{
temp =
multiplicand * multiplier;
if (size(temp) == size(
product))
/* product will fit */
{
/* store result */
product = temp;
/* clear overflow and carry flags */
OF = CF = 0;
}
else
/* product won’t fit */
{
/* store only lower half of result */
product = 0x00FF & temp;
/* set overflow and carry flags */
OF = CF = 1;
}
}
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
Processor Status
Flags Register
reserved
OF DF
IF TF SF ZF
AF
PF
CF
? = undefined; – = unchanged
For the single-operand form:
CF and OF = 1 if the product is large enough to
require the full destination.
CF and OF = 0 if the product is small enough to fit
in the
low half of the destination.
–
–
–
?
? res ? res ? res
For the two- and three-operand forms:
CF and OF = 1 if the product is too large to fit in the
destination.
CF and OF = 0 if the product is small enough to fit
in the destination.
BMULTIPLICAND
DB -10
; F6h
; 8-bit integer multiplication: AX = BMULTIPLICAND * AL
MOV
AL,7
; AL = 07h = 7
IMUL
BMULTIPLICAND
; AX = FFBAh = -70
Содержание Am186 Series
Страница 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Страница 10: ...Table of Contents x...
Страница 18: ...Programming 1 8...
Страница 40: ...Instruction Set Listing 3 14...