Dec 232017
 
Convert Turbo Pascal to VAX Pascal.
File VAXTURBO.ZIP from The Programmer’s Corner in
Category Pascal Source Code
Convert Turbo Pascal to VAX Pascal.
File Name File Size Zip Size Zip Type
VAXTURBO.DOC 11218 4058 deflated
VAXTURBO.PAS 34388 7273 deflated

Download File VAXTURBO.ZIP Here

Contents of the VAXTURBO.DOC file


Turbo Pascal
vs.
VAX/VMS Pascal

A Comparison/Conversion Guidebook.

9-May-1986
Walter M. Lamia
Digital Equipment Corp.


This document is an attempt to facilitate the migration of programs
written in Turbo Pascal to VAX/VMS Pascal. I have made every attempt
to make it accurate, but neither I nor Digital Equipment Corp may be
held liable for the accuracy, suitabiity of use, or maintenance of
this documention or its accompanying code.

The focus of this document is to make Turbo Pascal features onto VAX
Pascal features, but not the converse. VAX Pascal is a complete
implementation of Pascal, and is a fully compliant VAX compiler
language, so it includes many extensions for controlling linkages to
other compiled modules, all VAX data types, etc.

I must, for the sake of brevity, assume that the reader has a working
knowledge of both Turbo Pascal and VAX Pascal, and has access to their
respective documentation. This document addresses the DIFFERENCES in
the two languages, not the similarities where they are equivalent.

Finally, keep in mind that this document is only a guidebook for
converting and/or writing programs -- it isn't a magic recipe for
doing conversion automatically, although some ambitious soul might
want to take a crack at writing a (partial) translator program. I
won't. (Hint: if anyone does want to try this, I suggest that you
investigate the VAX Scan language as a potential implemention
language.) The closer the program is written to standard Pascal, the
easier the conversion will be. Using good software engineering
practices of information hiding and modularity will also help greatly.
I also recommend highly the use of the VAX Language Sensitive Editor
for creating and maintaining VAX Pascal programs, as it helps enforce
good coding practices.

If anyone has any suggestions or extensions to this document or its
accompanying library, please communicate with me.

Walter M. Lamia
Digital Equipment Corp. 93 Central St.
ZKO2-3/M31 Acton, MA 01720
110 Spit Brook Rd.
Nashua, NH 03062-2642
603-881-2121 617-263-3214

METOO::LAMIA
decvax!decwrl!dec-rhea!dec-metoo!lamia


PROGRAM FORMAT

TURBO VAX
----- ---

PROGRAM statement ignored PROGRAM required, and all files,
including INPUT and OUTPUT must be
declared

Directives specified as {$d} Attributes specified as [ATTRUBUTE]

Comment delimiters {} and (* *) are Comment delimiters are equivalent,
distinct, so nesting is allowed so nesting is NOT allowed

Hex constant format is $nn Hex constant format is %X'nn'
ASCII value format is #nn ASCII value format is ''(nn)
ex: ESC = #$1B ex: ESC = ''(%X'1B')

Control chars can be written ^G N/A

Include files with {$I filename} Include files with %INCLUDE 'filename'

Labels can be any alphanumeric Same
identifier


DATA TYPES AND REPRESENTATIONS

TURBO VAX
----- ---

even value = FALSE, Same
odd value = TRUE

16-bit integer 32-bit integer
48-bit real 32-bit real
64-bit double (G and H)
128-bit quadruple

VAX Pascal equivalents of Turbo types for when it matters how big
in bits the data items are.

Type
integer16 = [WORD] -32768..32767; { same size as Turbo Integer }
byte8 = [BYTE] 0..255; { same size as Turbo Byte }
uword = [WORD] 0..65535; { unsigned 16-bit word }

Variable strings

St: STRING[n], n = 1 to 255 St: VARYING[n] OF CHAR, n = 1 to 65535
with length stored in St[0] as a record structure with
length stored in St.LENGTH
and string body in St.BODY

PACKED ignored PACKED works

N/A Compile-time expressions allowed
wherever a constant is used

Typed constants for VAR initialization expression
initialized variables
CONST i : INTEGER = 3; VAR i : INTEGER := 3;

{ see appropriate documentation for variations }
{ on the theme of Array and Record constant constructors }


