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

2012-08-20 Thread Jonas Maebe


ABorka wrote on Mon, 20 Aug 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.


In Pascal, the type of the result of an expression only depends on its  
arguments, never on what you do with it afterwards. Additionally,  
integer expressions are evaluated using the "native bit width" if all  
factors are <= 32 bit, which is 32 bit on 32 bit systems (exception:  
operations involving both longint and cardinal).


If you want a 64 bit result, typecast one of the factors of the  
expressions to 64 bit.



Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


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

2012-08-19 Thread ABorka

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?

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel