HP 3000 compilers are not normally bundled with MPE/iX; they usually
must be purchased separately from Hewlett-Packard. There is one exception
to that rule, however--the HP 3000 S/918dx, a low-cost platform especially
for developers (see the sidebar). All the currently supported compilers
are bundled with this platform.
HP 3000 compilers are available for many popular computer languages,
including COBOL, C, FORTRAN, and many others.
Commands to Compile, Link, and Execute Programs
HP 3000 compilers are invoked using MPE commands.
Table 1
shows the commands that are used to invoke many of the HP compilers
that have been offered for the HP 3000 over the years.
For most languages, there are two separate compilers listed: a native-mode
(NM) compiler and a compatibility-mode (CM) compiler. The reason for two
compilers is that there are really two HP 3000 architectures. The earliest
models (sometimes called the "classic" systems) were based on
a 16-bit CISC architecture and had two-digit model numbers (e.g., Series/70).
HP stopped selling these "classic" HP 3000s in the late 1980s
and is now dropping support for MPE V software. All models of the HP 3000
sold since then have a three-digit "9xx" model number and are
based on HP's PA-RISC architecture.
The native-mode (NM) compilers listed in Table 1 generate binary machine
instructions that can be executed only on PA-RISC models of the HP 3000.
The best performance and application scalability are available in native
mode.
The compatibility-mode (CM) compilers generate binary machine instructions
that were designed to be used on the older 16-bit "classic" machines.
CM machine instructions were designed to be executed on older 16-bit machines.
Using the CM emulator, however, you can execute programs compiled with
a CM compiler on the newer PA-RISC systems.
Most of the languages shown in Table 1 are supported in both CM and
NM versions. A few (such as SPL) are available only in CM. SPL is the system
programming language for the "classic" systems, and as such is
supported only in CM.
A few others (C, COBOL 85) are available only in NM. Because these compilers
were developed for the HP 3000 only after HP stopped selling the older
16-bit machines, they are not supported on the older architecture.
The C++ compiler is part of the GNU Tools Binary Distribution, which
was ported to MPE/iX by Mark Klein. It is available from HP at no charge.
For more information on the HP 3000 implementation of C++, go to the HP
3000 jazz site at
//jazz.external.hp.com/.
Note that there are at least three (and in a few cases four) commands
associated with each compiler.
There is a command used simply to compile a program. This command creates
object files (or in the case of the CM compilers, USL files).
There is a command used to compile and link (or in the case of CM compilers,
PREP) a program. This commands an executable native-mode program file (or
in the case of CM compilers, an executable CM program file).
There is a command used to compile, link (or prep), and execute a program.
In the case of BASIC, there is also a fourth command to run the BASIC
interpreter.
COBOL Compilers
Since most HP 3000 applications are written in COBOL, we'll focus on
that language. COBOL has been around for a long time. If you're going to
develop software in COBOL, chances are that you're maintaining an existing
older application, rather than writing a new one. If that's the case, you
probably should try to find out what version of the COBOL compiler was
used to do the original development. A number of different COBOL compilers
have been used with the HP 3000 over the years.
The oldest one that you are liable to encounter today is compliant with
the 1968 ANSI standard for COBOL. It was originally offered on the old
16-bit models of the HP 3000. The COBOL 68 compiler isn't supported on
MPE/iX. However, most applications that were written to the COBOL 68 standard
easily can be made to compile cleanly on more modern compilers. Today,
HP provides compiler support for both the 1974 and 1985 ANSI COBOL standards.
In addition to the HP COBOL compilers, at least two leading third-party
COBOL compilers have been ported to MPE/iX from the UNIX environment. Used
to port UNIX applications to MPE/iX, these include MicroFocus (see
//www.acucobol.com/Products).
The discussions in this article are relevant only to the HP compilers.
Most HP 3000 applications running today were compiled using the 1974 or
1985 standard HP COBOL compilers. If you're using a compiler from another
company, you should contact that company for more information and instructions.
Invoking the Compiler
You invoke the HP compilers using MPE commands. Table 1 contains a complete
list of HP compiler commands. To use these commands, you'll need to have
an HP 3000 logon that has access to a colon prompt (see Part 1 of this
series of articles in the June 1997 Interact). The file containing
your source code must be accessible from your logon (see the security discussion
in Parts 5-7 of this series, November 1997-January 1998 Interact).
Let's look at some examples.
Suppose that on your HP 3000 you've created a file called MYPROGS and
it contains COBOL '74 source code. You can compile it using the command
:COBOLII MYPROGS,MYPROGU
This command invokes the 1974 standard compatibility-mode compiler.
Keep in mind that the above command will work properly only if you have
the COBOL II compiler installed on your HP 3000. If your company has not
purchased the COBOL II compiler, the command will fail.
Notice the parameters we supplied to the COBOL II command. The first
parameter is the name of the file that contains the source code (MYPROGS).
Strictly speaking, this parameter isn't required (you can leave it off
if you like), but you won't want to. The example in Figure 1 should explain why.
Figure 1: Common compiler "Gotchas"
Typing a compiler command all by itself, with no parameters, tells the
compiler to read your source code from a default input file called $STDIN.
This is the name MPE/iX assigns to the standard input device for your session--that
is, to your terminal keyboard. The net effect is that the compiler expects
to read COBOL source code from your terminal. Anything that you type
from this point forward will be interpreted as if it were COBOL!
In case you get yourself into this situation, here's how you can stop
the compiler. Press the <BREAK> key, as shown in Figure 1, to interrupt
the compiler and display another colon prompt. Now type the command :ABORT
to abort the compiler and return you to your session.
Compiler Output
In Figure 2, we're using the COB85XL command
to compile a very simple "hello world" program. The source code
was written in COBOL and is being compiled using the 1985 ANSI standard
NM compiler.
Figure 2: Using the COB85XL Command
The first parameter we supplied to the COB85XL command is the name of
the file where we put the source code: MYPROGS. The second parameter is
also a filename: MYPROGO. The second parameter tells the compiler what
name to assign to the object file that will contain its binary output.
If there is no file called MYPROGO, the compiler will automatically create
one. If a file by this name did exist, the compiler would reuse
it.
The example also shows how to identify object files. Enter the :LISTFILE
command with the "2" option. This command is used to display
one line of technical information about your files, including the file
code. Every MPE file has a file code, which can be displayed by :LISTFILE
under the heading "CODE", as shown in Figure 2. MPE uses the
file code to identify what kind of file this is. Object files are easily
identified because they bear the file code "NMOBJ."
While the compiler is processing your source code, it will generate
a listing of your program. This listing is written to $STDLIST.
By default, this name is associated with your terminal display, so it will
go scrolling by on your terminal screen (probably too fast for you to read).
If you want the listing routed to a file (instead of to your terminal),
its name can be specified as a third parameter to the compiler command.
Later in this series, we'll explain how file equations can be used
to route program output (including compiler output) to other devices, such
as printers.
The Linkage Editor
Object files are not finished executables. In Figure 1, MYPROGO contains
the machine instructions that correspond to the COBOL statements in MYPROGC.
But before this program can be executed, it must be linked with other machine
instructions stored in the MPE system libraries. This is done using a software
tool called the linkage editor. To link MYPROGO, you can use the link command,
as shown in Figure 3.
Figure 3: The link command
The LINK command tells the MPE linkage editor to read the object file
called MYPROGO, link any necessary routines from the native-mode system
library, and store the results in an MPE program file called MYPROG. The
native-mode system library resides in a file called XL.PUB.SYS. Later,
we'll see that there is also a CM system library called SL.PUB.SYS in the
same group.
If no errors have been displayed, then MYPROG will be an executable
HP 3000 program. The :LISTFILE command can be used to identify native-mode
program files. These files will have a filecode of NMPRG. The :RUN command
can be used to execute native-mode program files such as MYPROG. The example
in Figure 3 shows MYPROG being executed and displaying the messages we
called for in the source code.
Compatibility Mode
The output of the MPE/iX linkage editor is called a native-mode program,
because the machine code it contains executes natively on PA-RISC processors.
Many HP 3000 applications were originally developed for the older 16-bit
models of the HP 3000. In order to make it easier for customers to migrate
their older applications on to the PA-RISC based systems, HP provided customers
with three different kinds of help.
The first, an emulator for the old 16-bit environment, was bundled with
MPE/iX. This made it possible to execute many 16-bit binaries on the PA-RISC
HP 3000 without needing to rewrite or recompile the application. Using
this emulator is called executing a program in compatibility mode (CM).
The second way HP helped was by making many of the 16-bit compilers
available on MPE/iX. These compatibility-mode compilers generate 16-bit
machine instructions that could be executed on older 16-bit machines or
on newer PA-RISC machines. Having the compilers available on the newer
hardware made it possible for customers to maintain 16-bit applications
that could be run on any HP 3000 systems (old or new).
Third, HP provided native-mode (NM) compilers for PA-RISC machines,
making it possible to obtain the full performance and scalability of PA-RISC.
To make it easy to migrate 16-bit applications to native mode, HP designed
the NM compilers to have a high degree of compatibility with the corresponding
compatibility-mode compilers. In many cases, 16-bit applications could
be compiled using the NM compilers without any need to change the source
code. Figure 4 shows how compatibility-mode compilers
can be used to create CM programs on an MPE/iX machine. The COBOLII command
tells the system to use the CM COBOL compiler.
Figure 4: Using compatibility-mode compilers
The binary output of a CM compiler is quite different from the object
files created by the NM compilers. The CM machine instructions generated
by the CM compilers are stored in a "User Subprogram Library"
(or USL, for short). USLs are then processed by the PREP command. The PREP
command links the contents of the USL with the compatibility-mode system
library (stored in a file called SL.PUB.SYS) to create a compatibility
mode program file.
In the example shown in Figure 4, the USL called MYPROGU is being processed
by the PREP command. Just as the Linkage Editor creates NM programs from
object files, the PREP command creates CM programs from USL files. In the
example, the file MYPROGCM is a CM program. CM programs can easily be identified
using the :LISTFILE command by their filecode, which is PROG.
In the example in the figure, we used the :RUN command to execute MYPROGCM,
and the program behaved exactly like the NM program we saw earlier. Note
that we didn't have to do anything special to execute the CM program. The
RUN command can be used with any type of binary executable: CM or NM.
When you run an HP 3000 program, MPE/iX looks at the filecode of the
program you specify. If it finds a filecode of "NMPRG", then
it knows that you're calling for the execution of a native-mode program.
So, MPE/iX executes it natively.
If MPE/iX finds a filecode of PROG, it knows this is a 16-bit "classic"
program. This causes MPE/iX to run the emulator automatically. The emulator
then reads the compatibility-mode program as data and executes the program
instructions in compatibility mode.
It should come as no surprise that running a program in compatibility
mode can create significant overhead. Therefore, it's generally a good
idea to migrate compatibility-mode programs to native mode. Most MPE/iX
applications today have been migrated to native mode. Those that remain
in compatibility mode are often left that way because the source code has
been lost or because the application is considered not to be performance-critical,
and therefore not worth migrating.
In this month's article I have covered some of the basic concepts of
program development on the HP 3000. So far, we've looked at ways that simple
programs can be compiled and executed. Of course, real commercial applications
are often far too complex to place in a simple source file like the one
we saw earlier in this article. Therefore, they are usually broken up into
several subprograms, each of which can be compiled separately, sometimes
by different people. In the next part in this series, we'll begin examining
how this can be done on the HP 3000 using a variety of types of libraries.
George Stachnik, the director of Hewlett-Packard's Technology Closeup
series of television broadcasts, holds the title of Chief of Customer Communications.
He works at Hewlett-Packard's campus in Cupertino California.
The HP 3000 918DX Developer's Platform
Beginning in 1997, HP began marketing a specialized low-end model of
the HP 3000 for software developers. The model 918DX is a bundle of HP
hardware, HP software, and third-party software for use by commercial MPE
developers. It can be leased or purchased at an exceptionally low price.
The hardware consists of an eight-user license Series 918DX with product
number A4911A. The HP software that comes bundled with the 918DX is shown
in Table 2. In addition, a great deal of third-party
software is available for use with the 918DX. (Go to the Interex Web site for a
list of vendors and software.) But keep in mind that new development products for the HP
3000 are surfacing all the time. To get the latest information on the 918DX,
go to URL //jazz.external.hp.com/papers/91dx/faq.html.
Table 2: HP Software Bundled with the 918DX
MPE/iX Operating System
IMAGE/SQL
ALLBASE/SQL
HP Transact/iX
HP RPG/iX compiler
HP TurboStore/iX
HP COBOL II/iX compiler
HP FORTRAN 77/iX compiler
HP Pascal/iX compiler
HP C/iX compiler
HP Symbolic Debugger/iX
System Dictionary/iX
HP Business Basic/iX compiler
Architected Interfaces: Operating System
NS 3000/iX Network Services
HP SPT Collector for MPE/iX systems
SPT Analyzer
HP GlancePlus/iX
To buy a 918DX, you need to be developing (or interested in developing)
an MPE product for commercial purposes. You also must be a current member
of the Software Providers Program (SPP, formerly the PA-RISC Developers
Program) and be approved by CSY marketing. The SPP is set up to help HP
Channel Partners develop and market their solutions on HP systems. The
SPP discounts HP hardware and software, provides some consulting, and can
help with joint marketing. Their focus is mostly on Windows NT and HP-UX
platforms, but they are supporting the 918DX. The SPP is represented on
the Web at //www.hp.com/wsg/programs/partnership/partsoft.html.
You can contact the SPP by phone at (800) 249-3294 in the U.S. and Canada.
European and international developers can reach the SPP at the phone numbers
listed on the Web at //www.hp.com/wsg/programs/partnership/software/parjoin.html#e.
All 918DX customers need to contact Adrian Hartog to get CSY approval
for the 918DX program--even if you are already an SPP member. Adrian can
be reached via e-mail at Adeian_ Hartog@ hp.com or by phone at (408) 447-4883.
In Europe, contact Michael Robinson by e-mail at Michael_Robinson@ hp.com
or by phone at +49 7031 143889.