[fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

Ralf Quint freedos.la at gmail.com
Tue Mar 28 20:05:04 CEST 2023


On 3/27/2023 2:45 AM, Jacob Kroon via fpc-pascal wrote:
> Hi,
>
> I have some old Pascal code that was compiled in a CPM environment 
> using the Pascal/MT+ compiler from Digital Research. I'm trying to get 
> this project to build in a modern environment, for a start using 
> FreePascal.
>
> First, is anyone aware of a tool for converting this dialect of Pascal 
> to something that FreePascal will accept ?

Well, it is a very long time since I used Pascal MT+ the last time, and 
that was already on the x86 version (+30 years now), but the same things 
should still apply.

First of all, Pascal MT+ is more or less ISO7185 compatible, so you 
would have to use that mode in FPC if you don't want to change all those 
file reference (that's what's mostly different to a "real" Pascal :P )

As for the "external" vars (and possibly procedures/functions), it is 
not quite the same as the units in UCSD/Turbo/Delphi/FreePascal, but it 
had the possibility (due to source code size restrictions, you had only 
64KB for OS, compiler and source code together) to compile different 
source files into separate object files, which then could be linked 
together with the linker. It is more of an "forward" declaration. In 
most cases, I would assume that you could actually copy all those source 
files that are being referenced into a single source file. Using units 
could work in a lot of cases, but which way to go might depend on your 
actual use case...


Ralf

>
> Second, the old code contains a lot of:
>
> var
> foobar : external integer;
>
> in sources that reference 'foobar', then there is a declaration in one 
> of them:
>
> var
> foobar : integer;
>
> As I understand it, in order to translate this to something that 
> FreePascal understands, the variable needs to go in a "unit" and be 
> part of its interface. Then, pascal sources that needs to reference 
> the variable should use this unit. Is this the easiest way forward ?
>
> I thought maybe I instead could adapt the syntax like:
>
> var
> foobar : integer; external;
>
> but with this I still get undefined references when linking. Using 
> units seems ok.
>
> Bets regards
> Jacob
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




More information about the fpc-pascal mailing list