VMS / OpenVMS BASIC for x86 Intel Linux


VX/BASIC is a full-featured VMS / OpenVMS BASIC to ANSI C Compiler/Transpiler®. VX/BASIC allows VMS / OpenVMS BASIC source code to be compiled on multiple host machines. The application can be maintained in the original BASIC language or converted into C code. VX/BASIC will convert 100% of supported VMS / OpenVMS BASIC syntax to working C.

HP BASIC for OpenVMS is the latest name for a dialect of the BASIC programming language created by Digital Equipment Corporation (DEC) and now owned by Hewlett-Packard Enterprise (HPE). It was originally developed in the 1970s for the RSTS-11 operating system on the PDP-11 minicomputer. It was later ported to OpenVMS, first on VAX, then Alpha, and most recently Integrity. Past names for the product include: BASIC-PLUS, Basic Plus 2 (BP2 or BASIC-Plus-2), VAX BASIC, DEC BASIC, and Compaq BASIC for OpenVMS. Multiple variations of the titles noting the hardware platform (VAX, AlphaServer, etc.) also exist.

HP BASIC has many FORTRAN-like extensions, as well as supporting the original Dartmouth BASIC matrix operators.

line numbers are optional, unless the "ERL" function is present. It allows you to write "WHEN ERROR" error handlers around protected statements. The more traditional but less elegant "ON ERROR" statement lacks such context or scope.

One of HP BASIC's more innovative features is built-in support for OpenVMS's powerful Record Management Services (RMS). Before VAX BASIC (as it was then called), you would only get native RMS support in DEC's COBOL compiler.

History


he HP BASIC for OpenVMS product life spans a period of more than 30 years, and it has gone through many name and ownership changes in that time. It began at DEC. DEC was bought by Compaq. Compaq then merged with HP. HP then split off the owning division to HPE. It has also been ported to a succession of new platforms as they were developed by DEC/Compaq/HP. The company and/or platform name has often been included in the product name, contributing to the proliferation of names.

BASIC-PLUS[edit] Main article: BASIC-PLUS HP BASIC began as BASIC-PLUS, created by DEC for their RSTS-11 operating system and PDP-11 minicomputer. Programming language statements could either be typed into the command interpreter directly, or entered into a text editor, saved to a file, and then loaded into the command interpreter from the file. Errors in source code were reported to the user immediately after the line was entered.

Programs were stored as a .BAS source file, using the "SAVE" command. It could be "compiled" into a non-editable binary .BAC file, using the "COMPILE" command. This command did not produce true machine language programs, but rather a byte code called "tokens". The tokens were interpreted upon execution, in a manner similar to the more modern Java..

Programs were entered into the command interpreter starting with line numbers, integers from 1 to 32767. Lines could be continued onto multiple lines by using a line feed character. For ease of external editing of the source file, later versions of BASIC-PLUS also allowed the & character as a line-continuation character. Multiple statements could be placed on a single line using \ as the statement separator.

For PDP-11 systems with virtual memory (RSTS/E), address space was limited to about 64 KB. With BASIC-PLUS, about half of this was used by the combined command interpreter and run-time library. This limited user programs to about 32 KB of memory. Older RSTS-11 systems lacked virtual memory, so the user program had to fit into whatever was left of physical memory after RSTS and BASIC-PLUS took up their share. For example, on a PDP-11/35 with 32K of physical memory, running RSTS-11 V04B-17, user programs were limited to 7 KB. Large programs could be broken up into various pieces by use of the "CHAIN" instruction. Programs could chain to specific line numbers in a secondary program. The use of a shared memory section called core common also allowed programs to pass data among each other as needed; disk files could also be used but were slower.

The interpreter included a garbage collecting memory manager, used for both string data and byte-code. A running program could be interrupted, have variables examined and modified, and then be resumed. Many of the control structures used in other high-level languages existed in BASIC-PLUS, including WHILE and UNTIL. The language also supported the use of conditional modifiers on a single line. For example, the line "PRINT I UNLESS I < 10 would print the value of "I" unless I was less than 10..

BASIC Plus 2

Basic Plus 2 (BP2 or BASIC-Plus-2) was later developed by DEC to add additional features and increase performance. It used true compilation into threaded code, and wrote its output to machine language object files. These were compatible with other object files on the system, and could be assembled into libraries. A linker (the TKB taskbuilder) then created executable files from them. TKB also supported overlays; this allowed individual routines to be swapped into the main memory space as needed.

