[fpc-pascal] TSR Programs

Pianoman pianoman at centrum.sk
Wed Mar 9 18:06:39 CET 2005


Hello, how can I create resident programs for WIN32 in FPC?
Any help or docs would be appreciated.
Pianoman
----- Original Message -----
From: <fpc-pascal-request at lists.freepascal.org>
To: <fpc-pascal at lists.freepascal.org>
Sent: Wednesday, March 09, 2005 12:00 PM
Subject: fpc-pascal Digest, Vol 7, Issue 11


> Send fpc-pascal mailing list submissions to
> fpc-pascal at 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
> fpc-pascal-request at lists.freepascal.org
>
> You can reach the person managing the list at
> fpc-pascal-owner at lists.freepascal.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of fpc-pascal digest..."
>
>
> Today's Topics:
>
>    1.  fpc198 and old bugs (Bartek)
>    2. Re:  Help needed with interfacing to C-object-files.
>       (Koenraad Lelong)
>    3. Re:  Help needed with interfacing to C-object-files.
>       (Michael.VanCanneyt at Wisa.be)
>    4. Re:  fpc198 and old bugs (Peter Vreman)
>    5.  CLX for FPC + Bug i386 cdecl (Den Jean)
>    6. Re:  CLX for FPC + Bug i386 cdecl (Simon Kissel)
>    7. Re:  Help needed with interfacing to C-object-files.
>       (Marc Santhoff)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 8 Mar 2005 21:15:42 +0100
> From: "Bartek" <bbartek at gmx.net>
> Subject: [fpc-pascal] fpc198 and old bugs
> To: <fpc-pascal at lists.freepascal.org>
> Message-ID: <004601c5241b$a3219090$0201a8c0 at bartek>
> Content-Type: text/plain; charset="iso-8859-1"
>
> hi,
>
> i've just downloaded fpc198 and tried the following out. (there was a bug
> with the stack in fpc)
>
file://---------------------------------------------------------------------
-----
> program bug2;
> uses sysutils;
> type
>         tmmxint      =array[0..3] of smallint;
> const
>         x0 :tmmxint=(0,0,0,0);
> var
>         a,b,r :tmmxint;
>
> function paddw(a,b :tmmxint):tmmxint;assembler;inline;
> asm
> movq mm0, a
> paddw mm0, b
> movq @result, mm0
> end;
>
> begin
> a:=x0;b:=x0;r:=x0;
> a[0]:=1;b[0]:=1;
> r:=paddw(a,b);
> writeln(r[0]);
> end.
>
file://---------------------------------------------------------------------
-----
>
> compilations aborts with:
>
file://---------------------------------------------------------------------
-----
>  Assembling bug2
>  bug2.pas(8,13) Error: Error while assembling exitcode 1
>  bug2.pas(8,13) Fatal: There were 2 errors compiling module, stopping
>
>
file://---------------------------------------------------------------------
-----
>
> other programs also using assembler compiled well.
>
>
> i've also tried this one out:
>
file://---------------------------------------------------------------------
-----
> program bug;
> uses heaptrc,sysutils;
> begin
> markheap;
> end.
>
>
file://---------------------------------------------------------------------
-----
>
> output:
>
file://---------------------------------------------------------------------
-----
> ? Free Pascal IDE Version 1.0.2 [2005/02/21]
> ? Compiler Version 1.9.8
> ? GBD Version GDB 6.2.1
> ? Cygwin "E:\fpc198\bin\i386-win32\cygwin1.dll" version 1005.12.0.0
> Running "e:\fpc198\work\bug.exe /P"
> Marked memory at $00083514 invalid
> Wrong signature $AAAAAAAA instead of 8736A0C5
>   $004072DB
>   $00404E74
>   $0040C6D6
>   $004096B4
>   $0040C473
>   $0040C1C9
>   $004082C6
>   $00408088
>   $004022C7
>
file://---------------------------------------------------------------------
-----
>
> thanks for help in advance
> bartek
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 08 Mar 2005 21:51:40 +0100
> From: Koenraad Lelong <fpascal at brouwerij.homelinux.net>
> Subject: Re: [fpc-pascal] Help needed with interfacing to
> C-object-files.
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Message-ID: <422E105C.6040708 at brouwerij.homelinux.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Marc Santhoff wrote:
> > Am Mo, den 07.03.2005 schrieb Koenraad Lelong um 22:36:
> >
> >>Hi,
> >>I'm trying to make an interface to a kind of library, but I'm stuck. Any
> >>pointers are welcome.
> >>There is a C-header file, but this is common for a number of C-modules.
> >>If I translate (h2pas) this file, and use it, the linker tries to find
> >>an o-file, which does not exist. Any suggestions how to handle this ?
> >
> >
> > You've got to compile the C files to .o (gcc -c thesource.c) and then
> > link them into your pascal unit ({$L thesource.o}). This way it should
> > work, I'm using some C stuff like that.
> >
> > HTH,
> > Marc
> Let me explain more : the header file is used in at least five
> source-files, so compiling gives (at least) five .o files, but none with
> the name of the header-file.
> I was thinking that splitting that header-file in smaller files, each
> for its own source could do the trick, but I'll have to check this
> carefully. I had hoped for another suggestion.
> Anyway, thanks for the response.
> Koenraad.
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 8 Mar 2005 22:08:41 +0100 (CET)
> From: Michael.VanCanneyt at Wisa.be
> Subject: Re: [fpc-pascal] Help needed with interfacing to
> C-object-files.
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Message-ID: <Pine.LNX.4.61.0503082207180.6711 at home.wisa.be>
> Content-Type: TEXT/PLAIN; charset=US-ASCII
>
>
>
> On Tue, 8 Mar 2005, Koenraad Lelong wrote:
>
> > Marc Santhoff wrote:
> > > Am Mo, den 07.03.2005 schrieb Koenraad Lelong um 22:36:
> > >
> > > > Hi,
> > > > I'm trying to make an interface to a kind of library, but I'm stuck.
> > > > Any pointers are welcome.
> > > > There is a C-header file, but this is common for a number of
> > > > C-modules. If I translate (h2pas) this file, and use it, the linker
> > > > tries to find an o-file, which does not exist. Any suggestions how
to
> > > > handle this ?
>
> You can simply change the resulting pascal file so it has the correct
{$o }
> statements ? h2pas does not know (and can not know) what the names of the
> object files are. C does not work like that.
>
> Michael.
>
>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 08 Mar 2005 22:12:37 +0100
> From: Peter Vreman <peter at freepascal.org>
> Subject: Re: [fpc-pascal] fpc198 and old bugs
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Message-ID: <6.2.1.2.2.20050308221023.031a47d8 at wheresmymailserver.com>
> Content-Type: text/plain; charset="us-ascii"; format=flowed
>
> At 21:15 8-3-2005, you wrote:
> >hi,
> >
> >i've just downloaded fpc198 and tried the following out. (there was a bug
> >with the stack in fpc)
>
>//-------------------------------------------------------------------------
-
> >program bug2;
> >uses sysutils;
> >type
> >         tmmxint      =array[0..3] of smallint;
> >const
> >         x0 :tmmxint=(0,0,0,0);
> >var
> >         a,b,r :tmmxint;
> >
> >function paddw(a,b :tmmxint):tmmxint;assembler;inline;
> >asm
> >movq mm0, a
> >paddw mm0, b
> >movq @result, mm0
> >end;
>
> inline uses registers to pass arguments. movq doesn't support registers.
> You need to load a first in a local temp or use a different calling
> convention like stdcall.
>
> Note also that inline is disabled for assembler procedures (same as with
> delphi 2005).
>
>
>
>//-------------------------------------------------------------------------
-
> >program bug;
> >uses heaptrc,sysutils;
> >begin
> >markheap;
> >end.
>
> Use the bug repository to report bugs otherwise they will be forgotten.
>
>
> Peter
>
>
>
>
> ------------------------------
>
> Message: 5
> Date: Wed, 9 Mar 2005 00:30:47 -0500
> From: Den Jean <Den.Jean at telenet.be>
> Subject: [fpc-pascal] CLX for FPC + Bug i386 cdecl
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Message-ID: <200503090030.47533.Den.Jean at telenet.be>
> Content-Type: text/plain;  charset="us-ascii"
>
> Hi,
>
> We are porting CLX to FPC. You can see a first snapshot here:
> http://sourceforge.net/project/screenshots.php?group_id=116605
> The use of the BitBtn shows that we dealt with {$R QButtons.res}
>
> The code will be available at:
> http://sourceforge.net/projects/qtforfpc/
>
> There is still alot of work to do, diffs are welcome.
> The FPC Wiki shows someone else is busy at it too,
> any cooperation would be great.
> By the way thx for the many updates to the rtl,
> it is much easier than back in July when I first tried this.
> Also thx for renaming rtlconst(s) just after I had already replaced it
> everywhere :-)
>
> BTW, our aim is to be able to kinda just recompile Kylix programs
> if ever we encounter problems with dcc on newer distributions.
> Some programs that have some qt dependencies, just cannot
> be ported that easy to LCL (yet). New programs should ofcourse
> use the lazarus/LCL and profit of its nice form editor.
> We will try to convert the xfm files with lazres after
> some further study of the classes unit
>
> i386 FPC CDecl Bug encountered:
> =================
> When using libqtintf we call c-code and get called by c-code.
> For eg c-code calls this function in BindHelp.pas
>
> function GetPointsLength(const PA: TPointArray): Integer; cdecl; export;
>
> But with FPC this call fails. The way 'const TPointArray' is passed on the
> stack seems not ABI correct. I am an ABI analphabet, but I guess the
address
> of the points should be on EBP+8 so the following test program tests this.
> With Kylix (dcc) it works and with FPC it fails.
>
> =====================================
> ==         Output of both compilers                                  ==
> =====================================
> [jan at home]$ dcc TestPointArray
> writeln('end of program');
>
> [jan at home]$ dcc -q TestPointArray ; ./TestPointArray
> Borland Delphi for Linux Version 14.5
> Copyright (c) 1983,2002 Borland Software Corporation
> 59 lines, 0.03 seconds, 137636 bytes code, 7204 bytes data.
> GetPointsLength 1:
>    Length:3
> GetPointsLength 2:
>    Length:3
>
> [jan at home]$ ppc386 -Sd -v0 TestPointArray.pas ; ./TestPointArray
> Free Pascal Compiler version 1.9.9 [2005/03/08] for i386
> Copyright (c) 1993-2005 by Florian Klaempfl
> GetPointsLength 1:
>    Length:3
> GetPointsLength 2:
>    Oooops:i<>p
>    Length:3
>
> =====================================
> ==          Test Program:
==
> =====================================
> program TestPointArray;
> {$H+}
>
> uses
>   Classes, SysUtils, Types;
>
> type
>   PPointArray = ^TPointArray;
>   TPointArray = array of TPoint;
>
> var
>   Points     : TPointArray;
>   p          : PPointArray;
>   i          : integer;
>
>
> function GetPointsLength1 (PA: pointer): Integer; cdecl;
> begin
>   asm
>     mov EAX,[EBP+$08]
>     mov i,eax
>   end;
> writeln('GetPointsLength 1:');
> if i <> integer (p) then writeln ('   Oooops:i<>p');
> if integer(PA) <> integer (p) then writeln ('   Oooops:PA<>p');
> Result:=Length(TPointArray(PA));
> writeln('   Length:',Result);
> end;
>
> {$IFDEF FPC}
> {$asmmode intel}
> {$ENDIF}
>
> function GetPointsLength2 (const PA: TPointArray): Integer; cdecl;
> begin
>   asm
>     mov EAX,[EBP+$08]
>     mov i,eax
>   end;
> writeln('GetPointsLength 2:');
> if i <> integer (p) then writeln ('   Oooops:i<>p');
> if integer(PA) <> integer (p) then writeln ('   Oooops:PA<>p');
> Result:=Length(PA);
> writeln('   Length:',Result);
> end;
>
>
> begin
> SetLength (Points, 3);
> Points [0] := Point (1,2);
> Points [1] := Point (3,4);
> Points [2] := Point (5,6);
> p:=@Points[0];
> getPointsLength1(Points);
> getPointsLength2(Points);
> end.
>
>
> ===========================
>
> kind regards,
>
> Den Jean
>
>
>
> ------------------------------
>
> Message: 6
> Date: Wed, 9 Mar 2005 00:39:24 +0100
> From: Simon Kissel <scamp at untergrund.net>
> Subject: Re: [fpc-pascal] CLX for FPC + Bug i386 cdecl
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Message-ID: <1853046585.20050309003924 at untergrund.net>
> Content-Type: text/plain; charset=us-ascii
>
> Hello Den,
>
> DJ> The FPC Wiki shows someone else is busy at it too,
> DJ> any cooperation would be great.
>
> Replied to off-list.
>
> Simon
>
>
>
>
> ------------------------------
>
> Message: 7
> Date: Wed, 09 Mar 2005 00:34:21 +0100
> From: Marc Santhoff <M.Santhoff at t-online.de>
> Subject: Re: [fpc-pascal] Help needed with interfacing to
> C-object-files.
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Message-ID: <1110324861.450.16.camel at zaphod.das.netz>
> Content-Type: text/plain
>
> Am Di, den 08.03.2005 schrieb Koenraad Lelong um 21:51:
> > Marc Santhoff wrote:
> > > Am Mo, den 07.03.2005 schrieb Koenraad Lelong um 22:36:
> > >
> > >>Hi,
> > >>I'm trying to make an interface to a kind of library, but I'm stuck.
Any
> > >>pointers are welcome.
> > >>There is a C-header file, but this is common for a number of
C-modules.
> > >>If I translate (h2pas) this file, and use it, the linker tries to find
> > >>an o-file, which does not exist. Any suggestions how to handle this ?
> > >
> > >
> > > You've got to compile the C files to .o (gcc -c thesource.c) and then
> > > link them into your pascal unit ({$L thesource.o}). This way it should
> > > work, I'm using some C stuff like that.
> > >
> > > HTH,
> > > Marc
> > Let me explain more : the header file is used in at least five
> > source-files, so compiling gives (at least) five .o files, but none with
> > the name of the header-file.
> > I was thinking that splitting that header-file in smaller files, each
> > for its own source could do the trick, but I'll have to check this
> > carefully. I had hoped for another suggestion.
> > Anyway, thanks for the response.
>
> Hm, I don't know, how the translated header looks in pascal, but if it's
> a complete unit itself you could try to {$L xxx} all resulting .o files
> in that unit. So any declared function and type should be found ... the
> other thing would be, if the sources from the 1-wire stuff form a
> dynamic library, then you simply have to tell the linker to pull this
> lib (.so) in
>
> fpc -k-l<thelibraryname without the.so-ending> ...
>
> should work and does for me, too. Or it needs an additional
> "-k-L/the/path/to/1-wire-lib". The only thing in your sources is to put
> the translated header in the uses clause.
>
> HTH,
> Marc
>
>
>
>
>
> ------------------------------
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
> End of fpc-pascal Digest, Vol 7, Issue 11
> *****************************************
>
>
>
> __________ Informacia od NOD32 1.1021 (20050307) __________
>
> Tato sprava bola preverena antivirusovym systemom NOD32.
> http://www.eset.sk
>
>





More information about the fpc-pascal mailing list