CHAPTER 1: PASCAL/MT+ INTRODUCTION AND OVERVIEW

Welcome to the world of Pascal/MT+. This document describes a professional tool which is being used at thousands of installations, worldwide. Pascal/MT+ supports the entire International Standards Organization (ISO) standard, DPS/7185 including variant records, sets, typed and text files, passing procedures and functions as parameters, GOTO out of a procedure, conformant arrays, and program parameters. The following is a list of additions to the standard supported by Pascal/MT+.

Pascal/MT+ is designed both for data processing applications (compilers, editors, linkers, and business packages) and real-time control applications (measurment Systems, communications processors, video tape controllers, etc.). All Pascal/MT+ software is suitable for using in a ROM-based environment and is designed to operate with or without an operating system. Various software manufacturers make Pascal/MT+ compatible software such as data base access methods.

The purpose of this chapter is to present an overview of the contents of the manual, a system overview, host system requirements and run-time system requirements, and to describe the files on the distribution disk as well as the minimum set needed to compile a program.

Because of the complex nature of Pascal as a language, and the availability of many textbooks, we are not providing tutorial documentation but rather a reference chapter and a detailed description of extensions and additions which make Pascal/MT+ unique. However, Appendix A contains a tutorial on files in the Pascal/MT+ system. Please refer to the bibliography and choose a textbook if you do not know the Pascal language.

1.1 HOW TO USE THIS MANUAL

WILL IT WORK ON MY SYSTEM?
The answer to this question is in Sections 1.3 and 1.4 of this chapter. A description of the host requirements for running the compiler and linker is found in Section 1.3. Section 1.4 describes the run-time environment needed to execute programs compiled by the Pascal/MT+ system.
GETTING STARTED
To check that your software operates as it should, follow the directions for bringing up the software and compiling a program in Section 2.1.
USING THE COMPILER
For compiler options and directives read Section 2.2. Larger programs may be broken into small compiled units called modules which are treated in Section 3.1. Compile-time errors are treated in Chapter 2 and in the appendix.
USING THE LINKER
Section 2.3 describes the operation of the linker. Also, when you are familiar with the options provided by the linker the overlay scheme for large programs is discussed in Section 3.3.
USING THE DEBUGGER
Debugger instructions are found in Section 2.5.
USING THE DISASSEMBLER
Section 2.4 contains information on the disassembler.
USING THE LIBRARIAN
The librarian instructions are given in Section 2.6.
WHAT DOES THE PASCAL/MT+ LANGUAGE PROVIDE?
Chapter 7 is the definition of the Pascal/MT+ language, based on Jensen and Wirth's 'User Manual and Report'. Chapter 7 is a description of the ISO and MT+ features which are not implemented in the Jensen and Wirth Pascal. This chapter is not sufficient by itself to learn Pascal. If you do not yet know Pascal, use Jensen & Wirth or any Pascal textbook as a supplement when studying this chapter. See the bibliography.
HOW ARE THE PASCAL/MT+ EXTENSIONS USED?
The answer to this question is found in Chapter 3. All of the extensions are described with examples and suggestions.
FILE I/O (including console and printer I/O)
Pascal/MT+ file I/O is presented in Appendix A in tutorial format with many program samples. The file access procedures which are not part of the standard Pascal are discussed in Section 3.4 as well as in the appendix. Some notes on file access are also found in Section 7.12. Fast I/O routines are described in 3.4 and in Appendix A.
REAL NUMBERS
The format of real numbers is found in 5.1. Use of the AMD9511 hardware math chip is discussed in the appendix. The software floating point real number library is FPREALS.ERL, and the BCD real number library is BCDREALS.ERL.
RECURSION
Sections 2.2.4.10 and 3.9 indicate how to use recursion and what to watch for when using recursion. Check the index for the effects of recursion on various features of the language.
PUTTING A PROGRAM INTO ROM
Information on stand-alone operation of object code is found in Chapter 6.
ASSEMBLY LANGUAGE INTERFACING
Section 3.2 describes how modules written in assembly language and compiled to Microsoft compatile files may be interfaced with Pascal/MT+ programs.
RUN-TIME ERROR HANDLING
Sections 2.2.4.6 and 2.2.4.7 and Chapter 4 discuss Pascal/MT+ run-time error handling.
SYNTAX DIAGRAMS, KEYWORDS
The Pascal/MT+ BNF syntax diagrams are found in Appendix D and in Chapter 7 as each feature of the language is presented. A list of keywords is found in Appendix C.
PROGRAM STRUCTURE
The structure of a program generated by the compiler is presented in Chapter 5. Data storage is also presented in this chapter. Section 3.3 describes the structure of a program which is using overlays.

