HP OpenVMS Systems

Content starts here

Compaq BASIC for OpenVMS
Alpha and VAX Systems
Reference Manual

Previous Contents Index

C.2.9 Error Handling Semantics

To achieve the most efficient performance, the Alpha BASIC compiler may reorder the execution of arithmetic instructions. Rarely does this result in error handling semantics that are incompatible with VAX BASIC; most programs are not affected by this change.

Use the Alpha BASIC /SYNCHRONOUS_EXCEPTIONS qualifier for those programs that require exact VAX BASIC behavior.

C.2.10 Generation of Object Modules

In Alpha BASIC, the default behavior places all routines (SUBs, FUNCTIONs, and main programs) compiled within a single source program into a single module in the object file. VAX BASIC generates each routine as a separate module. Use the Alpha BASIC /SEPARATE_COMPILATION qualifier to duplicate VAX BASIC behavior. See the information on qualifiers on the BASIC command line in the Compaq BASIC for OpenVMS Alpha and VAX Systems User Manual.

C.2.11 RESUME and DEF

VAX BASIC does not enforce the documented restriction that a RESUME statement lexically outside a DEF statement (without a target specified) cannot resume program execution within a DEF statement. Alpha BASIC enforces this restriction at run time.

C.2.12 Exceptions

When the Alpha BASIC compiler determines that the result of an expression is never used, the compiler does not generate code to evaluate that expression. This causes an incompatibility with VAX BASIC if the removed expression causes an exception. In the following example, the program generates a divide-by-zero error in VAX BASIC. It runs without error in Alpha BASIC because Alpha BASIC, recognizing that the variable A is never used, does not generate code to evaluate the expression that is assigned to A:

      B = 5
      A = B / 0

C.2.13 Compiler Message Differences

There is a small difference in the way compiler messages are reported. In VAX BASIC the source information appears before the message text, and includes both source and listing line numbers. In Alpha BASIC the source information appears after the message text and includes only source line numbers.

When the Alpha BASIC compiler reports source line information, the message looks like:

%BASIC-E-xxxxxxxxx, xxxxxxxxxxxxx at line number YY in file xxxxxxxxxxx

In both Alpha BASIC and VAX BASIC, the reported line number is the physical source line in the file. It is not the BASIC line number that might occur in the source program.

C.2.14 Error Status Returned to DCL

When errors occur, the Alpha BASIC and VAX BASIC compilers at times return a different status to DCL. For example, when the file specified at the DCL command line cannot be found, Alpha BASIC returns BASIC--F--ABORT; VAX BASIC returns BASIC--F--OPENIN.


In Alpha BASIC, when you specify SYS$INPUT as the input file specification at the DCL command line, the object file and the listing file are named differently from VAX BASIC. In Alpha BASIC, the compiler names the files with the file types .OBJ and .LIS (with nothing preceding). In VAX BASIC, the compiler names the files NONAME.OBJ and NONAME.LIS.

C.2.16 FSS$ Function

The VAX BASIC compiler compiles a program that uses the FSS$ function, but if the FSS$ function is invoked at run time, the following run-time error is generated:

%BAS-F-NOTIMP, Not implemented

The Alpha BASIC compiler reports all uses of the FSS$ function by generating the following error at compile time:

%BAS-E-BLTFUNNOT, built-in function not supported

C.2.17 BAS$K_FAC_NO Constant

The BAS$K_FAC_NO constant is not defined on OpenVMS Alpha systems. You should replace all occurrences of the EXTERNAL LONG CONSTANT BAS$K_FAC_NO with EXTERNAL LONG CONSTANT BAS$_FACILITY. OpenVMS VAX systems use the constant BAS$K_FAC_NO to communicate the facility number between SYS$LIBRARY:BASRTL.EXE and SYS$LIBRARY:BASRTL2.EXE; it is not needed on OpenVMS Alpha systems.

C.2.18 Math Functions with Different Results

