Instruction Set
4-61
IDIV
IDIV
Operation It Performs
Flag Settings After Instruction
Examples
This example divides one 16-bit integer by an 8-bit integer.
if (size(
divisor) == 8)
/* signed byte division */
{
temp = AX /
divisor;
if (size(temp) > size(AL))
/* quotient too large */
interrupt(0);
else
{
AH = AX %
divisor;
/* remainder */
AL = temp;
/* quotient */
}
}
if (size(
divisor) == 16)
/* signed word division */
{
temp = DX::AX /
divisor;
if (size(temp) > size(AX))
/* quotient too large */
interrupt(0);
else
{
DX = DX::AX %
divisor;
/* remainder */
AX = temp;
/* quotient */
}
}
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
?
–
–
–
?
? res ? res ? res ?
SDIVIDEND
DW
-14500
; C75Ch
SDIVISOR
DB
123
; 7Bh
; divide word integer by byte integer
MOV
AX,SDIVIDEND
; AX = C75Ch = -14500
IDIV
SDIVISOR
; AL = 8Bh = -117, the quotient
; AH = 93h = -109, the remainder
Содержание 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...