TAMS

Home | Products | Support | How to Order | Contact Us | Search  

Introduction:

A compiled subprogram (CSUB) is a routine that is written in either Pascal or assembly language on a Pascal workstation and transformed into a routine that is callable as a subprogram from BASIC. Either a single CSUB or a library of CSUBs may be generated using this technique. then, after leaving the Pascal workstation and entering the BASIC system, the CSUB is loaded into memory using the LOAD or LOADSUB command and called like any other BASIC subprogram.

Note:
CSUBs written for BASIC 2.0 or 2.1 must be created on a Pascal 2.0 workstation. CSUBs written for BASIC 3.0 or later must be created on a Pascal 3.0 or later workstation, using the CSUB utilities whose revision corresponds to the revision of BASIC. This page pertains to the CSUB Utility for BASIC 6.0. though BASIC 6.0 is globalized, Pascal is not. This affects how you use the CRT I/O command, DISP_AT_XY.

The BASIC 6.0 CSUB Utility may be used with any 6.x version of BASIC/WS, however, BASIC/UX 300 version 6.5 requires the 6.5 edition of the CSUB utility.

 

A working knowledge of the BASIC language, editor, data types, and subprograms is required.

Before creating CSUBs, you must also know how to use the Pascal workstation to write and compile programs. To generate CSUBs, a good working knowledge of the Editor, the Compiler (or Assembler), and the Librarian is necessary.

You should also understand the Pascal language IMPORT/EXPORT features which will be used heavily to incorporate information from librairies. For information, see the "Pascal Compiler" chapter in the Pascal Workstation System Manual.

The principles of linking in Pascal must be understood before attempting to link additional modules and libraries into a CSUB. For information, see the "The Librarian" chapter in the Pascal Workstation System Manual.

Learn these things before proceeding with CSUBs. All this information can be obtained from the Pascal Workstation System Manual.

When to use CSUBs:

Back to Top

CSUBs are used to fill a number of needs:

  • Because the compiled or assembled routines are in 680000-family machine code, they have a speed advantage over BASIC interpreted code. Computational routines are faster when written in Pascal.
  • CSUBs are in object code on the disk, therefore, source code does not have to be released with them. This provides a greater measure of security for programs employing them.
  • CSUBs are useful when libraries of routines are needed for both Pascal and BASIC environments. By writing the routines in Pascal, you only need to write the routine once as a CSUB rather than once in BASIC and once in Pascal.

For examplbe, when a set of benchmark programs were run, performance using CSUBs was far superior to BASIC. In therse benchmarks, REAL and INTEGER loops, transcendetal 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. Two reasons for this size increase are:

  • BASIC "source" code is represented internally in a tokenized RPN (reverse Polish Notation) form. this results in space savings, even compared against the "pure" code of a CSUB.
  • Support routines needed by the CSUB (such as real number manipulation) must be linked with the CSUB. Even though the same low-level code may exist in BASIC, the overhead of calling these BASIC routines removes the speed advantage

There are some limitations in using CSUBs. Only BASIC INTEGER, REAL, COMPLEX, string and I/O path type parameters can be passed to a CSUB as opposed to Pascal data structures. Routines must have all external references fully resolved before they can be used as CSUBs. This may lead to problems if calls to Pascal system routines generate unresolved external references or other errors.

The Pascal Procedure Library is now supported for HP-IB and GPIO cards. Limited support is available for RS-232C interfaces. However, no transfer capability is supported. Also, limited file access is now allowed.

The System Components:

Back to Top

The CSUB utility consists of several different components; two libraries and three programs.

Libraries:

The two libraries that are included are CSUBDECL and CSUBLIB. CSUBDECL's declarations may be imported into your CSUB routines using the Pascal IMPORT command (e.g., IMPORT SCUBDECL;). CSUBDECL is a library file that contains the export text/declarations for the modules CSUBDECL, CSFA, KBDCRT, HEAP, COMSTUFF, and CSUBENTRY. The CSUBDECL module contains no code. The CSUBDECL file is only for use during compilation.

CSUBDECL Modules

