Your routine can call BASIC's FRCINT routine to put the argument
into
HL
in
16-bit, signed two's complement form. The address of
FRCINT is stored
in
[X'2603', X'2604'].
For example,
you
can put the following code at the beginning of your
subroutine:
FRCINT
EQU
2603H
iCONVERTS
USR
ARGUMENT
no
INTEGER
IN
HL
LD
HL,CTNU
i(HL)=CONTINUATION
iADDRESS
PUSH
HL
iSAl,JE
IT
FOR
RETURN
iFROM
FRCINT
LD
HL,(FRCINT)
i (HL)
=FORCE
INTEGER
iROUTINE
JP
(HU
iDO
FRC
INT
ROUTINE
Returning
values
from
the
subroutine
to BASIC:
If the USR[digit] expression is a variable, you can modify its value
by
changing the ASA or string contents,
as
pointed to by
HL
or DE. For
example, the statement:
}{=USRl
(AX,)
transfers control to the
USR1
subroutine, with
HL
pointing to the
two-byte ASA for integer variable
A%.
Suppose you modify the
contents of its storage area. When you do a RET instruction to return
to BASIC, A% will have a new value, and X will
be
assigned this new
value.
In
general, USR[digit](expression) will return the same type of value
as
the expression. However, you can use BASIC's MAKINT routine to
return
an
integer value. The address of the MAKINT routine is stored
at [X'2605',X'2606'].
For example, you might include the following code at the end of your
program to return a value to BASIC:
MAKINT
EQU
2605H
LD
HL
,l.JAL
PUSH
HL
LD
HL,
(MAK
I
NT>
D(
(SP),
HL
RET
2-172
iVAL
IS
THE
VALUE
TO
iBE
RETURNED.
iSAVE
VALUE
IN
STACK
iRESTORE
VAL
INTO
HL
iAND
PUT
MAKINT
iINTO
STACK