Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-05

[fpc-pascal]

7 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Anandu R Suri

I am writing an operating system using your Free Pascal Compilier 1.0.10. Most of my code is based on the IA32 opcodes in $ASMMODE INTEL. I have two problems, both are of importance.

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++?

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.

Reply by email

John Coppens
to Anandu R Suri
Show quoted text 8 lines
I am writing an operating system using your Free Pascal Compilier 1.0.10. Most of my code is based on the IA32 opcodes in $ASMMODE INTEL. I have two problems, both are of importance. 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.

Are you sure the video card is in text mode? The code you're using is very specific to 16-bit IBM-like PCs explicitly in mode 3 (color, 80x25). If you are in 32- bit mode, the memory will probably be elsewhere and text mode can even be emulated by graphics. If you want the program to be more or less portable you shouldn't be accessing the video directly. Use INT 10 functions.

John

Show quoted text 29 lines
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++? 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. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

listmember
to Anandu R Suri: I am writing an operating system using your Free Pascal Compilier 1.0.10. Most of my code…
Anandu R Suri wrote
I am writing an operating system using your Free Pascal Compilier 1.0.10.

<snip>

2. Since my Operating System will be Object Oriented,

<snip>

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.

Reply by email

Michael Van Canneyt
to listmember
listmember wrote 15 lines
Anandu R Suri wrote: > I am writing an operating system using your Free Pascal Compilier 1.0.10. <snip> > 2. Since my Operating System will be Object Oriented, <snip> 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.

Reply by email

Marco van de Voort
to Anandu R Suri: I am writing an operating system using your Free Pascal Compilier 1.0.10. Most of my code…
Show quoted text 10 lines
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.

Show quoted text 14 lines
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.

Reply by email

Nico Aragón
to Anandu R Suri: I am writing an operating system using your Free Pascal Compilier 1.0.10. Most of my code…
Anandu R Suri wrote 5 lines
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

Reply by email

Nikolay Nikolov
to Anandu R Suri: I am writing an operating system using your Free Pascal Compilier 1.0.10. Most of my code…
Anandu R Suri wrote 10 lines
I am writing an operating system using your Free Pascal Compilier 1.0.10. Most of my code is based on the IA32 opcodes in $ASMMODE INTEL. I have two problems, both are of importance. 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.

Have a look at this:
http://debian.fmi.uni-sofia.bg/~nickysn/paskernel/ It's a 'hello world' OS. In fact writing to the video memory is the only thing it can do :) It used to work with some older version of fpc (like 1.9.2 or 1.9.4 - I don't remember exactly) and I think also with 1.0.10. When 2.0 comes out, I'll update it. :)

Reply by email