Talk:Sign extension
Appearance
This is the talk page for discussing improvements to the Sign extension article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
This article is rated Stub-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||
|
Unnamed section
[edit]"c. word to doubleword", "c. w. to extended dw." [...] in the x86 context [...], a doubleword and extended doubleword [have] 32 bits [...]
What is the difference between doubleword and extended doubleword then? --Abdull 07:14, 6 July 2007 (UTC)
- I don't believe "extended doubleword" is actually a distinct data format, but instead I think the term refers to a doubleword in one of the extended registers (e.g. EAX or EDI) of the 32-bit x86 CPUs—the first of which was the 80386, which introduced the CWDE and CDQ instructions. These are the 32-bit versions of the instructions CBW and CWD respectively, which go all the way back to the original Intel 8086 CPU (introduced in 1978). CWD sign extends a 16-bit word into a 32-bit doubleword; since the 8086 has only 16-bit registers, it and every x86 CPU since (for software compatibility) puts the doubleword result of this instruction into the register pair DX:AX. The 32-bit version of CWD is CDQ, which sign extends the 32-bit number in EAX into a 64-bit quadword in EDX:EAX. CBW sign extends a byte in AL (low 8-bits of 16-bit register AX) into AX, and its 32-bit version CWDE extends a word in AX into a doubleword in EAX. So the original CWD and the newer CWDE both sign-extend a 16 bits word into a 32 bits doubleword, but they differ in whether the doubleword result is placed in two word registers (DX and AX) or one doubleword register (EAX, where the "E" stands for "Extended"). It is true to say both that the new instruction to sign-extend a word into a doubleword within one 32-bit register was needed, and that the two instructions CWDE and CDQ arose naturally from the way that 32-bit operations were added to the formerly 16-bit x86 instruction set (by generally redefining the instructions operating on 16-bit registers to operate on 32-bit registers instead, when the instructions are interpreted in 32-bit mode. However, while this is precisely how CDQ is relates to CWD, in the case of CWDE there has also been a special change of the source operand from byte [AL] to word [AX], which is not the normal pattern for 16-bit instructions interpreted in 32-bit mode).
- This information should probably be used to clarify the mention of these instructions at the end of the article, but I'll leave that to someone else (who seconds this proposal) to implement.
- Also, here's a web reference: https://courses.engr.illinois.edu/ece390/archive/spr2002/books/labmanual/inst-ref-cbw.html 98.114.141.122 (talk) 13:02, 13 October 2014 (UTC)