HTBasic Help
×
Menu
Index

CSUB Environment

 
This section describes the CSUB execution environment, error reporting conventions, elements of a CSUB, and resource restrictions.
 
CSUB routines run directly on the processor and have access to all of its instructions and power. They execute as if they were internal HTBasic routines using the HTBasic processor stack. Arguments are passed to the CSUB using the normal C language calling method.
 
The value returned from the CSUB by the C return statement is used as the BASIC error value. A zero value denotes no error. Error values should be limited to values in the range 1 through 32760 and should correspond to the HTBasic error values. If a non-zero value is returned the line number reported will be the line number of the CALL statement.
 
A floating point exception handler is set up to return control to HTBasic upon any floating point exception. It uses a longjmp function to return control to HTBasic’s CALL routine and includes the floating-point error code. The line number reported with the error will be the line number of the CALL statement.
Care must be taken to insure that all user and C runtime library routines function correctly within the CSUB environment.