* remove "\r" nonsense
[mascara-docs.git] / i386 / i386.reference / CWD.htm
blob224767d232afb6ffb116be6753fd5994cd8b8446
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Opcode CWD</TITLE>
5 </HEAD>
6 <BODY>
7 <B>up:</B> <A HREF="c17.htm">
8 Chapter 17 -- 80386 Instruction Set</A><BR>
9 <B>prev:</B><A HREF="CMPS.htm"> CMPS/CMPSB/CMPSW/CMPSD Compare String Operands</A><BR>
10 <B>next:</B><A HREF="DAA.htm"> DAA Decimal Adjust AL after Addition</A>
11 <P>
12 <HR>
13 <P>
14 <H1>CWD/CDQ -- Convert Word to Doubleword/Convert Doubleword to
15 Quadword</H1>
17 <PRE>
18 Opcode Instruction Clocks Description
20 99 CWD 2 DX:AX := sign-extend of AX
21 99 CDQ 2 EDX:EAX := sign-extend of EAX
22 </PRE>
24 <H2>Operation</H2>
26 <PRE>
27 IF OperandSize = 16 (* CWD instruction *)
28 THEN
29 IF AX < 0 THEN DX := 0FFFFH; ELSE DX := 0; FI;
30 ELSE (* OperandSize = 32, CDQ instruction *)
31 IF EAX < 0 THEN EDX := 0FFFFFFFFH; ELSE EDX := 0; FI;
32 FI;
33 </PRE>
35 <H2>Description</H2>
37 CWD converts the signed word in AX to a signed doubleword in DX:AX
38 by extending the most significant bit of AX into all the bits of DX. CDQ
39 converts the signed doubleword in EAX to a signed 64-bit integer in the
40 register pair EDX:EAX by extending the most significant bit of EAX
41 (the sign bit) into all the bits of EDX. Note that CWD is different from
42 CWDE. CWDE uses EAX as a destination, instead of DX:AX.
44 <H2>Flags Affected</H2>
46 None
48 <H2>Protected Mode Exceptions</H2>
50 None
52 <H2>Real Address Mode Exceptions</H2>
54 None
56 <H2>Virtual 8086 Mode Exceptions</H2>
58 None
61 <P>
62 <HR>
63 <P>
64 <B>up:</B> <A HREF="c17.htm">
65 Chapter 17 -- 80386 Instruction Set</A><BR>
66 <B>prev:</B><A HREF="CMPS.htm"> CMPS/CMPSB/CMPSW/CMPSD Compare String Operands</A><BR>
67 <B>next:</B><A HREF="DAA.htm"> DAA Decimal Adjust AL after Addition</A>
68 </BODY>