English
Language : 

NSB8 Datasheet, PDF (115/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
ITALIAN TECHNOLOGY
grifo®
MACHINE LANGUAGE SUBROUTINES
NSB8 provides a method through wich you may link your BASIC programs to machine language
subroutines which you have written to perform certain tasks.
A machine language routine must lie outside of the computer memory area reserved for the operating
system, BASIC and BASIC's program/data area (you may restrict this area, and thus leave room for
machine language routines in high memory, through use of the MEMSET command, for example).
Machine language routines are accessed through the built in BASIC functions named CALL. CALL
takes at least one argument, the numeric address in computer memory (an integer from 0 to 65535)
where your machine language routine begins. An optional second argument, also a numeric
expression in the above range, can be comunicated to your routine in the D and E registers pair. The
value will be truncated to an integer if it has a fractional part. Negative arguments are not allowed.
All registers may be used by your machine language routine in fact BASIC will have already
preserved any operating information which it will need later.
When your routine is finished, it should execute a RET (return) instruction, whic will allow BASIC
to resume control and continue with the execution of the BASIC program. If the machine language
routine uses the stack, then it should use its own stack area.
The stack area and stack pointer used by the BASIC interpreter should not be modified by the
machine language routine. The number returned as call's function value will be the decimal
representation of the contents of the H and L registers pair whenever the machine language routine
terminates. Thus, it is possible to communicate a single numeric value to your subroutine from
BASIC, and collect a single value from the routine when it returns.
Here are the models for proper formation of the CALL function call:
CALL(<address expression>)
CALL(<address expression>,<argument expression>)
For an example of CALL in use, let's supposethere exists a machine language routine at address 6000,
and that it will require the optional argument value. The foolowing line effects a transfer to that
routine, passing the value of variable A as argument in the D E registers as a positive, 16 bits binary
integer:
10 Q=CALL(6000,A)
If, in this istance, the binary value of 578 is in the H L registers pair when the machine language
routine returns, then the variable Q will be set to 578 when BASIC resume control.
Note that CALL looks like, and acts as a numeric function. CALL may be a part of any numeric
expression in BASIC, and may be used anywhere any other numeric function might be used. Note
that the following:
50 CALL(M,A)
is in error: CALL is not a statement.
Below are some more examples of CALL in use. In one argument instance of CALL, no specific
argument value is sent to the machine language routine in the D E registers pair, however, the CALL
function always returns a value: whatever is in the H L pair upon return to BASIC.
200 PRINT CALL(A(3)),A$
570 X=CALL(R+1024,G)
NSB8
Rel. 5.10
Page 103