Some math function results differ between Alpha BASIC and VAX BASIC, because underlying OpenVMS Alpha system routines use improved algorithms to perform these operations.

C.2.19 Floating Point Errors

Some programs that run successfully on OpenVMS VAX systems may fail on OpenVMS Alpha systems with division by zero or other floating-point errors. Examine your failing program for a dirty floating point zero. A dirty floating point zero is a number represented by a zero exponent and a nonzero mantissa. Most OpenVMS VAX system instructions treat the invalid floating-point number as a zero, but it causes an exception to be generated by some OpenVMS Alpha instructions.

You cannot create a dirty zero by using BASIC arithmetic expessions. You can create a dirty zero by reading it from a file. BASIC I/O statements, such as GET and MOVE FROM, move bytes of data to a variable without checking that the data is valid for the variable.

Correct the problem in one of the following ways:

  • Determine how the dirty zero was created and make the correction. This is the preferred way.
  • Write a routine to clean any floating-point numbers that receive a dirty zero value.

The following is an example of a routine that cleans a single precision floating-point number (you can write similiar routines to clean double or G-floating numbers):

     MAP (OVER) WORD W1,W2
     B = A
     IF (W1 AND 32640%) = 0% THEN
            A = 0
     END IF

The routine accepts a floating-point number, checks for a zero exponent, and clears the mantissa. It redefines the floating-point number as an integer so that the proper bits are tested.

For more information on floating-point formats and dirty zeros, see the Alpha Architecture Reference Manual.

C.2.20 Error Detection on Illegal MAT Operations

Following are two differences in error detection on illegal MAT operations:

  • Alpha BASIC correctly reports ILLOPE (Error 141 - Illegal operation) if an attempt is made to perform matrix multiplication when the destination matrix is identical to either source matrix. VAX BASIC does not correctly detect and report the ILLOPE message if an attempt is made to perform the following matrix multiplication, where B is a virtual array, and A is either a virtual array or an in-memory array:

    MAT B = A * B
  • Under certain conditions, VAX BASIC does not enforce the documented restriction that arrays used in MAT operations must have zero lower bounds. Alpha BASIC always reports either a LOWNOTZER error at compile time, or a MATDIMERR error at run time, when attempting to perform MAT operations on arrays with nonzero lower bounds.

C.2.21 Debugging Differences

There are debugging differences between VAX BASIC and Alpha BASIC, especially during use of the debugger STEP command around exception handlers, DEF functions, external subprograms, and GOSUB routines.

These differences are described below and in the Compaq BASIC for OpenVMS Alpha and VAX Systems User Manual.

When the debugger STEP command is used in source code containing an error, differences occur in the Debugger behavior between OpenVMS VAX and OpenVMS Alpha. These differences are due to architectural differences in the hardware and software of the two systems.

In Alpha BASIC, a STEP at a statement that causes an exception might never return control to the debugger. The debugger cannot determine what statement in the BASIC source code will execute after the exception occurs. Therefore, set explicit breaks if you use STEP on statements that cause exceptions.

The following hints should help when you use the STEP command to debug programs that handle errors:

  • When you STEP at a statement that takes an error, the debugger will not regain control unless the program reaches an explicit breakpoint or the next statement that would have executed if no error had occurred. Set explicit breaks if you want the program to stop in any other place.
  • Use of the STEP command at a statement that takes an error does not return control to the debugger when the program reaches the error handler code. If you want the program to break when program execution enters an error handler, explicitly set a breakpoint at the error handler. This applies to both ON ERROR handlers and WHEN handlers.
  • If you are within a WHEN handler, a STEP at a statement that terminates execution within the WHEN handler (CONTINUE, RETRY, END WHEN, END HANDLER, EXIT HANDLER) will not stop unless program flow reaches a point where an explicit breakpoint is set.
  • A STEP at a RESUME statement in an ON ERROR handler stops program execution at the first line of non-error-handler code.
  • Use SET BREAK/EXCEPTION at the beginning of the debugging session to prevent unexpected errors from occurring. This breakpoint is not necessary if you have set explicit breakpoints at all error handlers. However, use of this command will break at all exceptions, allowing you to check that you have the proper breakpoints to stop program execution following the exception.