MT MicroSYSTEMS has endeavored to produce a complete, integrated package of software tools and we are presently creating additional tools for use with this package. If you have suggestions for improving any MT MicroSYSTEMS' product, please WRITE US A LETTER. We evalutate, and often implement, user suggestions and comments. All suggestions become the property of MT MicroSYSTEMS, Inc.

1.2 SYSTEM OVERVIEW

The Pascal/MT+ system contains a compiler, linker, disassembler, debugger, run-time subroutine library, and optional editor package. Figure 1 shows a diagram of the relationships among these programs.

(any CP/M compatible editor may be used including our SpeedProgramming (tm) editor, which includes a syntax scanner).

+--------+
| editor |
+--------+
    |       (temporary file created and deleted by the compiler)
    V       /
+----------+
| compiler |<---- error message text file
+----------++
      |     |
      V     +-> relocatable file   [run-time-library]
   listing         |        |      |     also [other user modules]
     file          |        V      V
      |            |      +--------+
      |            |      | linker |<---- [optional debugger]
      |            |      +--------+
      |            |          |
      |            |          V
      |            |       executable program
      |            |       (optional symbol table)
      V            V
+----------------------+
+     disassembler     +---> intermixed source and assembly code
+----------------------+
Schematic Diagram of Pascal/MT+ Operation

The user executes the compiler to translate source programs into relocatable machine code. Then the user links this machine code with the run-time subroutine library to produce an executable object program. If desired, a "listing" file from the compiler and the relocatable file may be combined into a intermixed file of source code and assembly code using the disassembler. The user may also inform the compiler that use of the symbolic debugger is desired. The compiler and linker will then output an executable object module with the symbolic debugger included. Facilities such as variable display, breakpoints and tracing are available using the symbolic debugging package.

1.3 SYSTEM REQUIREMENTS

The Pascal/MT+ system requires an 8080, 8085, or Z80 CPU running the CP/M operating system (release 1.4 or later) in which to operate. Other operating systems which claim to be CP/M compatible may be used but the responsibility for compatibility lies with the user.

In a CP/M environment, the compiler requires 92K of simultaneous on-line storage. The Pascal/MT+ compiler requires 36K bytes of memory in which to reside. The compiler symbols occupy 4K bytes of symbol table space (this number may be changed using $K toggles to eliminate unused symbols) and still more space is needed for user symbols. For example, the largest module of the Pascal/MT+ compiler requires 17K of symbol table space. This means that a minimum recommended TPA (transient program area) of 43K is needed to compile small programs (allowing 3K for user symbols). A 48K CP/M system, in most cases, provides this minimum TPA If the entry to the BDOS is higher than ABFF you have enough room to compile small programs. However, a 48K TPA is recommended as a minimum working environment. Additional memory, if present, will automatically be used.

The linker requires only 11K bytes of disk and memory space. Because it uses memory for linking programs and run-time routines, the amount of available memory limits the program size which can be linked. A 59K TPA (maximum available memory for a minimum configuration 64K CP/M) has approximately 49K bytes of work space after the linker and linker data is loaded. This work space must contain the symbol table and the object code. In addition, if the /D switch is not used it must also contain the data area. Overlays can be used when the program becomes to large to link in one step.

1.4 RUN-TIME REQUIREMENTS

The Pascal/MT+ system generates programs which utilize a variety of run-time support subroutines which are extracted from PASLIB, the run-time library, and other relocatable modules. These run-time routines handle such needs as "multiply" and "divide" and file input and output interface to the operating system. CP/M 2.0 or a later release is required to use random access files.

