Program Turbo Pascal

0 views
Skip to first unread message

Oreo Huppe

unread,
Aug 3, 2024, 10:29:12 AM8/3/24
to jiaramusholt

I have not used turbo pascal, but for the small model for the x86 is very compact and optimized
for the ALGOL style of compiler. With C and other languages you had to have code that works with every model.

CP/M was blessed with many programming languages, each with their own strengths and weaknesses. I think that Turbo Pascal stands out from these and I'm not alone. When Turbo Pascal was released in 1983 by Borland, as their first software development application, it was quickly adopted by schools, universities, hobbyists and professional software developers. Turbo Pascal combined ease of use, power, speed and a great manual all for the really low price of $49.95.

With TP you get an Integrated Development Environment (IDE), so that you can edit, compile and run all from the same application. Since the IDE is only 34Kb there is plenty of space left on a disk for your source code and compiled programs. This is particularly handy for single disk machines. The editor is very functional and uses a subset of the Wordstar key combinations.

Pascal was designed to be easy to compile and because TP uses a single pass compiler, compilation speed is incredibly quick. The downside of the compilation speed is that the code is quite a literal translation without much optimization. However, for many applications this won't be much of an issue compared to the increased programmer productivity.

If you need parts of your program to run faster, you can always embed inline machine code into functions/procedures or access functions in external binaries. The latter option allows you to create libraries in assembly language and use a jump table to access individual functions with the external keyword.

In 1986 Borland released Turbo Pascal 3.0 which added support for overlays. The running code could now be swapped in and out from disk as needed. With careful planning, you could escape the normal 64Kb limit and only be constrained by the capacity of the disk you are running the application from.

The standard library offers a good range of functions and TP keeps quite close to Standard Pascal as defined by Jensen & Wirth in their 'User Manual and Report'. As with all Pascal implementations, there are problems porting programs between implementations. However, if you aren't using any of the operating system specific calls, then you can easily port to the MS-DOS and CP/M-86 versions. My only gripe is that TP doesn't support procedures and functions passed as parameters.

Finally, Borland included a highly readable and very complete manual. It covered not just the IDE, language and libraries, but also detailed information on the memory layout and calling conventions from assembly language. This meant that you could quickly get up and running with few additional resources.

Put at least TINST.* and TURBO.* files onto a disk. The real advantage of not copying all the files is seen if you only have a single drive. The extra room will allow you to edit, compile and run your programs all from the same disk. For instructions on how to create a virtual disk for z80pack look at: Emulating a CP/M System With z80pack.

Press S for Screen Installation and select the appropriate terminal for your set up. I'm using z80pack, so I select ANSI. You probably don't want to alter this definition so say No to altering it. Then enter the speed in Mhz of your machine. If a suitable terminal isn't listed consult the TP manual for advice.

If you want to configure additional editor commands, you can do this via the Command Installation option. At the very least, if you have them, you'll probably want to configure the page-up, page-down keys as well as the cursor keys to represent character-left, character-right, line-up and line-down. If not press Q to quit.

You should now be looking at the Turbo Pascal splash screen, showing the version, copyright message and which terminal is configured. At the bottom you are asked whether to 'Include error messages'. For the moment press Y.

To work with a pascal source file, first press W and then enter a filename. This is the file that the editor will open and it is also the file that the compiler will compile if you haven't selected a main file.

Get the Turbo Pascal 3.0 Manual for CP/M-80, CP/M-86 and PC-DOS/MS-DOS from bitsavers.org. It is a wonderfully well-laid out manual and you should have no problems using this to learn and get the most out of Turbo Pascal. You may also want to take a look at a copy of the old Borland musuem page: Antique Software: Turbo Pascal v3.02.

"Surely many arguments for or against a language can be relegated to philosophy, but the fact is, that in military or space projects, C is prohibited, only the Pascal related language ADA is allowed. Jobs relevant for security, for example controlling railways and plane electronics are often written in Pascal not in C. This
is surely not because of nostalgic reasons. So much to our decision to use Pascal instead of cryptic C."

