• Please review our updated Terms and Rules here

Turbo Pascal 4 compatible cross-compiler

vol.litwr

Experienced Member
Joined
Mar 22, 2016
Messages
324
I have made an interesting discovery recently. I have found Turbo Pascal 4.0 compatible compiler for the 8080 based CP/M! Its name is Express Pascal. I knew its author, we met in 1991 but he wanted to sell his product that time. This compiler is for a Russian computer https://en.wikipedia.org/wiki/Corvette_(computer) which has interesting graphic capabilities. It produces code compatible with CP/M. You only have to avoid using graphic functions. I tried to compile several programs on the Corvette and then successfully ran them on the Amstrad CPC 6128 and BBC Micro under CP/M 2.2 and on an MSX computer. However I couldn't run the code on the Amstrad CPC, PCW or Commodore 128 under CP/M+. This compiler has very detailed documentation in Russian but any documentation about Turbo Pascal 4 can be used instead. The compiler IDE uses English. You need to know only differences between Express Pascal 2.0 and Turbo Pascal 4.0. There are only a few of them:
1) no functions Freemem and Dispose, use only Release;
2) recursive functions can't have reference parameters (var-parameters);
3) no External or Interrupt procedures or functions. It is possible to write interrupt routine but it can be done by other means;
4) you can use constant expressions anywhere instead of just plain constants;
5) a function type can be a set type;
6) you can use a reference on a variable in Absolute and Inline constructs;
7) the for-loop can use a reference instead of a variable;
8 ) an identifier length is limited to 127 characters;
9) you can use any number of procedures and functions;
10) it is possible to stop an executing program;
11) no types Single, Double, Extended, Comp - use Real instead of them;
12) the Mem-array uses unsigned integer indices;
13) system calls are different, use functions Bios and Bdos to call them (a record type Registers is provided);
14) only the next compilers directives are supported: $A, $R, $I, $S, $V;
15) you can use Private keyword inside units.
So if anybody wants to work with Turbo Pascal 4 for his CP/M he has to use a Corvette for the cross-development. It is quite easy because the Corvette has several good emulators. Most of them work only under Microsoft Windows. But there is an emulator for browsers in js, one for Android and at least two emulators for Linux.
There are also several utilities to work with disk images. There is a package which supports a lot of retro-computer formats - http://era-cg.su/steinblume/#downloads - it is for Microsoft Windows only. There is also a small and fast utility which is available for Microsoft Windows and Linux - https://bitbucket.org/marinovsoft/mst/src/master/ Cpmtools can be used only for disk browsing (format v1050), I was not able to configure cpmtools to do a proper copy.
I have attached an archive with a disk image with the compiler (just type EP to run it) and documentation.
As this compiler generates the pure 8080 code DDT can be used for debugging as well as ZSID.
I dare to add several more words about the Corvette. It was designed by several young men in Moscow State University who were very impressed by the Tandy TRS-80 in the early 80s. So they designed their own PC and their design was supported as a standard computer for schools of the Soviet Union.This story is similar one about Apple. :) The Corvette was made having also the MSX computers as a pattern. It has large video memory (48 or 192 KB) and 512x256 color accelerated graphics. Its unique detail is an independent text plain which allows to combine three graphic plains and the text plain.
korvet1.pngkorvet2.png
 
This is very interesting and thanks for explaining all of it, but are there specific advantages to using this over using the Turbo Pascal 3 version for CPM? Given that there aren't specifically pre-built graphics libraries for this version.

Also, I see from the wiki article about the Corvette computer that it was built to be fully compatible with the MSX graphics standard in the BASIC implementation, but is it hardware compatible? Because if so there are some pre-existing TP3 libraries for it here: (description: ) http://www.msxarchive.nl/pub/msx/programming/pascal/lammassaari/00index (directory: ) http://www.msxarchive.nl/pub/msx/programming/pascal/lammassaari/
 
This is very interesting and thanks for explaining all of it, but are there specific advantages to using this over using the Turbo Pascal 3 version for CPM? Given that there aren't specifically pre-built graphics libraries for this version.

Also, I see from the wiki article about the Corvette computer that it was built to be fully compatible with the MSX graphics standard in the BASIC implementation, but is it hardware compatible?

