HP 3000 Manuals

LANGUAGES [ COMMUNICATOR 3000/XL Release 1.2, Version A.20.10 ] MPE/iX Communicators


COMMUNICATOR 3000/XL Release 1.2, Version A.20.10

Chapter 4  LANGUAGES 

Introducing the Packed-Decimal Library 

by Walter Murray--Data & Languages Division/CLL 

Beginning with MPE XL Release 1.2, the MPE XL Compiler Library includes a
group of procedures for performing operations on packed-decimal data.

Procedures are provided for performing basic operations on packed-decimal
numbers, including arithmetic operations, comparisons, left and right
shifts, and conversions to and from binary and external decimal formats.
Replacements are also provided for LONGDIVD and DIVD, the decimal
division routines which are part of the compiler library under MPE V/E
but not under MPE XL.

The procedures can be declared as intrinsics and can be called from
high-level languages such as Pascal, C, and FORTRAN. They run entirely in
native mode.

The typical user of the packed-decimal procedures is the programmer who
is migrating from SPL/3000 or a mixed Pascal/SPL environment into Pascal
or C, with the intention of running in native mode.  The application is
one which used the SPL/3000 ASSEMBLE statement to invoke the Classic HP
3000's (3x - 7x) decimal instructions.

To make migration as straightforward as possible, the new routines
closely parallel the corresponding instructions on the Classic HP 3000.
In virtually all applications where packed-decimal operations are
performed in SPL/3000, it is possible to replace SPL ASSEMBLE statements,
on a one-for-one basis, with calls to the new procedures, with no need to
change algorithms or data structures.  These procedures permit the same
operand lengths, formats, and alignments as the Classic HP 3000.  They
follow the same conventions concerning interpretation of the sign nibble
and the treatment of invalid digits.  The handling of traps is very
similar to that under MPE V/E.

This example shows how a subtraction operation might be translated.

     In SPL/3000:                    In Pascal/XL:

     TOS := @PAY'AMT;                PROCEDURE HPPACSUBD; INTRINSIC;
     TOS := 9;                       .
     TOS := @DEDUCTIONS;             .
     TOS := 7;                       HPPACSUBD (PAY_AMT, 9,
     ASSEMBLE (SUBD);                           DEDUCTIONS, 7);

The procedures are also suitable for use in new programs being developed
under MPE XL. Since the sizes of the operands are passed as parameters,
these procedures can be used in applications where the field sizes are
not known at compile time, as in general-purpose data base applications
and report writers.

The packed-decimal procedures are documented in the latest edition of the
Compiler Library/XL Reference Manual (P/N 32650-60014).



MPE/iX Communicators