For programs which are run under the CP/M operating system the minimum run-time overhead is typically in the 2K- to 6K-byte range. This includes support routines and text file I/O routines for integer, characters and strings. Additional modules will be included for routines which utilize REAL numbers, non-text file I/O, transcendental routines, etc. Below are the current approximate sizes (in 1024 byte units) of the run-time libraries and support modules. These numbers are subject to change without notice. If you need a very accurate view of run-time overhead, link the individual file, ignore the undefined references, and note the code and data size at the end of the link.

File CodeDataTotal
PASLIB* 16.8 2.319.1*
FPREALS** 6.1 0.5 6.6
TRANCEND 2.5 0.3 2.8
BCDREALS** 2.3 0.1 2.4
FULLHEAP*** 1.8 0.1 1.9
RANDOMIO 2.1 0.1 2.2
DEBUGGER+ 7.9 1.2 9.1
REALIO++ 4.0 0.4 4.4
FPRTNS+++ 0.8 0.1 0.9
TRAN9511+++ 0.4 0.1 0.5
* normally only the referenced routines are linked using only 2 to 6 K bytes
** only one of these are used for software real number support. FPREALS is searchable, BCDREALS is not searchable
***used for ISO heap management; PASLIB contains a smaller version for UCSD style heap management
+ when used, compiler generates extra code; never contained in final version of program
++ counted in FPREALS already, used only for AMD9511 support
+++used only for AMD9511 support

1.5 PASCAL/MT+ DISTRIBUTION DISK INFORMATION

The Pascal/MT+ software package is distributed on media compatible with your computer (tape, diskette, etc.) The package consists of a number of CP/M files containing object, source and relocatable files. Listed below are the names of all of these files, a brief description of their contents and a list of which files are required to configure a minimum operational disk. These files are subject to change without notice as later releases of the software become available and the contents of the distribution disks change.

FILECONTENTS
MTPLUS.COM Pascal/MT+ compiler, executable CP/M file (Phase 0) Syntax scanner and listing file generator also generates PASTEMP.TOK temporary file which is approximately 1/3 the size of the source code file. Also uses MTERRS.TXT for error message text.
MTERRS.TXT Ascii text for error messages used by MTPLUS.COM
MTPLUS.000 Root program (a .COM file renamed so that it cannot be executed directly) which calls the overlays .001 through .006.
MTPLUS.001Built-in symbol table initialization.
MTPLUS.002User Symbol table construction (Phase 1)
MTPLUS.003Code generator initialization
MTPLUS.004Object code generator pass (Phase 2)
MTPLUS.005Code generator termination and external reference output
MTPLUS.006 Debugger symbol table output routine (actually executed between .002 and .003 overlays)
LINKMT.COM Pascal/MT+ linker, takes .ERL and .CMD files as input and optionally creates .COM, HEX SYM and SYP files
PASLIB.ERL Searchable run-time subroutine library in relocatable form. Always linked last.
FPREALS.ERLSoftware floating point support routines. This is a library which contains software floating point routines and REALIO.ERL. Searchable and must be linked just before PASLIB.
TRANCEND.ERLTranscendental function support (for software floating point only).
BCDREALS.ERLBusiness arithmetic support routines (does not include square root or trancendentals).
DEBUGGER.ERLRelocatable code for symbolic debugger (linked as main program when used).
DEBUGHELP.TXTContains a summary of debugger commands.
DIS8080.COMDisassembler program. Takes .PRN and .ERL files as input and outputs intermixed listing file to file, console or printer. Also handles Z80 instructions generated by the compiler. Only usable for Pascal programs, not a general purpose disassembler.
LIBMT.COMLibrarian program which inputs .BLD and .ERL files to create searchable libraries OR L80 compatible modules.
FULLHEAP.ERLComplete new and dispose, with garbage collection and heap management routines in relocatable form. PASLIB contains UCSD-style stack heap routines. This module must be linked before PASLIB to use these routines.
ROVLMGR.ERLOverlay manager assembled with the RELOAD option TRUE.
CALC.SRCSample program for testing floating point. Useful when using AMD9511 hardware to insure proper operation of the 9511.
REALIO.ERLRead and Write real routines for floating point necessary only when using AMD9511 hardware floating point routines.
AMDIO.SRCModule containing routines which interface to the AMD9511. User must edit and recompile to customize for specific hardware requirements.
FPRTNS.ERLSupport routines for AMD9511 hardware floating point
TRAN9511.ERLModule containing 9511 drivers for transcendental functions only for use with hardware floating point
AMD9511.CMDLinker command file including AMDIO, FPRTNS, REALIO and TRAN9511
AMD9511X.CMDLinker command file including just AMDIO and FPRTNS
UTILMOD.ERLModule which contains KEYPRESSED, RENAME and EXTRACT utility subroutines.
RANDOMIO.ERLRandom I/O routines which are compatible with sequential files.

