
Commands - 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
program.
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 address (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 structured as follows:
SP – >
m n
m n–1
.
.
.
m 1
return address
HL – > stack location of return address
BC – > number of data
The data may then be popped off the stack in reverse order. Note the HL register 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 returned to C AM BASIC from the assembly language routine by storing them in
memory locations before returning to CAM BASIC, and then reading the memory locations from
within CAMBASIC with the PEE K function. Or they may be stored directly in CAMBASIC
variables, if the VAR function was used to pass the variable addresses to the assembly language
program.
NOTE1: Once you have called a n assembly language r outine, you are in complete control.
CAM BASIC has no influence (unless the inter rupts ar e left enabled). If you do not re turn to
CAMBASIC, you probably have not restored the CPU stack or registers, destroyed RAM reserved
for CAM BASIC, or have not executed a RET (C9H). However, if interrupts have been enabled by
CAM BASIC, you must consider the consequences or turn off the interrupts.
Komentarze do niniejszej Instrukcji