Instruction Set
4-40
CWD
Convert Word Integer to Doubleword
CWD
What It Does
CWD converts a 16-bit integer to a sign-extended 32-bit integer.
Syntax
Description
CWD converts the signed word in the AX register to a signed doubleword in the DX::AX
register pair by extending the most significant bit of the AX register into all the bits of the
DX register.
Operation It Performs
Flag Settings After Instruction
Examples
This example divides one 16-bit integer by another 16-bit integer.
Form
Opcode
Description
Clocks
Am186 Am188
CWD
99
Put signed extension of AX in DX::AX
4
4
CWD
/* extend sign of AX into DX */
if (AX < 0)
DX = 0xFFFF;
else
DX = 0x0000;
? = unknown; – = unchanged
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
5800
; 16A8h
SDIVISOR
DW
-45
; FFD3h
; divide word integers
MOV
AX,SDIVIDEND
; AX = 16A8h = 5800
CWD
; DX::AX = 000016A8h = 5800
IDIV
SDIVISOR
; AX = FF80h = -128, the quotient
; DX = 0028h = -40, the remainder
Summary of Contents for Am186 Series
Page 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Page 10: ...Table of Contents x...
Page 18: ...Programming 1 8...
Page 40: ...Instruction Set Listing 3 14...