Hello im working on debugging a program that has a weird error and i think it might be compiler error..



:004280CA 8B4114 mov eax, dword ptr [ecx+14]
:004280CD 0FAF450C imul eax, dword ptr [ebp+0C]
:004280D1 99 cdq
:004280D2 F77D10 idiv [ebp+10]


what this code is doing is calculating what part of a PCX file to display on the screen

From what I understand is that when you do IMUL with two operand it no longer does signed multiplication...

So why would the progra then convert a non signed value into a QWORD then use signed idiv

also at the IDIV this is were the error happens...

my question is if i remove the CDQ and change the idiv to div should it no longer error.. becuase when i removed it fully it stopper erroring but didnt now show the correct image section on the screen..
Posted on 2003-09-25 03:53:06 by devilsclaw

From what I understand is that when you do IMUL with two operand it no longer does signed multiplication...


No, this is not true. When you use imul with 2 or 3 operands it can produce only 32 bit result (signed) and can be overflowed. Maybe this is the problem with your application. IDIV dosn't behave this way. When you change idiv with div the result will be different.
Posted on 2003-09-25 03:58:45 by JohnFound
i decided to test my idea out and the idiv and the div visually show the right thing...

so i think they were using IMUL on none signed and then converted a non signed to a QWORD then idiv

this would have cleared the edx which i had to do to make it work but it seems thats all they used it for..
Posted on 2003-09-25 04:13:50 by devilsclaw