Re[3]: [fpc-other]reputation of Pascal

Johann Glaser Johann.Glaser@gmx.at
09 Jun 2002 10:38:10 +0200


Hi!

System programming with Pascal is a very interesting task. My attempt to
write a small operating sys was totally in assember (Turbo Assembler),
because I had control over memory regions, ...

When you wrote your OS with Delphi, I guess you made .exe files or at
least .dll files. But therefore you have to implement a loader for it.
Did you? Is it very difficult to write a loader for .exe, .dll or (far
better) for ELF binaries?

> Still, I personally have a feeling that modern Pascal (like Borland's
> or FPC perhaps) is in partucular suitable for building and maintaining
> a _large_ project such as an operating system. Why not? Does anyone
> know some real obstacles, or perhaps such kind of project exists
> already?

Yesterday I had a closer look to the Infineon TriCore TC1775
microcontroller. It is a 32 bit µC with looots of funny things inside.
(but it is a BGA329 package, but I'll manage that ;-) ). I thought of
writing a nice assembler for Linux, GPLed of course. But only assembler
is a bit poor, so I thought of extending FreePascal to use that
assembler.

My question: How difficult and how much work is it to extend FPC for
that processor? Some time ago I heard of a new internal structure to
easily implement newer processors. Is that restructuration already in
1.1?

Additionally this Pascal would have to be more complex than normal FPC,
because I'd need interrupt procedures like in Keil C for the Infineon
C166. e.g.

Procedure TimerISR; interrupt 12;
Var Counter : LongInt; static;
Begin
  if P12.2 = 1 then
    Inc(Counter);
End;

Here are three specialities:
 1) "interrupt 12" ... this should tell the compiler to automatically
    put this procedure to the interrupt vector table (or whatever the
    µC uses)
 2) "static" ... this variable should be static. I think using "Const"
    instead of "Var" would do the job.
 3) "P12.1" ... direct access to bits of bit addressable
    registers/memory

Additionally the TriCore has a second Peripheral processor inside, which
has other opcode set and its own data and code memory. ISRs can be
executed there instead of the main core CPU. Lots of interesting
features, and I'd love to have them in FPC. :-) I would help to
implement that. But, is it possible?

Another thing interesting me: can FPC give me a binary file instead of
an executable. So that the first byte starts with real code, as a MS-DOS
.com or .bin file did?

How can one avoid to use the System unit? I only want a few procedures,
which don't need so many system functions. The Linux kernel itself
doesn't use libc either. (BTW: It is not nice to see a tiny FPC program
with 80kB executable, where a far more complex C program only has 7k. I
don't care, but how to argue to others?)

Bye
  Hansi

-- 
Johann Glaser   <Johann.Glaser@gmx.at>
   Vienna University of Technology
       Electrical Engineering 
____ http://www.johann-glaser.at/ ____