Re: [fpc-pascal] lazarus crash at start

2005-08-01 Thread Vincent Snijders

Peter Vreman wrote:

At 01:12 1-8-2005, you wrote:

Trying to find why lazarus crashes at start in win98 I found a 
courious problem, global variable IsConsole is true when it should be 
false as lazarus is built as a gui application.




You need to use {$apptype gui} or use the -WG parameter. For the 
compiler it is not known if the application needs a console or not.





If you use -WG, IsConsole should be false. Correct?

Vincent.

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


Re: [fpc-pascal] lazarus crash at start

2005-08-01 Thread Jesus Reyes

 --- Peter Vreman [EMAIL PROTECTED] escribió:

 At 01:12 1-8-2005, you wrote:
 Trying to find why lazarus crashes at start in win98 I found a
 courious 
 problem, global variable IsConsole is true when it should be false
 as 
 lazarus is built as a gui application.
 
 Digging I found that IsConsole is set in two functions in
 wprt0.as: 
 _mainCRTStartup sets to true and _WinMainCRTStartup sets to False,
 this 
 cause a wrong setup of standard Output that DebugLn (lclprocs.pas)
 use to 
 emit debug messages.
 
 It seems that this functions are 'used' in the linker script, for
 example 
 ld .--verbose shows that by default a ENTRY(_mainCRTStartup) it's
 used. I 
 looked into the generated lazarus link.res file and didn't find a
 ENTRY 
 section so I guess it uses the default and that's why even when
 lazarus is 
 a gui app, it's linked as a console app.
 
 To demostrate this I modified the link.res script to inculde 
 ENTRY(_WinMainCRTStartup) section and then linked, the resulting 
 lazarus.exe file now behaves as a gui app and won't crash at
 start.
 
 It seems that WriteResponseFile lacks the code to add the ENTRY
 section to 
 the link.res script but I don't know if it's supposed to be there
 or 
 should it be in another stage, any comments?
 
 You need to use {$apptype gui} or use the -WG parameter. For the
 compiler 
 it is not known if the application needs a console or not.
 
 
 Peter
 

Lazarus is already compiled with -WG

Jesus Reyes A.


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 

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


Re: [fpc-pascal] fast integer multiplication

2005-08-01 Thread Gerhard Scholz
...
The code generated for the above sample is:
# [16] c:=a*b;
movlU_P$PROJECT1_A,%edx
movlU_P$PROJECT1_B,%eax
mull%edx
movl$0,%edx
movl%eax,U_P$PROJECT1_C
movl%edx,U_P$PROJECT1_C+4

What I want is the above code, but without the movl $0,%edx
instruction. Is there a way to do this (wihtout using fpc_mul_qword).


 Only assembler for now. Any suggestions how the compiler could be told
 to generate such code?
...
function UI32x32To64(A,B: Longword): QWord;
assembler; register; nostackframe;
asm
mull %edx
end;

It is fast but certainly much less than if it were inlined.

My suggestion would be:

  FUNCTION lmul ( CONST a,
b : LongInt ) : int64 ; inline ;

BEGIN
{$ifdef cpu86}
  ASM
movla,%eax
imull   b
movl%eax,lmul
movl%edx,lmul+4
   END ;
{$else}
{$ifdef cpu68k}
  lmul := int64 ( a ) * b ;
{$else}
{$ifdef cpusparc}
  lmul := int64 ( a ) * b ;
{$else}
{$ifdef cpualpha}
  lmul := int64 ( a ) * b ;
{$else}
{$ifdef cpupowerpc}
  lmul := int64 ( a ) * b ;
{$else}
  lmul := int64 ( a ) * b ;
{$endif}
{$endif}
{$endif}
{$endif}
{$endif}
 END ;

and similar for unsigned mul.

(shortened here; full code in ulmul.pas; liitle test in tmuls.pas, timing
routines in
wtimer/tdrsc1)

Is portable so code doesn't need to be rewritten when compiled for other
processors (but not optimal then)

Tested only on i386.

Seems to be faster than standard multiplication (interesting: significantly
faster for signed mul than for unsigned mul), can be assembly-coded in the
branches for the other cpus
(if there are opcodes for such a multiplication - I don't know), could go to
unit math.pp.

It seems that routines which contain assembler are not inlined; on the day
somebody finds a trick to inline such code they should be really fast.

Gerhard


ULMUL.pas
Description: Binary data


tmuls.pas
Description: Binary data


WTIMER.pas
Description: Binary data


TDRSC1.pas
Description: Binary data
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal