trying to understand the assembly instruction: cltd on x86
It looks pretty straightforward to me: cltd converts the signed long in EAX to a signed double long in EDX:EAX by extending the most-significant bit (sign bit) of EAX into all bits of EDX."
cltd
converts signed long to signed double long
If you want to see a diagram of what happens, jump to page 160 of http://download.intel.com/products/processor/manual/325462.pdf (more details on page 681)
cltd
is an alias for cdq
(reference), which sign-extends eax
into edx:eax
.
What this means in practice is that edx
is filled with the most significant bit of eax
(the sign bit). For example, if eax
is 0x7F000000
edx
would become 0x00000000
after cdq
. And if eax
is 0x80000000
edx
would become 0xFFFFFFFF
.