STATEMENTS, OPERATORS, FUNCTIONS, MISC

Turbo VAX Pascal
----- ----------

Retyping by the use of Type name Retyping with the Typecast ::
as a function operator
Month(10) = Nov 10::Month = Nov

CASE ... CASE ...
ELSE ...; OTHERWISE ...;
END; END;

Case labels may be lists Case labels may be lists,
or subranges but not subranges (so far)

real := Int(real | integer) integer := INT( any ordinal )
(returns integer part of arg.) (converts value of arg. to integer)
integer := TRUNC( real ) integer := TRUNC( real )

arithmetic AND UAND function
r := p AND q; r := UAND( p, q );
arithmetic NOT UNOT function
r := NOT q; r := UNOT( q );
arithmetic OR UOR function
r := p OR q; r := UOR( p, q );
arithmetic XOR UXOR function
r := p XOR q; r := UXOR( p, q );
logical XOR XOR function
boolr := boolp XOR boolq; boolr := XOR( boolp, boolq );
arithmetic SHL SHL function {VaxTurbo library}
r := i SHL j; r := SHL( i, j );
arithmetic SLR SHR function {VaxTurbo library}
r := i SHR j; r := SHR( i, j );

Pos (pat, source) POS_ (pat, source) { VaxTurbo libr. }
Delete (source, pos, len) DELETE_ (source, pos, len) "
Random, Random(ceiling_integer) REAL Random only "

Misc functions that are similar in intent, but are implemented differently

SizeOf SIZE, but read documentation carefully
Addr IADDRESS " " "
FillChar Pad " " "
Exit {from a procedure} N/A {use a GOTO label}
Move N/A
Halt HALT (calls exit condition handler)
also see SYS$EXIT system service

The accompanying VaxTurbo library has emulations of many of the Turbo
Pascal built-in functions and procedures. Please read it as well.

The operating system access features of Turbo are obviously not
meaningful to VAX Pascal. These include: access to physical memory and
hardware ports as arrays; pointers to device drivers; operating system
Bios, Bdos, and MsDos calling procedures; Intr; GetMem and FreeMem;
inline absolute machine code; IBM-PC graphics, windows, sound.
Equivalent functionality can be had in VAX Pascal by using the
Run-Time Libraries and System Services.
I/O OPERATIONS

The area of I/O is the most different among all Pascal
implementations, and Turbo/VAX is no exception.

In general, it is safe enough to use Standard Pascal READLN and
WRITELN to the console and text files, which both versions support.
Long sequences of WRITE's to OUTPUT with no WRITELN's can cause quota
problems in VAX Pascal, for reasons that I won't go into now. See the
CrtInit procedure for a technique that helps alleviate the problem by
defining a non-standard long record length for OUTPUT.

Both versions support FILE OF (type) and READ/WRITE on sequential
files in about the same way. However, random access is considerably
different, and VAX Pascal supports RMS ISAM files.

The following is a table that will help you to compare Turbo I/O
features to VAX Pascal features. Rather than complicate this too much,
readers are referred to the appropriate documentation for more
details.

Turbo VAX Pascal
----- ----------

Assign/Reset/Rewrite/Append OPEN/RESET/REWRITE/EXTEND

{$I-} .. {$I+} ( .. ERROR:=CONTINUE) parameter on
I/O procedures

IOResult variable STATUS(fv) function

formatted WRITE default field size ... = 12 for integer, real
= 1 for integer = 20 for double
= 18 for real = 40 for quadruple

N/A enumerated values in formatted WRITE

N/A GET / PUT

MkDir CREATE_DIRECTORY
Rename(fv) RENAME_FILE(fn1, fn2)
Erase (fv) DELETE_FILE(fn)
Seek FIND / LOCATE
FilePos,FileSize N/A
KeyPressed ? - QIO's, maybe?
ParamCount,ParamStr Use LIB$GET_FOREIGN

Block operations on Untyped files fv: FILE OF ARRAY[1..512] OF CHAR;
OPEN(fv,fn,NEW,,SEQUENTIAL,FIXED);
OLD
REWRITE / RESET
PUT / GET

Execute Use LIB$DO_COMMAND or
LIB$RUN_PROGRAM or
LIB$SPAWN as appropriate

Chain overlays Don't bother!


 December 23, 2017  Add comments

Leave a Reply