C.2.22 Listing File Differences

Following are differences in listing files between Alpha BASIC and VAX BASIC:

  • /MACHINE/LIST - In VAX BASIC, if you specify BASIC/MACHINE, you get a listing file containing a machine language listing but no source code listing. In Alpha BASIC, if you specify BASIC/MACHINE, you do not get either listing. You must specify /LIST to get listing files. In Alpha BASIC, specifying /MACHINE/LIST gives you both the machine language and the source code in the listing file.
    When VAX BASIC creates a listing file for a program with more than one routine, it places the machine code for each routine after the source code for that routine. The listing file produced by the Alpha BASIC compiler contains the source listing for all the routines followed by the machine code listing for all the routines, unless you use the /SEPARATE_COMPILATION qualifier.
  • %PAGE - In Alpha BASIC, the %PAGE directive appears on the page following the page break. In VAX BASIC, the %PAGE directive appears on the page before the page break.
  • %TITLE and %SBTTL strings - These are truncated at 31 characters in Alpha BASIC, and 45 characters in VAX BASIC.
  • Form feeds - VAX BASIC treats form feeds as %PAGE directives. Alpha BASIC does no special processing with form feeds. When a form feed occurs in the source file, that form feed occurs in the listing file, but no listing header information accompanies the form feed.
  • /SHOW=MAP qualifier - The following differences occur in Alpha BASIC when you use the /SHOW=MAP qualifier:
    • Alpha BASIC leaves the offset field in the allocation map blank in cases where the values are not applicable, or not available to the listing phase.
    • In dynamic maps of arrays, VAX BASIC reports the size of the array descriptors; Alpha BASIC reports the size of the array.
  • Message placement - The placement of some error messages in the listing file may differ between VAX BASIC and Alpha BASIC. For example, in Alpha BASIC, errors that require flow analysis such as "unreachable code" and "routine can never be called" appear in the listing after the source code and allocation map listing. In listings for source files that contain more than one routine, these errors appear after the source and allocation listing for all routines in the compilation, unless the /SEPARATE_COMPILATION is specified.

C.3 Common Language Environment Differences

This section describes differences between Alpha BASIC, VAX BASIC, and other languages within the common language environment.

C.3.1 Creating PSECTs with COMMON and MAP Statements

In Alpha BASIC, the PSECT attributes are different from those in VAX BASIC, as follows:

Alignment of OCTAWORD Alignment of LONG

In Alpha BASIC, the lengths of the PSECTs that the COMMON and MAP statements create are rounded up to a multiple of 16. The size of COMMON or MAP does not change; the size of the PSECT does. This change is visible only to applications that use shareable images in a multilanguage environment.

Both Alpha BASIC and VAX BASIC create PSECTs that are compatible with those of other languages on the same platform, with the exception of MACRO. You can link with modules written in languages other than MACRO without changing code. If you link against MACRO modules that reference these PSECTs, you may need to make corresponding changes in the MACRO code.

C.3.2 64-Bit Floating-Point Data

In most other Compaq languages, the default 64-bit floating-point data type has changed from D_floating on OpenVMS VAX systems to G_floating on OpenVMS Alpha systems. If you communicate BASIC DOUBLE (OpenVMS D_floating) data between BASIC and one of the other languages that have made this change, you need to do one of the following:

  • In the compiler command line of the other language, change the 64-bit floating-point data type to D_floating to match the behavior of Alpha BASIC.
  • In your BASIC program, change the data type of the 64-bit floating-point data from DOUBLE to GFLOAT to match the other language.

C.4 LIB$ROUTINES and BASIC$STARLET.TLB Routines Unsupported by Alpha BASIC

Direct use of the following routines by Alpha BASIC programs is unsupported. Attempts to execute any of these routines will result in an error.



In STARLET module:


Index Contents