Hi, the UI32x32To64 function is great but is amazingly short. How can I
Specify which varriables in function will be accessed. In this function for
example it accesses a and b but source says mull (I don't know why not mul I
didnt find mull instruction in any assembly book) and %eax why mull %eax
multiplies a,b is it on the stack or why? If i would like to multiply a,b,c
what would look source code then? Thanx for response to those quite stupid
assembly question(I am only beginner in asm :)
Pianoman
- Original Message -
From: <[EMAIL PROTECTED]>
To:
Sent: Tuesday, August 02, 2005 12:00 PM
Subject: fpc-pascal Digest, Vol 12, Issue 2
Send fpc-pascal mailing list submissions to
fpc-pascal@lists.freepascal.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of fpc-pascal digest..."
Today's Topics:
1. Re: lazarus crash at start (Jesus Reyes)
2. Re: fast integer multiplication (Gerhard Scholz)
3. Can a program find out how it was started?
([EMAIL PROTECTED])
4. Re: Can a program find out how it was started? (Moz)
--
Message: 1
Date: Mon, 1 Aug 2005 11:21:10 -0500 (CDT)
From: Jesus Reyes <[EMAIL PROTECTED]>
Subject: Re: [fpc-pascal] lazarus crash at start
To: FPC-Pascal users discussions
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=iso-8859-1
--- 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/
--
Message: 2
Date: Mon, 1 Aug 2005 23:58:04 +0200
From: "Gerhard Scholz" <[EMAIL PROTECTED]>
Subject: Re: [fpc-pascal] fast integer multiplication
To: "FPC-Pascal users discussions"
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"
...
>>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