The following run-time library subroutines are provided in source code form. Some of these are supplied to allow users who are running without an operating system, e.g., without CP/M, to properly interface to their hardware. Others are provided so that the user may change the action of the routines as they are performed in PASLIB. These routines are identical or functionally compatible with the routines in PASLIB.ERL. Nearly all are supplied in Pascal module form so that users will not require an assembler to implement ROM based programs in most cases.

PINI.SRCInitialization routine
CPMRD.SRC Used by Read string routine (@RST) Included because it uses CP/M direct BDOS call.
HLT.SRC"halt" routine. Current routine calls CP/M.
CHN.MACChaining routine. May be changed to do bank switching, etc. as desired in a non-CP/M environment. As this is fairly special it is supplied in assembly code. NOTE: MOST ROM BASED SYSTEMS WILL NOT USE CHAIN AND THEREFORE THE USER NEED NOT HAVE AN ASSEMBLER TO CREATE A ROM BASED SYSTEM!
RNC.SRCContains read next character routine.
WNC.SRCContains write next character routine.
DIVMOD.MACSource for DIV and MOD routines which include a direct call to CP/M for divide by 0 error message.
FIBDEF.LIBInclude file for PINI, RNC and WNC. Definition of the file control block.
OVLMGR.MACOverlay manager. User selectable options to allow more overlays or to allow overlays to call overlays. Unmodified version already in PASLIB.
IOERR.SRCSample routine for user-handled I/O errors.
XBDOS.SRCBDOS routine which contains calls to IOERR.
IOCHK.BLDFile to be used to create I/O error library.
RST.MACRead string routine.
CWT.MACWait for end-of-line routine.
GET.SRCLow level input routine.
PUT.SRCLow level output routine.
@RNB.SRC Read next byte routine.
@WNB.SRC Write next byte routine.

1.6 MINIMUM CONFIGURATION

The files listed below are the absolute minimum required to operate the Pascal/MT+ compiler. They need not all be present on the same disk but all need to be on-line. Additional files such as the linker and libraries may be on the same disk but are not necessary to operate the compiler. The MTPLUS.006 overlay is only necessary to use the debugger and otherwise need not be on-line.

FILESIZE
MTPLUS.COM35kexecutable compiler
MTPLUS.00013kroot program, calls overlays
MTPLUS.00111k}
MTPLUS.002 7k}
MTPLUS.003 8k}overlays for compiler
MTPLUS.00417k}(always required)
MTPLUS.005 8k}
MTPLUS.006 6konly necessary if debugger requested

The total size required is 92k, or 86k if debugger is not requested. These numbers are subject to change without notice. If you cannot fit all of the above files onto one disk there is a method by which the root and overlay files may reside on another on-line disk. This is done by using a compiler command switch which informs the compiler that the root and overlays are on a different drive. See Section 2.2.2.

The minimum files required to link a program are:

LINKMT.COM11klinker
PASLIB.ERL19kRun-time support library

Other .ERL files may be required if calls are made to them from a Pascal program. See Section 2.3 on the linker which contains the list of .ERL files supplied and which ones are required to be linked into your program to resolve references.

If you have room, the ideal configuration is to place all of the above files plus MTERRS.TXT (the error message text file) on one disk. The data can be on the same disk if there is room, or on a second online disk.