I learnt it as part of a computer science degree, its a good language to learn to program with, and unlike the C based languages , it makes some sense when you look at it years later . C was often criticised as a 'write only' language, because of its terse and cryptic nature.

Nicholas Wirth's Pascal is, in my opinion, a bit too restrictive for embedded programming. There are times when being closer to the metal is necessary and the original Pascal keeps the programmer as far from the metal as possible.

After working with both for decades, the decision comes done to a handful of features. If a preprocessor is important, then C++ is usually the better choice. If bit-sets are important, then Pascal is a better choice. If multiple-inheritance is important, then go with C++. If simplified interfaces are important, then go with Pascal. There are good numerical libraries, graphical libraries, database libraries, etcetera for both.

My personal preference is C++ for embedded programming. I like being able to put object-instances in static data, on the stack, or on the heap. In my opinion, portable C++ code is easier to develop than portable Pascal. I like having a good preprocessor when doing embedded work. I see no compelling reason to choose Pascal over C++ for the Arduino.

It's been many years since I used it (grad school), but I just got a very weird chill reading your LISP post, Lefty! It is a very beautiful language formally, but wow. I vaguely recall that you could write a solution to the Towers of Hanoi problem in about one line. CAR CDR indeed.

I don't think it's fair to call ADA "pascal related." Like many big $$ language developement efforts, ADA was something of a mashup of most of the languages around. Pascal probably someone less than AlgoL, ForTran, PL/1, and probably even CoBOL, give the buy-in they wanted form "serial software writers" rather than just universities.

Wirth-style pascal is a bit worthless for deeply embedded systems; it does too much that it disallows the code to do, rather intentionally. Most modern Pascals for micros have fixed these issues, I believe.

Wikipedia seems to agree with you, but I remember it feeling more like Ada was yet another attempt to merge all the best features of all the languages people were using into one. Not too different from IBM's attempt to make PL/1 replace both Fortran and Cobol (plus "academic" languages like Algol.)

Well, there was that tendency, as I recall. But it all came from ALGOL originally. I think. I'd have to go back to the long-ago boxed reference books to verify the chronology. Or just trust Wikipedia and look it up online

In any event, programming languages of that class and era were very much aimed at the development of large, complex systems. Therefore verifiability and program correctness were driving goals for language design.

Absolutely false. There was an attempt to require this, many years ago, but it failed. One can argue that we'd be better off if it had succeeded, especially given the number of spectacular failures that have resulted from allowing the military to use Microsoft crapware in important systems. But it didn't, and I'm suspicious of anyone who doesn't know that, and who feels compelled to keep putting "C" in quotes. It suggests someone with an academic background and little real-world experience: professionals don't use quotes when referencing C any more than they do Pascal or COBOL.

There certainly would be some benefits to learning another language if you plan to do a lot of programming: as with learning more than one spoken language, it broadens the mind. Learning a more "academic" language like Pascal is useful because the compilers tend to nag you more about risky and sloppy programming practices, or even prohibit them. That encourages better coding habits. But modern C and C++ compilers can be told to be fussy, and can spot and warn you about many risky practices without trying to keep you from taking the risk if you choose to do so. So that advantage has diminished a lot.

My advice: if you plan to get serious about programming as a hobby, you should definitely plan on learning some other languages. Perhaps something like Python or Java that's useful for making things happen the way you want to on the PC side, for starters. If you're thinking about programming professionally, learning other languages is essential.

If you're just having fun tinkering with Arduinos as an occasional diversion, you shouldn't feel bad about sticking with the standard Arduino toolkit, and may even find it confusing to learn other languages if leads to trying to use techniques or syntax you learned in language "x" when you're coding in language "y".

At least at the management level: down in the trenches, I'm sure there were a lot of unhappy COBOL users who saw it as a matter of self-preservation against future suffering from Carpal Tunnel Syndrome ;D

Hi I have Turbo pascal and my teacher told us to find how much a guy will earn if he puts in a hundread dollars a month till he's sixty at 5 percent interest. (compound interest that is)
Help me please, Here's the code:=

c80f0f1006
Reply all
Reply to author
Forward
0 new messages