[fpc-pascal] OT: PetrOS [was Re: fpc-pascal]

2005-05-05 Thread listmember
Anandu R Suri wrote:
I am writing an operating system using your Free Pascal Compilier 1.0.10.

2. Since my Operating System will be Object Oriented, 

This reminds me of PetrOS (www.petros-project.com) which
I was very much interested and then dismayed since it
never was released.
Then there was another project on SF by some french speaking
guys, which seems to be dead (to me, as I dont speak french).
I do hope you fare better than PetrOS --I, for one, would
like to see an OO/Pascal OS.
Good luck.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] OT: PetrOS [was Re: fpc-pascal]

2005-05-05 Thread Michael Van Canneyt


On Thu, 5 May 2005, listmember wrote:

> Anandu R Suri wrote:
> > I am writing an operating system using your Free Pascal Compilier 1.0.10.
>
> 
>
> > 2. Since my Operating System will be Object Oriented,
>
> 
>
> This reminds me of PetrOS (www.petros-project.com) which
> I was very much interested and then dismayed since it
> never was released.
>
> Then there was another project on SF by some french speaking
> guys, which seems to be dead (to me, as I dont speak french).

DelphineOS, I think it is called.

> I do hope you fare better than PetrOS --I, for one, would
> like to see an OO/Pascal OS.

Writing an OS is not an easy task.

Michael.


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


[fpc-pascal] Dynamic arrays in FP

2005-05-05 Thread Jilani Khaldi
Hi All,
I have written a little library in C (compiled in as a DLL) to use it in 
Free Pascal and  Delphi applications. While the code (below) works with 
Delphi (7), I get an Access Violation using FPC (1.98). Perhaps I am 
missing something.
Any hint? Thanks!

program fpc_dll;
{$H+}{$MODE OBJFPC}
uses
 sysutils;
type
myarray = array of double;
// if I declare "myarray = array[0..9] of double;" the code runs as 
expected.

function get_array(a, b: myarray; size: integer; value: double): 
integer; cdecl; external 'mylib.dll';
// extern "C"  __cdecl __declspec(dllexport) int get_array(double a[], 
double b[], int size, double val);

var
 x, y, z: double;
 t: integer;
 i, kk, qq: integer;
 mat1, mat2: pmyarray;
 st: string;
begin
 kk := 10;
 SetLength(mat1,kk);
 SetLength(mat2,kk);
 for i := 0 to kk-1 do
 begin
   mat1[i] := i+1;
   st := FloatToStr(mat1[i]);
   writeln(st);
 end;
 qq := get_array(mat1,mat2,kk,3.14);
 st := IntToStr(qq);
 writeln(st);
 for i := 0 to kk-1 do
 begin
   st := FloatToStr(mat1[i]);
   writeln(st);
 end;
 st := '--';
 writeln(st);
 for i := 0 to kk-1 do
 begin
   st := FloatToStr(mat2[i]);
   writeln(st);
 end;
 SetLength(mat1,0);
 SetLength(mat2,0);
end.
jk
--
// Jilani KHALDI
*** K-Book
Interactive Scientific & Technical Pubblications
http://jkhaldi.oltrelinux.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Dynamic arrays in FP

2005-05-05 Thread Peter Vreman
At 11:44 5-5-2005, you wrote:
Hi All,
I have written a little library in C (compiled in as a DLL) to use it in 
Free Pascal and  Delphi applications. While the code (below) works with 
Delphi (7), I get an Access Violation using FPC (1.98). Perhaps I am 
missing something.
Any hint? Thanks!

program fpc_dll;
{$H+}{$MODE OBJFPC}
uses
 sysutils;
type
myarray = array of double;
// if I declare "myarray = array[0..9] of double;" the code runs as expected.
function get_array(a, b: myarray; size: integer; value: double): integer; 
cdecl; external 'mylib.dll';
// extern "C"  __cdecl __declspec(dllexport) int get_array(double a[], 
double b[], int size, double val);
Dynamic arrays are an internal type of pascal. C doesn't know dynamic 
arrays. That it works with delphi is pure luck.

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


Re: [fpc-pascal] Dynamic arrays in FP

2005-05-05 Thread Jilani Khaldi

Dynamic arrays are an internal type of pascal. C doesn't know dynamic 
arrays. That it works with delphi is pure luck.
Sorry, but pascal dynamic arrays are just pointers.
jk
--
// Jilani KHALDI
*** K-Book
Interactive Pubblications
http://jkhaldi.oltrelinux.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Dynamic arrays in FP

2005-05-05 Thread Michael Van Canneyt


On Thu, 5 May 2005, Jilani Khaldi wrote:

>
> > Dynamic arrays are an internal type of pascal. C doesn't know dynamic
> > arrays. That it works with delphi is pure luck.
>
> Sorry, but pascal dynamic arrays are just pointers.

Totally wrong. They are a reference counted type.

See e.g. page 5-19 of the Delphi 7 Language guide.

(Chapter 5 'Data types', section structured types - arrays - dynamic arrays)

Michael.


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


Re: [fpc-pascal] Dynamic arrays in FP

2005-05-05 Thread Jonas Maebe
On 05 May 2005, at 13:06, Michael Van Canneyt wrote:
Dynamic arrays are an internal type of pascal. C doesn't know dynamic
arrays. That it works with delphi is pure luck.
Sorry, but pascal dynamic arrays are just pointers.
Totally wrong. They are a reference counted type.
Yes, but aren't they "just" C-style arrays (i.e. pointers) in the same 
way that ansistrings are "just" pchars?

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


Re: [fpc-pascal] Dynamic arrays in FP

