Writing a Program

You can write a program with an y text editor or w ord processor. MPE/iX pro vides two facilities for en tering text that you can use to create a source ￿le for a program: Editor and Toolset/XL. For an overview of Editor and T oolset/XL, refer to Chapter 2, "Utilities and Tools." Since these facilities can be used for writing documen ts, memos, and programs, the output is called text ￿les. Although the source code for a program is a text ￿le, this guide refers to it as a source ￿le for program dev elopment purposes.

How to Use Intrinsics

Many programs use lo w-level, system supplied procedures or subroutines to handle recurring tasks. On MPE/iX, these are performed through a set of procedures called in trinsics, whic h are an integral part of the operating system. In trinsics are alwa ys available to any process on the system and allo w a program to gain access to system services. T asks that intrinsics provide include:

Accessing and alteration of ￿les (for example, writing to a ￿le)

Requesting of utilit y functions (for example, perform ASCII/binary n umber conversion)

Access to system resources (for example, obtain system timer information)

You can manipulate and manage processes and system resources b y means of intrinsics, provided you have the required execution privileges. Man y intrinsics return values to the caller. Most do this through parameters; some, through functional returns. Most in trinsics are coded in HP Pascal/iX (one of the systems programming languages for the 900 Series HP

3000) and are de￿ned b y a procedure declaration consisting of:

Procedure header, con taining the procedure name and t ype, procedure de￿nitions, and other information about the procedure.

Procedure body, containing executable statemen ts and declarations local to this procedure.

Intrinsics work like user-written procedures, except that the details of performing the task are invisible to you.

Note

Most intrinsics are callable from an y language supported on MPE/iX.

The MPE/iX intrinsic mechanism provides ￿exible and con venient access to intrinsic routines from various languages. In some programming languages, y ou need not (or cannot) giv e descriptions for procedures that are external to y our program. When y ou designate that an external routine is an in trinsic, the compiler uses the In trinsic Mechanism to correctly in voke the routine by:

Providing a consisten t intrinsic interface

Ensuring proper data t ype conversion

Generating proper reference parameter addresses Ensuring that the in trinsic is properly called

3-2 Program Development