Chapter
10
I
BASIC Keywords
DEF
USR
Statement
DEF
USR[number]
=
offset
Defines the user number and segment offset
of
a
subroutine to
be called by the USR function.
Number
may be an integer in the range 0 to 9. If you omit
num-
ber,
BASIC assumes USR0.
Offset
is an integer in the range 0
to
65535.
BASIC computes
where the subroutine begins in memory by adding the
offset
to
the current segment address as set by DEF SEG. BASIC trans-
fers control to this address when you execute the USR function.
If the subroutine is not in BASIC’s data segment, you must exe-
cute a DEF SEG statement before the USR function.
A
program may contain any number
of
DEF USR statements, al-
lowing access to
as
many subroutines
as
necessary. However,
only 10 definitions may be in effect at one time.
See the section “Interfacing With Assembly-Language Subrou-
tines” in Chapter
11
and USR in this chapter
for
more details.
Examples
DEF
USR3
=
6H0020
DEF
SEG
=
&HI700
USR3 begins
at
20H bytes into the current data segment which
is set at 1700 hexadecimal. When your program calls USR3, con-
trol branches to your subroutine beginning
at
absolute address
17020. (1700*10
+
20).
140