Recent

Author Topic: How could someone write a new rtl for freepascal?  (Read 1253 times)

guest64953

  • Guest
How could someone write a new rtl for freepascal?
« on: December 03, 2019, 01:10:11 pm »
My friend is a CS student. He want to ask if he could and how to write a new rtl for freepascal. Is it have to be written in pascal as well? The guy is learning C and want to implement it in C, too  :)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: How could someone write a new rtl for freepascal?
« Reply #1 on: December 03, 2019, 01:40:11 pm »
My friend is a CS student. He want to ask if he could and how to write a new rtl for freepascal.

Yes. Just start. Check out rtl/minimal and the various wiki articles about "writing OS" in FPC. This is often includes making a new minimal RTL for a target.

Quote
Is it have to be written in pascal as well?

It is the library for Free Pascal. You may use whatever language you use, as long as it generates Free Pascal compatible units.

Which currently, out of the box that is limited to the subset of exactly Free Pascal in the current and previous version. So it would be very hard to use anything else, or only after heavy modification.

  • Calling convention. On 32-bit non standard register
  • RTL is implemented as Units, and units have binary files that describe them (.ppu) This will be hard to duplicate
  • Units acts as a kind of namespace with mangling of procedures
  • Various exceptions (SJ, SEH) in use on e.g. Windows
  • Generation of various tables for operation

And the list goes on.

Quote
The guy is learning C and want to implement it in C, too  :)

Even if it were possible (which I sincerely doubt), it is not something for a beginner. At the very least he should have a C compiler that he can (very heavily) modify and enhance to generate tables, extend with mangling, write PPUs etc
« Last Edit: December 03, 2019, 03:21:20 pm by marcov »

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: How could someone write a new rtl for freepascal?
« Reply #2 on: December 03, 2019, 01:52:47 pm »
At the very least he should not ask which language, but should be able to be to analyze what are the pro's and con's of a language and take six weeks each to be able to be proficient in them.
He is a computer science student, you wrote. A language is just a tool, does he understand that? Theory is way more important.
Computer languages are not rocket science, the theory behind them makes rocket science implementable, not possible.
Most CS people have way more than an understanding of just one computer language because they are not restricted to that: get the theory right and you should be able to learn any computer language. (If it is Turing complete...)
It may very well be that if his Master focusses on math, he will choose Fortran, or if his subject is string oriented, he would choose Pascal, of if he is in a rush chooses Python or if he want to shoot himself in the foot choose C.
Note these are all languages from my past: I have just (two years ago) started to pick up Haskell.

Get the point?

A CS student should be able to have sufficient knowledge to make the choice for the right tool, even better: he should me able to make the right tool for what he needs.
Compiler engineering is craft, not science. Computer science is.
« Last Edit: December 03, 2019, 02:15:28 pm by Thaddy »
Specialize a type, not a var.

guest64953

  • Guest
Re: How could someone write a new rtl for freepascal?
« Reply #3 on: December 03, 2019, 03:08:14 pm »
I admit I didn't understand anything on this thread. I will ask him to create his own account on this forum to reply with you  %)

guest64953

  • Guest
Re: How could someone write a new rtl for freepascal?
« Reply #4 on: December 04, 2019, 04:41:38 pm »
The guy quitted. He now struggle with data structure and algorithm, something called graph. When think about graph, I imagine mathematic function curve like y = sin(x) but in fact it's a bunch of points connected by many lines. How weired it is!   >:D

 

TinyPortal © 2005-2018