Download BASIC User`s Manual
Transcript
TSC BASIC User's Manual
11.4 Calling multiple 6809 USR routines.
While there is only one USR command setup in BASIC, there is no
reason not to have more than one actual routine. The following hints
will show you how to call as many assembly language routines as you want
from BASIC.
There are two ways to accomplish such a task. The first is to pass
a parameter to the USR routine which could be decoded by the actual
assembly routine to determine which of any other routines to jump to.
The second method, which is much simpler, is to change the USR routine
start address as desired. This is done via the POKE command.
As an example, let's assume we have two assembly language user
routines, one at hex AEOO and one at hex AFFO. Also assume memory end
is at $7FFF as before. To call these routines in a row (passing zero
parameters to them) we would use the following lines.
190
200
210
220
POKE HEX("7FFD"), HEX("AE") : POKE HEX("7FFE"), HEX("00")
A = USR(O)
POKE HEX("7FFD"), HEX("AF") : POKE HEX("7FFE"), HEX("FO")
B = USR(0)
You might want to consider line 190 as part of the USR call for the
routine at $AEOO and line 210 as part of the USR call for $AFFO.
In
fact it might make sense to put the two steps into a single line using
the multiple statements per line character.
This is done in the
following example.
The main purpose of the following example, however, is to show how
you might save yourself some typing and chances for mistakes by
assigning addresses to variable names. We will setup the address of the
USR routine address vector as variables UL and UR (for User vector Left
and Right halves) and the various user routines as XL, XR, and YL, YR.
The result is as follows.
340
350
360
370
380
390
400
UL =
XL =
YL =
REM
REM
POKE
POKE
HEX("7FFD") : UR = HEX("7FFE")
HEX("AE") : XR = HEX("OO")
HEX("AF") : YR = HEX("FO")
NOW USING MULTIPLE STATEMENTS PER LINE,
THE CALLS LOOK LIKE THE FOLLOWING.
UL,XL : POKE UR,XR : A = USR(O)
UL,YL : POKE UR,YR : B = USR(O)
You can see that if there were to be many calls to the USR routines
this method would make things much simpler and cleaner.
-68-