[fpc-devel] 64 bit integer result in Win32 problem

ABorka fpc-devel at aborka.com
Mon Aug 20 03:59:16 CEST 2012


Hi,

Win32 .exe compiled on Win64 computer, latest SVN build.

I am trying to multiply 2 Integers (Declared as LongInt but sometimes 
need to use it as LongWord) and put the result into a QWord (64bit 
unsigned) result variable on Win32.
However, it seems that the result is always cut to 32bit.
Checked the assembler window inside Lazarus and there is a "mull" 
instruction and immediately after that there is a zeroing out of the 
"EDX" register cutting the "EDX:EAX" result short.
Simplified example:

var
A: LongInt;
C: QWord;

begin
   A := $12345678;
   C := LongWord(A) * LongWord(255);
.
.
.
end;

Am I doing something wrong in the code to accomplish this?

in Assembly it could be something like:
asm//Intel syntax
   mov edx, $12345678
   mov eax, 255
   mul edx
...store
end;
which would store the 64 bit result from EDX:EAX
However, the code actually generated is something like:
asm//Lazarus syntax
   mull ...
   mov $0x0, %edx   <- why is this here?
then stores both eax and edx into the variable
end;

Thanks for any help,

AB

PS: Any way to see the assembler window in Intel assembly syntax?




More information about the fpc-devel mailing list