I were using Turbo Pascal 3, 5, 6, and 7 for some time so I don't know much details about Turbo Pascal 4. I used Express Pascal only several times for small programs several days ago and I know rather little about it. Therefore I can give only some details about Express Pascal 2 advantages over Turbo Pascal 3.

1) it offers good types for integers: byte, shortint, word, integer, longint;
2) an identifier length is limited to 127 characters;
3) you can use units;
4) you can use Break inside loops;
5) it produces the 8080 code (compatible with the z80 or 8085).

I can also add a list of functions/procedures in standard library, which should work with every CP/M: Abs, Addr, Append, Arctan, Assign, Bdos, Bios, BlockRead, BlockWrite, Break, ChDir, CheckState, Chr, Close, Concat, Copy, Cos, Dec, Delete, DiskFree, DiskSize, Eof, Eoln, Erase, Exit, Exp, FilePos, FileSize, FillChar, Frac, GetDir, GetMem, Halt, Hi, Inc, Insert, Int, IoResult, Length, Ln, Lo, Mark, Memavail, Move, New, Odd, Ord, ParamCount, ParamStr, Pi, Pos, Pred, Ptr, Random, Read, ReadLn, Release, Rename, Reset, Rewrite, Round, Seek, SeekEof, SeekEoln, Sin, SizeOf, Sqr, Sqrt, Str, Succ, Swap, Trunc, Truncate, UpCase, Val, Write, WriteLn.

The next standard library function probably will not work with any CP/M: ClrScr, Delay, GotoXY, KeyPressed, Randomize, ReadKey, ReadKeyExt.

Graphic functions are useful only for the Corvette: Circle, ClrGScr, GetPixel, Line, PutPixel, Rectangle, SetColor.

There are also several predefined variables in the standard library, for instance, RandSeed.

Express Pascal IDE is very convenient and fast.

The Corvette hardware is not compatible with the MSX. The Corvette uses very easy graphic system which consists of three 16 KB plains which gives us 8 colors and 512x256 resolution. The palette is 16 colors. The text plain is independent of graphics, it is like sprites.
 
I were using Turbo Pascal 3, 5, 6, and 7 for some time so I don't know much details about Turbo Pascal 4. I used Express Pascal only several times for small programs several days ago and I know rather little about it. Therefore I can give only some details about Express Pascal 2 advantages over Turbo Pascal 3.

1) it offers good types for integers: byte, shortint, word, integer, longint;
2) an identifier length is limited to 127 characters;
3) you can use units;
4) you can use Break inside loops;
5) it produces the 8080 code (compatible with the z80 or 8085).
The big wins here are the unsigned and long integer types, and the units.

I'm curious how the units work in practice. They're certainly practical in their application, but one of Turbos big benefits is its compile speed. It manifests through doing everything in memory. When you start adding include files, or writing to COM files, it certainly starts slowing down. Add in UNITS to the compilation, plus now a linkage step (Turbo original did not have a link phase), and I wonder how much that impacted the overall development cycle. It should be noted that it still skips the assembly step, which it not nothing to be sure.

But I have to think that UNITS and linking are cheaper than including source code every time as was historically done.

The next standard library function probably will not work with any CP/M: ClrScr, Delay, GotoXY, KeyPressed, Randomize, ReadKey, ReadKeyExt.
The ClrScr, Delay, GotoXY were all stock on CP/M, since Turbo itself used the same routines. The game there was you'd configure Turbo to work on your system and then Turbo programs would benefit from that configuration. Can't speak to the rest.
 
Turbo Pascal 4 introduced Units, which could be compiled
separately and reused, this was a huge improvement over
previus versions.
BTW Borland released Turbo Modula 2 for CP/M, a very good
compiler (units in Turbo Pascal 4 were clearly derived
from MODULA) that was quickly dropped ...

https://books.google.it/books?id=AC8EAAAAMBAJ&pg=PA39&lpg=PA39&dq=turbo+modula+2&source=bl&ots=VHCN4ybh_8&sig=ACfU3U1EI09iDHQs4IvxzHQjHugzrSc2TQ&hl=it&sa=X&ved=2ahUKEwiCjfSA5M3pAhVRPJoKHd0ICKA4ChDoATABegQICxAB#v=onepage&q=turbo%20modula%202&f=false

