Errors

This chapter covers unresolved external references, CSUB errors, problem areas, relocation errors, and run-time errors.

Unresolved External References

The most common problem encountered while building CSUBs is unresolved external references. These get reported by either the RELDATA program or the BUILDLIF program. When this happens, you must determine the modules which define these references, and link these missing module(s) to your CSUBs. All missing references should have been reported by RELDATA. However, BUILDLIF will stop on the first unsatisfied reference. If this occurs, find all your unresolved external symbols by using the Librarian to list the externals of file CSUB_TEMP. See the Pascal Workstation System manual for details. If any of these externals are generated by the Compiler, you need to find out which modules in CSUBLIB contain these entry points and link them in.

The table below list the entry points in the CSUBLIB modules. If you have an unresolved reference, use the table to find the missing module (if it is part of the support routines).

If the missing module contains global variables, (e.g., IODECLARATIONS, GENERAL_0 or yours), it must be manually pre-linked and BUILDC must be executed again. Otherwise, the GENC.TEXT stream file can be modified to do the linking for you. Add the appropriate TM <module name> lines to your GENC stream file.

IODECLARATIONS is not listed here, but will be needed to satisfy references from other device I/O modules. Be sure to use modules from the CSUB utility, not ones from the Pascal System, to satisfy references.

CSUBLIB
DEF table of 'ALLREALS':DEF table of 'CSFA':
ASM_ARCTAN CSFA_FAL_CLOSE
ASM_BCDROUND CSFA_FAL_CREATE_ASCII
ASM_BCD_REAL CSFA_FAL_CREATE_BDAT
ASM_COS CSFA_FAL_EOF
ASM_EQ CSFA_FAL_LOADSUB_ALL
ASM_EXP CSFA_FAL_LOADSUB_NAME
ASM_FLOAT CSFA_FAL_OPEN
ASM_FLPT_ERROR CSFA_FAL_POSITION
ASM_GE CSFA_FAL_PURGE
ASM_GT CSFA_FAL_READ
ASM_LE CSFA_FAL_READ_BDAT_INT
ASM_LN CSFA_FAL_READ_STRING
ASM_LT CSFA_FAL_WRITE
ASM_NE CSFA_FAL_WRITE_BDAT_INT
ASM_RADD CSFA_FAL_WRITE_STRING
ASM_RDIV
ASM_REAL_BCD DEF table of 'CSUBENTRY':
ASM_RMUL
ASM_ROUND CSUBENTRY_BASIC_GLOBALS
ASM_RSUB CSUBENTRY_CSUBENTRY
ASM_SIN CSUBENTRY_PASCAL_GLOBALS
ASM_SQRT CSUBENTRY_STACKSPACE
ASM_TRUNC CSUBGLOB
CSUB_ENTRY
DEF table of 'COMSTUFF':
COMSTUFF_COMSTUFF
COMSTUFF_FIND_COM
DEF table of 'FS': DEF table of 'FS' (continued)
FS FS_IO_ENTERTERM
FS_BASICTYPECONST FS_IO_OUTPUT
FS_BOOLTABLE FS_IO_STRINPUT
FS_DEV_INIT FS_NUMERIC_DEFAULT
FS_FHPRESET FS_PRT_INIT
FS_FREADCHAR FS_REALNUM_DEFAULT
FS_FREADINT FS_RESET
FS_FREADLN FS__BASE
FS_FREADPAOC IOENTRY_STRINPUT
FS_FREADSTR ROUNDIT
FS_FREADSTRBOOL
FS_FREADSTRCHAR DEF table of 'GENERAL_0':
FS_FREADSTRENUM
FS_FREADSTRINT GENERAL_0_IOCONTROL
FS_FREADSTRPAOC GENERAL_0_IOREAD_BYTE
FS_FREADSTRSTR GENERAL_0_IOREAD_WORD
FS_FREADSTRWORD GENERAL_0_IOSTATUS
FS_FREADWORD GENERAL_0_IOWRITE_BYTE
FS_FS GENERAL_0_IOWRITE_WORD
FS_FWRITECHAR
FS_FWRITEINT DEF table of 'GENERAL_1':
FS_FWRITELN
FS_FWRITEPAOC GENERAL_1_IOINITIALIZE
FS_FWRITESTR GENERAL_1_IORESET
FS_FWRITESTRBOOL GENERAL_1_IOUNINITIALIZE
FS_FWRITESTRCHAR GENERAL_1_READCHAR
FS_FWRITESTRENUM GENERAL_1_READWORD
FS_FWRITESTRINT GENERAL_1_SET_TIMEOUT
FS_FWRITESTRPAOC GENERAL_1_WRITECHAR
FS_FWRITESTRSTR GENERAL_1_WRITEWORD
FS_FWRITESTRWORD
FS_FWRITEWORD
FS_IO_ENTERNUM
FS_IO_ENTERSETUP
DEF table of 'GENERAL_2': DEF table of 'HPIB_0':
GENERAL_2_READNUMBER HPIB_0_CLEAR_HPIB
GENERAL_2_READNUMBERLN HPIB_0_HPIB_LINE
GERERAL_2_READSTRING HPIB_0_SET_HPIB
GENERAL_2_READSTRING_UNTIL
GENERAL_2_READUNTIL DEF table of 'HPIB_1':
GENERAL_2_SKIPFOR
GENERAL_2_WRITENUMBER HPIB_1_ACTIVE_CONTROLLER
GENERAL_2_WRITENUMBERLNHPIB_1_END_SET
GENERAL_2_WRITESTRING HPIB_1_MY_ADDRESS
GENERAL_2_WRITESTRINGLNHPIB_1_SEND_COMMAND
&empty HPIB_1_SYSTEM_CONTROLLER
DEF table of 'GENERAL_3':
DEF table of 'HPIB_2':
GENERAL_3_IOERROR_MESSAGE
HPIB_2_ABORT_HPIB
DEF table of 'HEAP': HPIB_2_CLEAR
ASM_NEWBYTES HPIB_2_LISTEN
ASM_NEWWORDS HPIB_2_LOCAL
HEAP_HEAP HPIB_2_LOCAL_LOCKOUT
HEAP_HEAP_INIT HPIB_2_PASS_CONTROL
HPIB_2_PPOLL_CONFIGURE
DEF table of 'HPM': HPIB_2_PPOLL_UNCONFIGURE
HPIB_2_REMOTE
HPM HPIB_2_SECONDARY
HPM_DISPOSE HPIB_2_TALK
HPM_HESTABLISH HPIB_2_TRIGGER
HPM_HPM HPIB_2_UNLISTEN
HPM_MARK HPIB_2_UNTALK
HPM_NEW
HPM_RELEASE
HPM__BASE
DEF table of 'HPIB_3': DEF table of 'MFS':
HPIB_3_LISTENER MFS
HPIB_3_LOCKED_OUT MFS_FREADREAL
HPIB_3_PPOLL MFS_FREADSTRREAL
HPIB_3_REMOTED MFS_FWRITEREAL
HPIB_3_REQUESTED MFS_FWRITESTRREAL
HPIB_3_REQUEST_SERVICEMFS_MFS
HPIB_3_SPOLL MFS__BASE
HPIB_3_TALKER
DEF table of 'MISC':
DEF table of 'IOCOMASM':ASM_BINARY
ASM_FASTMOVE
ICOMASM_BINAND ASM_HEX
ICOMASM_BINCMP ASM_MOVEL
ICOMASM_BINEOR ASM_MOVELEFT
ICOMASM_BINIOR ASM_MOVER
IOCOMASM_BIT_SET ASM_MOVERIGHT
ASM_OCTAL
DEF table of 'KBDCRT': ASM_PACK
ASM_SCAN
KBDCRT_CLEAR_SCREEN ASM_UNPACK
KBDCRT_CONTROLCRT
KBDCRT_CONTROLKBD DEF table of 'SETSTUFF':
KBDCRT_CRTREADCHAR ASM_ADDSETRANGE
KBDCRT_CRTSCROLL ASM_ADELEMENT
KBDCRT_CURSOR ASM_SETASSIGN
KBDCRT_DISP_AT_XY
KBDCRT_READ_KBD DEF table of 'STRING':
KBDCRT_SCROLLDN ASM_PSUBTOPSUB
KBDCRT_SCROLLUP ASM_PSUBTOSSUB
KBDCRT_STATUSCRT ASM_SSUBTOPSUB
KBDCRT_STATUSKBD ASM_SSUBTOSSUB
KBDCRT_SYSTEMD ASM_STRLTRIM
ASM_STRRPT
ASM_STRRTRIM