2005-05-05 Thread Michalis Kamburelis
Jilani Khaldi wrote:
Hi All,
I have written a little library in C (compiled in as a DLL) to use it in 
Free Pascal and  Delphi applications. While the code (below) works with 
Delphi (7), I get an Access Violation using FPC (1.98). Perhaps I am 
missing something.
Any hint? Thanks!

program fpc_dll;
{$H+}{$MODE OBJFPC}
uses
 sysutils;
type
myarray = array of double;
// if I declare "myarray = array[0..9] of double;" the code runs as 
expected.

function get_array(a, b: myarray; size: integer; value: double): 
integer; cdecl; external 'mylib.dll';
Change this to
type
  PDouble = ^Double;
function get_array(a, b: PDouble; size: integer; value: double): 
integer; cdecl; external 'mylib.dll';

In C "double a[]" is the same as "double *a" which is the same as "A: 
PDouble" in Pascal. "array of Double" is not the same thing as 
"PDouble", as fpc developers already explained.

// extern "C"  __cdecl __declspec(dllexport) int get_array(double a[], 
double b[], int size, double val);
...
 qq := get_array(mat1,mat2,kk,3.14);
Change this to
qq := get_array(PDouble(mat1),PDouble(mat2),kk,3.14);
Michalis
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Dynamic arrays in FP

2005-05-05 Thread Peter Vreman
At 13:05 5-5-2005, you wrote:
On 05 May 2005, at 13:06, Michael Van Canneyt wrote:
Dynamic arrays are an internal type of pascal. C doesn't know dynamic
arrays. That it works with delphi is pure luck.
Sorry, but pascal dynamic arrays are just pointers.
Totally wrong. They are a reference counted type.
Yes, but aren't they "just" C-style arrays (i.e. pointers) in the same way 
that ansistrings are "just" pchars?
It is also calling convention related how C expects arrays to be pushed. 
From the example:

// extern "C"  __cdecl __declspec(dllexport) int get_array(double a[], 
double b[], int size, double val);

Here the array is expected on the stack on some i386 targets. Using 'double 
*a' is less ambigious, because it then always needs to be a pointer.

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


Re: [fpc-pascal]

2005-05-05 Thread Marco van de Voort
> 1. The very basic problem is with the video driver. Whenever I try to write
> to the Video memory either there is no reponse, or I receive a run time
> error 216. I tried all possibilities of using an absolute array, pointers,
> and even FillWord, nothing works out.
> 
> 2. Since my Operating System will be Object Oriented, the compilation
> consists of calling a FPC_HELP_CONTRUCTOR which in turn calls the built in
> AsmGetMem function. But during the system initialization process there will
> be no memory manager. Is there a possiblity of constructing an object at a
> predetermined location like in C++?

1) use TP objects instead of classes
2) (better) provide an own startup temporary memmanager.

 
> Var x, y: Byte
> 
> Procedure ClrScr; Assembler; [Public, Alias: 'CLRSCR'];
> ASM
> mov edi, $B8000
> mov  eax, $07200720
> mov  ecx, 2000
> rep
> stosw
> mov  x, 0
> mov  y, 24
> End;
 
> This piece of code always gives a RTE 216.

You write a lot of bytes to %ds:[$B8000]. Since you are writing an OS, the
selectors could be setup in a multitude of ways. Are you sure you mapped the
videocard memory to that location? I suggest to check your early OS bootup
code how you enter protected mode and set up the selectors.

E.g. under dos the videocard memory is in $B8000 in the real mode segment
(which is %fs:$B8000 under Go32v2 typically), but if you didn't setup
the selector in your bootloader, it is pretty much random.



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


[fpc-pascal] About the bug report #3931

2005-05-05 Thread Marcel Martin
About the bug report #3931
>The following does not compile:
>jmp dword ptr [@@FwdJumpTable+ecx*4] <---
>nop {Align Jump Table}
>@@FwdJumpTable:
[...]
Use "jmp dword ptr @@FwdJumpTable[ecx*4]"
Don't use "nop" to align, use the "align" instruction (Yes, FPC
is better than Delphi :-)
mm
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Dynamic arrays in FP

2005-05-05 Thread Jilani Khaldi

 qq := get_array(mat1,mat2,kk,3.14);

Change this to
qq := get_array(PDouble(mat1),PDouble(mat2),kk,3.14);
It is ok. Thank you.
jk
--
// Jilani KHALDI
*** K-Book
Interactive Pubblications
http://jkhaldi.oltrelinux.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]

2005-05-05 Thread Nico Aragón
El Jueves, 5 de Mayo de 2005 05:49, Anandu R Suri escribió:

> 2. Since my Operating System will be Object Oriented, the compilation
> consists of calling a FPC_HELP_CONTRUCTOR which in turn calls the built in
> AsmGetMem function. But during the system initialization process there will
> be no memory manager. Is there a possiblity of constructing an object at a
> predetermined location like in C++?

As far as I know, FPC object model tries to be compatible with Delphi's. I say 
this because I do know that what I'm going to tell you works with Delphi. But 
I'm not sure that it works with FPC. Please read the docs or the source to 
check it.

In Delphi TObject has some class methods that provide a hook to customize the 
lifecycle of memory: NewInstance and FreeInstance. The default behaviour is 
to call GetMem asking for InstaceSize bytes.

You can override NewInstace to return memory from a predetermined location. 
You should also override FreeInstance accordingly to do nothing.

Another possibility is to call InitInstance (or the constructor using 
assembler, for that matter) on some arbitrary buffer. Check the source for 
constructor calls.

-- 
saludos,

Nico Aragón

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