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

Nikolai Zhubr s001@hotbox.ru
Sun, 9 Jun 2002 15:29:26 +0400


Hi,
Sunday, 09 June, 2002, 12:38:10, Johann Glaser wrote:
[...]
> 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?
Well, yes, I wanted to parse 'PE' (32bit flat) .exe and .dll executables,
and it was messy I remember. Partly, because of lack of _proper_ info in
MS world. Perhaps this got better by now with the help of open-source
people. Anyway, I didn't try to provide much compatability, just wanted
_something_ to work.

[...]
> 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)
Well, actually interrupt handling on many (regular) systems involves
much more stuff than just a handler pointer and a number. For example,
think of shared IRQs, which are quite common. And, it is heavily
platform-dependant. I definitely do not believe that it is a good idea
for an abstract language compiler to deal with this internally. It is
an operating system job. And, I see no reason why this could not be
implemented nicely using existing compiler abilities. Ups, I guess
I see one :)) Bit fields, perhaps? Would be nice to have them when
manipulating some hardware-defined stuff. And, yet, this is
not platform-dependant (I guess).

>  2) "static" ... this variable should be static. I think using "Const"
>     instead of "Var" would do the job.
Isn't it enough to just declare it outside the procedure?

[...]
> 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?
It's not that difficult to unpack 32-bit .exe to a plain memory image.

> How can one avoid to use the System unit? I only want a few procedures,
I'm not yet familiar that much with FPC but no doubt a good compiler
_must_ be able to compile some standalone unit without making external
references. IIRC it is possible to make Delphi do it, for example.
[...]
-- 
Best regards,
 Nikolai Zhubr