A compiled subprogram (CSUB) is a routine written in Pascal, C, FORTRAN, or assembly language on HP-UX and transformed into a subprogram callable from BASIC. Either a single CSUB or a library of CSUBs may be generated using this technique. In BASIC, the CSUB is loaded into memory using the LOAD or LOADSUB command and called like any other BASIC subprogram.
This manual assumes you are familiar with the BASIC language, editor, data types, and subprograms.
To create CSUBs, you should also know how to use HP-UX to write and compile programs. This includes:
To link the necessary modules and libraries into a CSUB object file, you should understand the linking procedures associated with the ld command.
Learn these things before proceeding with this manual.
The following are notations you should be familiar with:
literal | This font is used for listing example programs, specifying file names, CSUB programming language variables and types, and output from commands. It is also used for specifying computer input that you must type in character for character. For example it you are told to type rmb [Return], you would type the characters rmb and press the [Return] key. |
variable | This font is used to specify variables for which you must supply a value. For example, MSI "dir" is a command to change directories (explained later). The variable "dir" is a directory whose name you have to supply for the command to work. |
KEYWORD | This font indicates keywords that are used in BASIC commands or statements. For example, LOADSUB is the BASIC command used to load compiled subprograms (CSUBs) into memory. |
When the term BASIC is used in this manual, it is referring to the implementation of BASIC on HP-UX.
CSUBs are used to fill a number of needs:
For example, when a set of benchmark programs were run, performance using CSUBs was far superior to BASIC. In these benchmarks, REAL and INTEGER loops, transcendental (e.g., functions such as sin(x), log(x), etc.) and non-transcendental math, quick and shell sorts, and matrix multiplication were compared. For the quick sort, the CSUB ran many times faster than a similar BASIC routine. For transcendental math, the CSUB was found to be marginally faster.
The price paid for this speed is the size of the routines. CSUB code will always be larger than comparable BASIC code. The reason for this size increase is that BASIC source code is represented internally in a tokenized RPN (Reverse Polish Notation) form. This results in space savings, even compared against the binary code of a CSUB.
The CSUB utility consists of several different system components, a library, an include file, and a program.
The library, librmb.a, contains the necessary code to link CSUB code with BASIC and any CSUB utilities provided.
File | Contents |
---|---|
csfa.o | miscellaneous BASIC file I/O routines |
kbdcrt.o | miscellaneous BASIC keyboard and crt I/O routines |
csubdecl.o | useful parameter type declarations for Pascal CSUBs |
The include file, csubdecl.h, contains useful parameter type declarations for C language CSUBs.
The program, rmbbuildc, interactively prompts you for information about the subprograms (CSUBs) being generated. It accepts a fully linked CSUB object file and generates as output a BASIC PROG file.