Radio Shack TRS-80 Trsdos & Disk Basic Reference Manual page 107

Micro computer system
Hide thumbs Also See for TRS-80:
Table of Contents

Advertisement

DISK BASIC
Note:
If
you
call
a
USRn
routine before defining the routine entry
point with
DEFUSR/?,
an
ILLEGAL FUNCTION CALL
error
will
occur.
You
can
pass
one argument and
retrieve
one output
value
directly
via
the
USR
argument;
or
you
can
pass
and
retrieve
arguments
indirectly via
POKE
and
PEEK
statements.
Example:
IS
DEFUSR1=&H7D00
26
REM.
.
.
MORE PROGRRH LINES HERE
100
fMJSRKX)
The
effect
of
this
sequence
is
to:
1)
Define
USR1
as a
routine
with an entry point
at
hex
7D00
(line
10)
2)
Transfer control
to the routine; the value
X
can
be
passed
to
the routine
if
the routine
makes
the
CALL
described
below
(line
100)
3)
When
the routine returns to
BASIC,
the
variable
A
may
contain the value passed
back from
the routine
(if
your
routine
makes
the
JUMP
described below); otherwise
A
will
be
assigned the value
of
X
(line
100).
Passing
arguments
to
and from
USR
routines
There
are several
ways
to pass
arguments back and
forth
between
your
BASIC
main program
and your
USR
routines:
the
two
major
ways
are
listed
below.
1.
POKE
the argument(s)
into fixed
RAM
locations.
The
machine-language
routine
can then
access these values
and
place
results in
other
RAM
locations.
When
the routine
returns control to
BASIC,
your program
can
PEEK
into
these addresses to
pick
up
the
"output"
values.
This
is
the
only
way
to
pass
two
or
more
arguments back and
forth.
2.
Pass
one argument
to the routine
as
the
argument
in
the
USRn
call,
then
use
special
ROM
calls
to access
this
argument and
return
a
value to
BASIC.
This
method
is
limited to
sending
one argument and
returning
one
value
(both
are integers).
7-21

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents