IDIV
Instruction (Cont.)
CWD
(convert word to doubleword) instruction extends the sign bit of AX
into the DX
register.
CDQ
(convert doubleword to quadword) instruction extends the sign bit of EAX
into the EDX
register.
CWD — Convert Word to Doubleword |
|||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||||||||||||
CDQ — Convert Doubleword to Quadword |
|||||||||||||||||||||||||||||||||||
|
16-Bit Signed Division | 32-Bit Signed Division | Using CDQ |
.data x SDWORD 00101010h y SWORD -100h .code mov dx, WORD PTR x+2 movzx eax, WORD PTR x idiv y call DumpRegs |
.data x SDWORD -101010h y SDWORD 100h .code mov eax, x mov edx, 0FFFFFFFFh idiv y call DumpRegs |
.data x SDWORD -101010h y SDWORD 100h .code mov eax, x cdq idiv y call DumpRegs |
Output | Output | Output |