BP2 programs ran under RSX-11 or RSTS/E's RSX Run Time System. This RTS only occupied 8KB (later, 2KB) of the user's address space, leaving 56KB for the user's program. These two factors allowed individual BP2 programs to be much larger than BASIC-PLUS programs, often eliminating the need for CHAINing. Unlike BASIC-PLUS (which was only available on RSTS-11), BP2 allowed use on the RSX-11 operating system as well.

VAX BASIC and DEC BASIC

With the creation of the VAX minicomputer, DEC ported BASIC-PLUS-2 to the new VMS operating system, and called it VAX BASIC. VAX BASIC used the standard VMS calling standards, so object code produced by VAX BASIC could be linked with object code produced by any of the other VMS languages. Source code for BASIC Plus 2 would usually run without major changes on VAX BASIC.

When DEC created their Alpha microprocessor, VMS was ported to it and renamed OpenVMS. VAX BASIC was likewise ported to Alpha and renamed DEC BASIC. The BASIC interpreter was permanently dropped at this point, which meant that DEC BASIC programs could only be run as OpenVMS executables, produced by a compile followed by a link.

Compaq, HP and VSI

When DEC was purchased by Compaq in 1997/98, the products were renamed Compaq BASIC for OpenVMS VAX and Compaq BASIC for OpenVMS Alpha.

Likewise, when Compaq merged with HP in 2001/02, the products were renamed HP BASIC for OpenVMS on VAX and HP BASIC for OpenVMS on AlphaServer. HP has since built new server platforms based upon Intel's Itanium chip, and there is now a HP BASIC for OpenVMS on Integrity as well.

In mid 2014, HP sold the whole OpenVMS ecosystem to VSI (VMS Software Inc) so it should be of no surprise that the BASIC compiler was renamed VSI BASIC for OpenVMS



Learn More

VMS / OpenVMS BASIC on Linux INTRODUCTION

VX/BASIC allows developers to maintain their code in VMS / OpenVMS BASIC and Transpire the code for Linux/Windows. Using C as the intermediate language, VX/BASIC takes advantage of all the elements of C compilers and object code optimizers. By generating ANSI C, users of VX/BASIC are assured that no matter how chip technology changes, the Transpiled code can be compiled.

