PDA

View Full Version : ASM help


stealthFIGHTER
03-31-2001, 06:32 PM
Hi, I have problems with this piece of code:
-----------------------------------------
:
:
MOV ECX, 3 ; EAX=E
CDQ ; ECX=3
IDIV ECX ; EDX=0
IMUL ... ; EAX=4, EDX=2
:
:
-----------------------------------------
I don't know what does the 2nd function (CDQ) do.

Regards

sF

Bratsher
03-31-2001, 11:41 PM
Quote:
stealthFIGHTER (03-31-2001 15:32):
Hi, I have problems with this piece of code:
-----------------------------------------
:
:
MOV ECX, 3 ; EAX=E
CDQ ; ECX=3
IDIV ECX ; EDX=0
IMUL ... ; EAX=4, EDX=2
:
:
-----------------------------------------
I don't know what does the 2nd function (CDQ) do.

Regards

sF


CDQ Convert doubleword (in EAX) to quadword (contained in EDX:EAX) always acts on the EDX:EAX registers, so it does not take an operand. The Quad mantains the sign of the integer contained in EAX.

Fpc
04-01-2001, 12:29 AM
About CDQ:
If EAX>0x7FFFFFFF, then EDX=0XFFFFFFFF;
If EAX<=0X7FFFFFFF,then EDX=0X0.
That's all.