54 lines
2.1 KiB
HTML
54 lines
2.1 KiB
HTML
<html><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
<html>
|
|
|
|
<head>
|
|
<title>80386 Programmer's Reference Manual -- Opcode CWD</title>
|
|
</head>
|
|
|
|
<body>
|
|
<b>up:</b> <a href="C17.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C17.HTM">Chapter 17 -- 80386 Instruction Set</a><br>
|
|
<b>prev:</b><a href="CMPS.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/CMPS.HTM"> CMPS/CMPSB/CMPSW/CMPSD Compare String Operands</a><br>
|
|
<b>next:</b><a href="DAA.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/DAA.HTM"> DAA Decimal Adjust AL after Addition</a>
|
|
<p>
|
|
<hr>
|
|
<p>
|
|
<h1>CWD/CDQ -- Convert Word to Doubleword/Convert Doubleword to Quadword</h1>
|
|
<pre>
|
|
|
|
|
|
|
|
Opcode Instruction Clocks Description
|
|
|
|
99 CWD 2 DX:AX := sign-extend of AX
|
|
99 CDQ 2 EDX:EAX := sign-extend of EAX
|
|
</pre>
|
|
<h2>Operation</h2>
|
|
<pre>
|
|
|
|
|
|
|
|
IF OperandSize = 16 (* CWD instruction *)
|
|
THEN
|
|
IF AX < 0 THEN DX := 0FFFFH; ELSE DX := 0; FI;
|
|
ELSE (* OperandSize = 32, CDQ instruction *)
|
|
IF EAX < 0 THEN EDX := 0FFFFFFFFH; ELSE EDX := 0; FI;
|
|
FI;
|
|
</pre>
|
|
<h2>Description</h2>
|
|
CWD converts the signed word in AX to a signed doubleword in DX:AX by extending the most significant bit of AX into all the bits of DX. CDQ converts the signed doubleword in EAX to a signed 64-bit integer in the register pair EDX:EAX by extending the most significant bit of EAX (the sign bit) into all the bits of EDX. Note that CWD is different from CWDE. CWDE uses EAX as a destination, instead of DX:AX.
|
|
<h2>Flags Affected</h2>
|
|
None
|
|
<h2>Protected Mode Exceptions</h2>
|
|
None
|
|
<h2>Real Address Mode Exceptions</h2>
|
|
None
|
|
<h2>Virtual 8086 Mode Exceptions</h2>
|
|
None
|
|
<p>
|
|
<hr>
|
|
<p><b>up:</b> <a href="C17.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/C17.HTM">Chapter 17 -- 80386 Instruction Set</a><br>
|
|
<b>prev:</b><a href="CMPS.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/CMPS.HTM"> CMPS/CMPSB/CMPSW/CMPSD Compare String Operands</a><br>
|
|
<b>next:</b><a href="DAA.HTM" tppabs="http://webster.cs.ucr.edu/Page_TechDocs/Doc386/DAA.HTM"> DAA Decimal Adjust AL after Addition</a>
|
|
</body>
|
|
|