VX/BASIC retains the original structure, variable names and comments, thus, developers can choose any time to move to C and maintain the source code in C, or retain all the investment in VMS / OpenVMS BASIC and Transpire for the target hardware platform. For VMS / OpenVMS BASIC developers, compiling the VMS / OpenVMS BASIC is only half the story. Most VMS / OpenVMS BASIC programs use VMS system service calls (implicitly for RMS or explicitly). Sector7 has developed more than 900 VMS system service calls (VX/RT API's) for Linux/Windows.

VX/BASIC MAPS and RECORDS

Maps and records are converted into C structures. VX/BASIC supports two conversion types. For processors that allow numeric data types to align on any boundary, the BASIC data types are converted in standard C data types, and regular C structure accessing code is generated. Most Linux processors and C compilers will force numeric data types to be aligned on even byte boundaries. They do this by automatically inserting "slack" bytes to pad the structures. This can cause serious problems for BASIC users who would expect overlaid MAPS to align. For these processors VX/BASIC has an option to treat all numeric data types as arrays of bytes (long words are typedef'd to char[4], doubles to char[8]).

VX/BASIC then generates code that will access this data without causing processor bus errors. This access method does add some overhead to the execution time and users are strongly urged to re-organize Maps and RECORDs for even byte alignment. For details on your target machine please contact Sector7.

Maps of the same name are overlaid identically to VMS. VX/BASIC supports GLOBAL (SHARE) Maps. Unlike VMS, all Maps are linked by default NOSHARE.

VX/BASIC STATEMENTS

All VMS / OpenVMS BASIC commands have been implemented except graphics. Generally the VMS / OpenVMS BASIC commands translate to the same name, lowercased except the first character with "'Vxb_" prepended. Some commands (such as PRINT, READ, INPUT) take format strings that define the data types to be acted upon and the line formatting to be applied.

All VX/BASIC functions perform identically to their VMS / OpenVMS BASIC equivalents. In the case above all three string functions would check the length of the input string and apply the same rules as VMS / OpenVMS BASIC.

Some VX/BASIC functions will also generate ERROR traps in certain conditions (VAL("HH") will generate ERROR 52). Others like BUFSIZ() on an unopened channel simply return 0 (As VMS / OpenVMS BASIC).

A few VX/BASIC functions are generated with different designators, depending on the input data type. For optimization, VX/BASIC recognizes that VAL has been passed an INTEGER quantity and generates Vxb_Vali() rather than Vxb_Val().

VX/BASIC DATATYPES

VX/BASIC supports all VMS / OpenVMS BASIC data types except GFLOAT and HFLOAT. If these are declared in a program VX/BASIC will convert them to DOUBLE. Note that DOUBLE on Linux/Windows has a similar range and precision to GFLOAT on the VMS.

DECIMAL data types are supported, but have a maximum range of (15,8). Both DYNAMIC and STATIC strings are implemented. VX/BASIC uses the same descriptor structure as VMS / OpenVMS BASIC. All VMS / OpenVMS BASIC string operations are fully implemented.

VX/BASIC ERROR HANDLING

VX/BASIC supports the full range of VMS / OpenVMS BASIC error numbers and error handling.

Whenever an error is generated, the current error handler is evoked and the error processing executed. VX/BASIC returns the same error codes as VMS / OpenVMS BASIC (52 = ILLEGAL VALUE, 15 = WAIT EXHAUSTED etc).

If your program calls the VMS service routines directly, and checks the return value, it will still perform in the identical manner using the VX/RT libraries. Each VX/RT system service call returns the same codes as VMS (SYS$OPEN returns 98962, RMS$_FNF, if the file does not exist).

The BASIC error functions ERR, ERL, ERT$, ERN$ are set in the identical manner. If another error occurs in an error processing routine before the error has been cleared a BASIC stack dump is issued.

VMS / OpenVMS BASIC INTEGRATED RMS on Intel Linux

VX/BASIC translates BASIC statements in C functions. All BASIC statements that are involved in RMS I/O (OPEN, GET FIND, PUT etc) take as arguments the original VMS / OpenVMS file specification including LOGICALS. Vx/Tools includes Vx/RMS an VMS / OpenVMS API and functionality compatible file system. Vx/RMS

STATEMENTS
CALL
CASE
CAUSE
CHAIN
CHANGE
CLOSE
COM
COMMON
CONTINUE
DATA
DECLARE
DEF
DEF*
DELETE
DIM
DIMENSION
DRAW
ELSE
END
ENDIF
EXIT
EXTEND
EXTERNAL
FIELD
FIND
FNEND
FNEXIT
FOR
FREE
FUNCTION
STATEMENTS
FUNCTIONEND
FUNCTIONEXIT
GET
GO
GOSUB
GOTO
HANDLER
IF
IFEND
INPUT
ITERATE
KILL
LET
LINPUT
LSET
MAP
MARGIN
MAT
MOVE
NAME
NEXT
NO
NOEXTEND
NOMARGIN
ON
ONERROR
OPEN
OPTION
PICTURE
PRINT
STATEMENTS
PROGRAM
PUT
RANDOM
RANDOMIZE
READ
RECORD
REM
REMAP
RESET
RESTORE
RESUME
RETRY
RETURN
RSET
RUN
SCRATCH
SELECT
SET
SLEEP
STOP
SUB
SUBEND
SUBEXIT
UNLOCK
UNTIL
UPDATE
USE
WAIT
WHEN
WHILE

FUNCTIONS
ABS
ABS%
AND
ASC
ASCII
ATN
BUFSIZ
CCPOS
CHR$
COMP%
COS
COT
CTRLC
CVT$$
CVT$%
CVT%$
DATE$
DATE4$
DET
DIF$
ECHO
EDIT$
EQV
ERN$
ERR
ERT
ERT$
EXP
FIX
FSP$
FUNCTIONS
FSS$
IMP
INSTR
INT
LEFT
LEFT$
LEN
LEN
LINE
LOG
LOG10
MAGTAPE
MAGTAPE
MAR
MAR%
MOD
NOECHO
NOT
NUM
NUM2
ONECHR
OR
PEEK
PLACE$
POS
PROD$
QUO$
RAD$
RCTRLC
RCTRLO
FUNCTIONS
RECOUNT
RIGHT
RIGHT$
RND
SEG$
SGN
SIN
SPACE$
SPEC
SPEC%
SQR
SQRT
STATUS
STRING$
SUM$
SWAP
SWAP%
TAB
TAN
TIME
TIME$
TRM$
VAL
VAL%
VMSSTATUS
XLATE
XLATE$
XOR