IDIV Instruction (Cont.)
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 |
|
“I’m not arguing, I’m just explaining why I’m right.” ― Unknown |