CSUB Errors

BASIC uses error range 369 through 399 to report CSUB errors. There is a textual message of the form:


   CSUB Pascal error <>

for most of these errors. To find out what these errors mean, first subtract 400 from the error number. The result will be an escape code value which you can look up in the "Errors Message" appendix in the Pascal Workstation System manual.

Problem Areas

System Stack Overflow

Another problem you may run into is overflowing the system stack. Normally, the compiler generates code at the beginning of each procedure to check for stack overflow. However, if you use the $STACKCHECK OFF$ directive or if you write your code in assembly without stack checking, you may overflow the system stack.

NOTE
However, even if you compile your program with $STACKCHECK ON$, the BASIC operating system and all the support routines (listed earlier) are compiled with $STACKCHECK OFF$. Therefore, you can overflow the top of the stack and overwrite the system without warning. If this happens, you will need to reboot the system.

You can determine the space available by calling the function STACKSPACE. STACKSPACE is contained in the module CSUBENTRY and is automatically linked to your module. It returns an INTEGER containing the number of bytes available on the system stack. You should not let the stack space get below 0.

Parameter Mismatch

Since there is nothing in the system that checks the parameter list of a CSUB to make sure it matches the Pascal declaration, it is up to you to make sure that the matching is done correctly. See the "Parameter Passing" section in the "Writing CSUBs" chapter. If this is not done correctly, the stack will not be restored properly and unpredictable behavior will result.

