HPlogo Getting Started as an MPE/iX Programmer Programmer's Guide: HP 3000 Computer MPE/iX Computer Systems > Chapter 3 Program Development

Writing a Program

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

You can write a program with any text editor or word processor. MPE/iX provides two facilities for entering text that you can use to create a source file for a program: Editor and Toolset/XL. For an overview of Editor and Toolset/XL, refer to Chapter 2, "Utilities and Tools" Since these facilities can be used for writing documents, memos, and programs, the output is called text files. Although the source code for a program is a text file, this guide refers to it as a source file for program development purposes.

How to Use Intrinsics

Many programs use low-level, system supplied procedures or subroutines to handle recurring tasks. On MPE/iX, these are performed through a set of procedures called intrinsics, which are an integral part of the operating system. Intrinsics are always available to any process on the system and allow a program to gain access to system services. Tasks that intrinsics provide include:

  • Accessing and alteration of files (for example, writing to a file)

  • Requesting of utility functions (for example, perform ASCII/binary number conversion)

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

You can manipulate and manage processes and system resources by means of intrinsics, provided you have the required execution privileges. Many intrinsics return values to the caller. Most do this through parameters; some, through functional returns. Most intrinsics are coded in HP Pascal/iX (one of the systems programming languages for the 900 Series HP 3000) and are defined by a procedure declaration consisting of:

  • Procedure header, containing the procedure name and type, procedure definitions, and other information about the procedure.

  • Procedure body, containing executable statements 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 any language supported on MPE/iX.

The MPE/iX intrinsic mechanism provides flexible and convenient access to intrinsic routines from various languages. In some programming languages, you need not (or cannot) give descriptions for procedures that are external to your program. When you designate that an external routine is an intrinsic, the compiler uses the Intrinsic Mechanism to correctly invoke the routine by:

  • Providing a consistent intrinsic interface

  • Ensuring proper data type conversion

  • Generating proper reference parameter addresses

  • Ensuring that the intrinsic is properly called

Although intrinsics usually refer to system routines, you can define routines that you want to access as if they were intrinsics and then place them in new or existing intrinsic files and libraries.

You invoke an intrinsic by calling it from within a program. In HP C/iX, HP Pascal/iX, COBOL II/XL, and HP FORTRAN 77/iX programs, you explicitly call an intrinsic. The Intrinsics Mechanism facilitates the declaration of system intrinsics. All MPE/iX intrinsics are processed as external procedures by user programs.

Before you can call an intrinsic from a program, you must declare it in all languages by using an intrinsic declaration statement. The format varies depending on the language. Refer to the appropriate language programming guides for details on how to call intrinsics. For detailed information on intrinsics and intrinsic declarations, refer to MPE/iX Intrinsics Reference Manual (32650-90028).

Feedback to webmaster