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

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


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:

A: LongInt;
C: QWord;

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

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
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

Thanks for any help,


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

More information about the fpc-devel mailing list