Heap Initialization

If you attempt to use the heap without calling the HEAP_INIT procedure first, the heap pointer will not be initialized and unpredictable behavior will result.

Device I/O Initialization

If you attempt to use device I/O without calling the ioinitialize procedure first, the isc_table pointers will not be initialized and unpredictable behavior will result.

Debugging

There is no BASIC Debugger similar to the Pascal Debugger. You should test and debug your CSUB code on the Pascal workstation as much as possible. If this is not possible for some reason, (such as use of FAL or KBDCRT) and you run into problems with your code, you should insert WRITELNs into your program to print diagnostic information.

Stream File with I/O Path Names

If you have BUILDC make a stream file for you, and you are passing I/O paths as parameters or including them as variables in COM, the resulting file will include lines which Pascal will interpret as input variables. The Pascal error -25 (undefined macro parameter) will occur when you try to stream this file, unless you include "[*]" after the file name. See the section entitled "Stream" in the "The Main Command Level" chapter of the Pascal Workstation System manual.

Relocation Errors

The RELDATA program generates relocation information to be used by the CSUB anytime the CSUB is moved. It can only, however, update objects which are 32-bit addresses. If it can't generate the relocation information, it will report:


    Unable to relocate object at nnn

The number nnn is the offset of the object in the code block. If the code file is being manually pre-linked (as recommended), the error will be reported by the Librarian.

One example

Using the $CALLABS OFF$ compiler option causes PC-relative addressing to be used to call procedures. If you are calling a routine 32768 or more bytes away, and you don't provide patch space at link time, the call will not reach and an error will be reported. Either use long absolute addressing or let the Librarian put in patch jumps at link time to correct this problem.

Another example

An assembly language routine using short absolute addressing (16-bit addressing) to jump to another routine in the CSUB will not be able to address the procedure and an error will be reported by RELDATA. Use long absolute addressing to correct this problem.

Run-Time Errors

Eventually, the CSUB generation process (from running BUILDC to BUILDLIF) will proceed smoothly with no fatal errors. However, when BASIC is booted, several new types of errors can still occur:

NOTE
Pre-run errors will result if the revision of the CSUB utilities (BUILDC, CSUBDECL, CSUBLIB, and RELDATA) do not match the revision of BASIC. The major revision must match; for example, revision 4.0 utilities will produce CSUBs compatible with BASIC 4.0, 4.01, 4.02, and 4.03.

Typically this means that the BASIC operating system has been corrupted and a reboot is necessary. There are several causes for this behavior: