• Keine Ergebnisse gefunden

The Pascal-86 Language

Im Dokument PASCAL-a6 USER'S GUIDE (Seite 22-25)

1. 1 Product Definition

1.2 The Pascal-86 Language

1.2. 1 Using a High-Level Language

High-level languages (Pascal in particular) more closely model the human thought process than do lower-level languages, such as assembly language. They therefore are easier and faster to write, since one less translation step is required from concept to code. High-level language programs are also more likely to be correct, since there is less occasion to introduce error.

Programs in a high-level language are easier to read and understand, and thus easier to modify. As a result, you can develop high-level language programs in a much shorter period of time, and these programs are easier to maintain throughout the life of the product. Thus high-level languages result in lower costs for both development and maintenance of programs.

In addition, programs in a high-level language, particularly a standardized language like Pascal, are easily transferred from one processor to another. Programs that can be transferred between processors without modification are said to be portable.

Overview

1-2

Pascal-86 User's Guide

As you might expect, these advantages have a price: the resulting translated machine programs normally require more memory space and may run more slowly. For this reason, after the initial software design is complete, you may wish to re-code your most time-critical and space-critical routines in assembly language.

If Pascal-86 is your first high-level language, you probably want to know how programming in a high-level language differs from assembly-language programming.

When you use a high-level language:

• You do not need to know the instruction set of the processor you are using.

You need not be concerned with the details of the target processor, such as regis-ter allocation or assigning the proper number of bytes for each data item-the compiler takes care of these things automatically.

• You use keywords and phrases that are closer to natural English.

• You can combine many operations (including arithmetic, Boolean, and set opera-tions) into expressions; thus you can perform a whole sequence of operations with one statement.

• You can use data types and data structures that are closer to your actual problem;

for instance, in Pascal you can program in terms of Boolean variables, charac-ters, arrays, and files rather than bytes and words.

The introductory example at the end of this chapter (section 1.7) illustrates these points. Compare this Pascal program with an assembly-language program you might write to solve the same problem.

Coding programs in a high-level language involves thinking at a different level than coding in assembly language. This level is closer to the level of thinking you use when you are planning your overall system design.

1.2.2 Why Pascal?

Many high-level programming languages are available today; some of them have been around far longer than Pascal. So once you have decided to use a high-level language, your next questions may be: How does Pascal differ from other high-level languages?

What advantages does it have? When is it the right language to use?

Here are some of the characteristics of Pascal:

• It has a block structure similar to that of PL/M, plus control constructs that aid-in fact, encourage and enforce-structured programming.

• It includes facilities for such data structures as multi-dimensional arrays, records, sets, files, and pointer-based dynamic variables, and also allows you to define new data types related to your problem, e.g., weekday, patientrecord.

• It is a strongly typed language-that is, the compiler does extensive data type compatibility checking and range checking to help you detect logic errors in your programs at compile time.

• It includes run-time support for sequential file I/O and floating-point arithmetic.

Its data structuring facilities and control statements are designed in a logically consistent way. Thus Pascal is a particularly good language for expressing algorithms, and has been used for this purpose in many textbooks.

Its control constructs make program correctness relatively easy to verify.

• It is a standard language used on many computers, so Pascal programs are portable.

Pascal-86 User's Guide

For iAPX 86 and 88 systems, Intel offers Pascal, PL/M, and FORTRAN. Your choice among these should depend on your implementation. Pascal-86, with its run-time I/O support, data-structuring facilities, user-defined types, and special-purpose built-in procedures and functions, is a higher-level language than PL/M-86, and is therefore better suited to applications programming. Pascal-86 also provides more extensive type checking than either PL/M-86 or FORTRAN-86, thus reducing program debugging time. Because Pascal is a standard language, programs in Pascal are portable they can be used on a number of different processors. On the other hand, PL/M-86 allows you to program at a level closer to your microprocessor hardware, making it generally more suitable for systems programming, while FOR TRAN-86 has a rich set of arithmetic operations which make it best suited to scientific and numerical applications.

The philosophy behind the Pascal and PL/M languages is fundamentally different.

Pascal's strong typing and other language features impose a strict discipline on you, the programmer, to enforce good structured programming practice and help you detect errors in your programs. Certain programming practices that make errors hard to find - such as defining one data type on top of another - are forbidden in Pascal.

PL/M, on the other hand, was designed for programmers (generally systems programmers) who need such features and are willing to take the risk and extra debugging time required by programs that use them.

What about the differences between Pascal and older, better-established languages like BASIC and COBOL Pascal has many more features than BASIC; and thanks to more consistent standardization, it is also more portable. It is a more general-purpose language than COBOL, which is tailored for business data processing. In addition, Pascal differs from these other languages in its strong typing and block structure.

Pascal was designed in 1973 by Niklaus Wirth, who had two main objectives: to produce a language suitable for teaching programming concepts, and to design that language so that its implementations on existing computers could be reliable and efficient. Wirth found the more traditional languages (including FORTRAN, COBOL, and PL/I) unsuitable for teaching: their features and constructs often cannot be explained logically, making them more difficult to learn.

Even more important, he was convinced that the language in which a programmer learns to program profoundly influences his thinking, and therefore his programming style and his reasoning in problem solving. He concluded that teaching programming using a logically constructed language can lead to better programmers and better programs.

Pascal's principles of structuring and form of expressions were patterned after those of Algol 60. However, other constructs were changed from Algol to accommodate Pascal's additional data structuring facilities. Record and file structures more useful for solving commercial-type problems were added to Pascal.

1.2.3

Portability

As mentioned earlier, Pascal-86 conforms to standard Pascal as defined in the ISO Draft Proposal. This means that you can take Pascal programs written for other processors, compile them using Pascal-86, and run them on an iAPX 86 or iAPX 88 microcomputer system, provided you use only standard features. The same programs can run on iAPX 86 systems and iAPX 88 systems without change.

Overview

Overview

1-4

Pascal-86 User's Guide

You can write complete programs in Pascal-86 without using any Intel extensions to standard Pascal, thus keeping your programs completely portable. In this manual, the descriptions of Intel extensions are shaded in gray to distinguish them from stan-dard features. You can also use a compiler option (the NOEXTENSIONS control) to direct the compiler to print out warning messages wherever such extensions appear in your program.

1.2.4 Intel Extensions to Standard Pascal

If you are concerned with the ease of programming for your microprocessor applica-tions, you will probably want to use the language extensions and compiler controls that tailor Pascal-86 to the iAPX 86, 88 environment. These include 32-bit arithme-tic, language constructs for building separately compiled modules, and builtin proce-dures for port input/output and interrupt control.

Separately compiled modules allow you to divide a program into smaller, more manageable parts, and to locate different parts of your program in memory of differ-ent types or in differdiffer-ent hardware locations. Port input/output provides fast data transfer by means of direct communication with microprocessor ports. The interrupt control procedures allow you to write Pascal routines to handle interrupts in your system.

Im Dokument PASCAL-a6 USER'S GUIDE (Seite 22-25)