https://techtinkering.com/2013/03/12/if-only-borland-had-stuck-with-turbo-modula-2-for-cpm/
 
I'm curious how the units work in practice. They're certainly practical in their application, but one of Turbos big benefits is its compile speed. It manifests through doing everything in memory. When you start adding include files, or writing to COM files, it certainly starts slowing down. Add in UNITS to the compilation, plus now a linkage step (Turbo original did not have a link phase), and I wonder how much that impacted the overall development cycle. It should be noted that it still skips the assembly step, which it not nothing to be sure.
But I have to think that UNITS and linking are cheaper than including source code every time as was historically done.
The ClrScr, Delay, GotoXY were all stock on CP/M, since Turbo itself used the same routines. The game there was you'd configure Turbo to work on your system and then Turbo programs would benefit from that configuration. Can't speak to the rest.

To tell the truth, I've never used units with any TP. My experience with EP is below an hour. So I can't help much with it. :(
IMHO it should be easy to configure screen code dependent routines for any CP/M but I didn't try to do such things.
EP allows also to use quite good inline assembly, for instance,
Code:
prosedure DoByte (b:byte; var r: byte);
   begin
   inline (iLHLD /addr(b)-1 {comment}
         / iMVI_C  /8
         / iDAD_H
         / iJNZ   / *+-3
 
But I have to think that UNITS and linking are cheaper than including source code every time as was historically done.

Precompiling code into UNITS and then linking them in is always, 100% of the time, faster than compiling all of your source. Units are about half the size of their source files, so they load in half the time, and on top of that you don't need to spend additional time compiling them.
 
Why do you call this a cross compiler?

Seems like it runs and compiles on the same machine..

This sounds very interesting as a solution for pascal on 8080.
 
Last edited:
Maybe I can answer my own question. I thought that the suggestion was that EP could run on any 8080 CP/M 2.2 computer but that is not the case?
Sounds like the Korvet applications don't run on standard CP/M.
So you have to run EP inside a Korvet emulator, but the compiled application might be able to run on standard CP/M 8080 so long as you avoid graphics.

Do I understand correctly now ? ;)
 
I guess one last thought. The Corvette is an 8080 based machine, and so it is disappointing EP.COM does not run on a standard CP/M machine also.
Would the issue be that the CRT is "memory mapped" and not acting like a terminal?
I did download and attempt to run EP.COM on a more or less standard CP/M 2.2 machine with no luck.

Is there a way to get this to run with a terminal CRT?
 
I guess I will keep this thread moving along...
So, I am wondering what it would take to get EP.COM running on a standard CP/M rig.
After all, Turbo Pascal for 8080 has been on many a wish list.

So the next clue is that the Korvet computer will run "stock" CP/M applications.
Sample set of one, but the Korvet simulator allowed me to load and run VEDIT.COM unchanged.

Therefor standard CRT/console works for text, and I assume that the Pascal UI uses text console and not graphics.

So - why would EP.COM not run on a standard CPM-80 machine? When I try it, the application displays nothing and seems to hang. Bank switching memory ?
 
I have tried EP and EP2 on my Microbee running both cp/m 2.2 and 3.1 and no go. All I get is a some obscure characters on the 24th line of the screen and the whole system hangs.
 
I have tried EP and EP2 on my Microbee running both cp/m 2.2 and 3.1 and no go. All I get is a some obscure characters on the 24th line of the screen and the whole system hangs.

yah, seems like 2 things are going on. EP is using the graphics mode of the hardware to display, and it is leveraging bank switching in memory. Both of these are going to make it hard to get EP running on a stock CP/M box.

Microbee is Z80 though right? You can run "stock" Turbo Pascal can you not?
 
ahah! very interesting! thanks for that bit of detective work.
My application does not have video ram; all video is handled with terminal code sequences over serial. So some change needed. But good to know you got it "running".

How did you conclude that that location was at all related to video ram? there are lots of instances of FC00 in the EP.COM program.
 
Last edited:
I have tried EP and EP2 on my Microbee running both cp/m 2.2 and 3.1 and no go. All I get is a some obscure characters on the 24th line of the screen and the whole system hangs.

EP uses the Corvette Video RAM for its tables so you need a Corvette for the cross-development. The Corvette uses quite plain CP/M 2.2 and can run almost any CP/M console program.
 
Back
Top