Call – Remote Processing CAMBASIC User Manual
Page 46

Comm ands - 13
CALL
Statement
SYNTAX:
CALL address [,m1] [, m2] . . .
PURPOSE:
To execute an assembly language program at the specified address and, optionally, to pass data.
REMARK S:
The specified address may be an expression and is the absolute address of the assembly language
p r o gr a m .
The optional data may be expressions. After conversion to 16– bit integers, the data is pushed on
the CPU stack for use by the CALLed routine.
The data could be the memory addr ess (obtained by the VAR function) of either numeric or string
variables, if the routine is to access floating point data.
The amount of data that can be saved on the stack is limited only by available memory. When the
assembly language r outine is entered, the information passed and created is struc tured as follows:
SP – >
m n
m n– 1
.
.
.
m 1
return address
HL – > stack location of return ad dress
BC – > number of data
The data may then be popped off the stack in reverse order. Note the HL r egister pair point to the
location of the return address in the stack, allowing a clean return to CAMBASIC. The BC register
pair contains the number of data passed to the routine.
Data m ay be re turned to C AM BASIC from the assem bly language routine by storing them in
memor y locations before returning to CAM BASIC, and then reading the memory locations from
within CAM BASIC with the PEE K function. Or they m ay be stored directly in CAMBA SIC
variables, if the VAR function was used to pass the variable addresses to the assembly language
p r o gr a m .
NOTE1: Once you have called a n assemb ly language r outine, you are in comple te control.
CAM BASIC has no influenc e (unless the inter rupts ar e left enabled) . If yo u do not re turn to
CAM BASIC, you probably have not restored the CPU stack or registers, destroyed RAM reserved
for CAM BASIC, or have not executed a RET (C 9H). However, if interrupts have been enabled by
CAM BASIC, you must consider the consequences or turn off the interr upts.