Module Contents
COMSTUFF Export text for routines for accessing COM
CSFA Miscellaneous BASIC file I/O decalrations
CSUBDECL Type declarations for passing BASIC parameters
CSUBENTRY Export text neede to facilitate entry and exit from CSUB
HEAP Export text for routines that support heap management (requires COMSTUFF)
KBDCRT Miscellaneous BASIC keyboard and crt I/O declarations

CSUBLIB is the other library file and contains run-time support for CSUBs (used when linking). There are no declaratons (i.e. export text) in CSUBLIB to be imported. It holds the following modules:

CSUBLIB Modules

Module Contents
ALLREALS Real number arithmetic support
COMSTUFF Contains routines for accessing COM (export text in CSUBDECL)
CSFA Miscellaneous BASIC file I/O decalrations
CSUBENTRY contains code to facilitate entry and exit from CSUB (must always be present; export text in CSUBDECL)
CSUBSYM Defines some entrypoiints into BASIC and bootrom routines. It contains no code. (must always be present)
FS Support for string and INTEGER reaad and write
GENERAL_0 Read and write firmware interface registers
GENERAL_1 Character I/O routines plus timeout and I/O sytem setup
GENERAL_2 Implements string and real number I/O
GENERAL_3 Translates Pascal I/O errors into text messages
HEAP Contains routines to support heap management (requires COMSTUFF; export text in CSUBDECL)
HPIB_0 Provide low-level access to the HP-IB controller and bus
HPIB_1 Low-level bus control commands for HP-IB
HPIB_2 HP-IB message commands
HPIB_3 High-level bus status and control commands for HP-IB
HPM Additional heap routines necessary when HEAP_DISPOSE compiler option is turned on (requires COMSTUFF and HEAP)
IOCOMASM Tests and manipulates bits in a 32-bit INTEGER
IODECLARATIONS Must be present to use GENERAL and HPIB modules
KBDCRT Miscellaneous BASIC keyboard and crt I/O routines
MFS Support for REAL read and write (requires ALLREALS and FS)
MISC Miscellaneous Pascal support routines
SETSTUFF Support routines for Pascal sets (3.0 only)
STRING Pascal string support routines

Programs:

The first program, called BUILC.BUILDC, is an interactive program run by you to gather information about the subprogram (CSUB) being generated and how it will look to BASIC.

The other two programs, RELDATA and BUILDLIF, are used by the stream file, GENC.TEXT. The GENC stream file is a sequenced batch file containing commands to link the user routine with library routines, execute the program that extracts relocation information, link the jump and header file with the user routines and then execute a program that writes completed routines to a formatted disk.

The first program to be executed in the GENC stream file is RELDATA, which generates relocation information for BASIC. RELDATA reports all unsatisfied external references. The second program, BUILDLIF, takes the fully linked routine and reformats it to a BASIC PROG file.

 

Ordering Information:

Back to Top

BASIC/WS 6.x CSUB Utility (includes License and Media)
Part #: 98616S
Price: US $340.00

Upgrade BASIC/WS 6.x CSUB Utility (includes License and Media)
Part #: 98616S-001
Price: US $140.00

The Manuals "HP BASIC 6.0 CSUB Utility" (98616-90006) and "Creating CSUBs for RMB/UX" (E2040-90003) are included on our BASIC Documentation CD.
Part #: 2047K
Price: US $300.00

CSUB Utility Support:

Back to Top

Annual Support Contracts are available for this product. For more information about our support services, please click [here].

CSUB Utility Support License to Use
Part #: 98616S-0028
Price: US $120.00 (12 months)

CSUB Utility Support Media
Part #: 98616S-0028
Price: US $240.00 (12 months

 Home | Products | Distributors | Support | Company Info | How to Order | Contact Us | Search

 
All referenced prices are United States Dollars.
Copyright © 1997-2006 Test & Measurement Systems Inc.
Other products and companies referred to herein are trademarks or registered trademarks of their respective companies or mark holders.  Specifications are subject to change without notice.

Test & Measurement Systems Inc.
750 14th Street SW
Loveland, CO 80537

Tel:  + 970-669-6553
Fax: + 970-669-3090
sales @ tamsinc.com

 

18 Oct 2005