Up one Useful routines. By Lee Davison. Up to top

Introduction.

There are many subroutines within BASIC that can be useful if you wish to use your own assembly routines with it. Here are some of them with a brief description of their function. For full details see the source code.

The routines.

LAB_IGBY

BASIC increment and get byte routine. gets the next byte from the BASIC command stream. If the byte is a numeric character then the carry flag will be set, if the byte is a termination byte, either null or a statement separator, then the zero flag will be set. Spaces in the command stream will automatically be ignored.

LAB_GBYT

BASIC get byte routine. Gets the current byte from the BASIC command stream but does not increment the execute pointer. Otherwise the same as above.

LAB_COLD

Performs a cold start. BASIC is reset and all BASIC memory is cleared.

LAB_WARM

Performs a warm start. Execution is stopped and BASIC returns to immediate mode.

LAB_XERR

With d0 set, do error #d0, then warm start.

The equivalent can be achieved by calling the routine in the name column.

Name d0 Error Name d0 Error
LAB_NFER$00NEXT without FOR LAB_SNER$04syntax
LAB_RGER$08RETURN without GOSUB LAB_ODER$0Cout of data
LAB_FCER$10function call LAB_OFER$14overflow
LAB_OMER$18out of memory LAB_USER$1Cundefined statement
LAB_ABER$20array bounds LAB_DDER$24double dimension array
LAB_DZER$28divide by 0 LAB_IDER$2Cillegal direct
LAB_TMER$30type mismatch LAB_SLER$34string too long
LAB_SCER$38string too complex LAB_CCER$3Ccan't continue
LAB_UFER$40undefined function LAB_LDER$44LOOP without DO
LAB_UVER$48undefined variable LAB_UDER$4Cundimensioned array
LAB_WDER$50wrong dimensions LAB_ADER$54address

You may add your own error messages by extending the error message pointer and error message tables.

LAB_INLN

Print "? " and get BASIC input. Returns a0 as a pointer to the start of the input line. The input is null terminated.

LAB_SSLN

Search Basic for a line, the line number required is held in the temporary integer, from start of program memory. Returns carry set and a pointer to the line in a0 if found, if not it returns carry and a pointer to the next numbered line in a0.

LAB_SHLN

Search Basic for temporary integer line number from a0. Same as above but starts the search from a0.

LAB_SNBS

Scan for next BASIC statement (: or [EOL]). Returns d1 as index to : or [EOL] from (a5).

LAB_SNBL

Scan for next BASIC line. Same as above but only returns on [EOL].

LAB_REM

Perform REM, skip (rest of) line.

LAB_GFPN

Get fixed-point number into temporary integer.

LAB_CRLF

Print [CR]/[LF] to output device.

LAB_PRNA

Print character in d0 to output device.

LAB_GVAR

Get variable address. Returns a pointer to the variable in Cvaral and a0 and sets the data type flag, $80=string, $40=integer and $00=float.

LAB_EVNM

Evaluates an expression and checks the result is numeric, if not it does a type mismatch. The result of the expression is returned in FAC1.

LAB_CTNM

Check if source is numeric, else do type mismatch.

LAB_CTST

Check if source is string, else do type mismatch.

LAB_CKTM

Type match check, set carry for string, clear carry for numeric.

LAB_EVEX

Evaluate expression.

LAB_GVAL

Get numeric value from line. Returns the result in FAC1.

LAB_SCCA

Scan for the byte in d0 as the next byte. If so return here, else do syntax error then warm start.

LAB_CASC

Check byte is alpha ("A" to "Z" or "a" to "z"), return carry clear if so.

LAB_EVIN

Evaluate integer expression. Return integer in d0 and Itemp.

LAB_EVPI

Evaluate +ve integer expression.

LAB_EVIR

Evaluate integer expression, no sign check.

LAB_CKRN

Check that the interpreter is not in immediate mode. If not then return, if so do illegal direct error.

LAB_GARB

Perform garbage collection routine.

LAB_EVST

Evaluate string.

LAB_SGBY

Scan and get byte parameter, return the byte in d0 and Itemp.

LAB_GTBY

Get byte parameter and ensure numeric type, else do type mismatch error. Return the byte in d0 and Itemp.

LAB_EVBY

Evaluate byte expression, return the byte in d0 and Itemp.

LAB_GADB

Get two parameters as in POKE or WAIT. Return the first parameter in a0, second in d0.

LAB_SCGB

Scan for "," and get byte, else do Syntax error then warm start. Return the byte in d0 and Itemp.

LAB_UFAC

Unpack the four bytes starting (a0) into FAC1 as a floating point number.

LAB_PFAC

Pack the floating point number in FAC1 into the current variable (Lvarpl).

LAB_AYFC

Convert d0 to signed longword in FAC1.

LAB_RTST

Put string address and length on descriptor stack & update stack pointers. Pointer is in a0, length is in d1. This is how you return a string to BASIC.


Last page update: 3rd May, 2004. e-mail me e-mail