User`s manual

8-8
USR
(x)
This function lets you call a machine-language subroutine and then continue
execution of your BASIC program.
"Machine language" is the low-level language used internally by your
Computer. It consists of Z-80 microprocessor instructions. Machine-language
subroutines are useful for special applications (things you can't do in BASIC)
and simply because they can do things very fast (like white-out the Display).
Writing such routines requires familiarity with assembly-language
programming and with the Z-80 instruction set. For more information on this
subject, see the Radio Shack book, TRS-80
Assembly-Language
Programming,
by William Barden, Jr., and the instruction manuals for Radio
Shack's TBUG (26-2001) and EDITOR-ASSEMBLER (26-2002).
Getting the USR routine into memory
1.
You should first reserve the area in high memory where the routine will
be located. This is done immediately after power-up by answering the
MEMORY SIZE? question with the address
preceding the start
address of your USR routine.
For example, if your routine starts at
32700, then type 32699 in response to MEMORY SIZE?.
2.
Then load the routine into memory.
A.
If it is stored on tape in the SYSTEM format (created with
EDITOR-ASSEMBLER or TBUG), you must load it via the SYSTEM
command, as described in Chapter 2. After the tape has loaded press
[BREAK]
to return to the BASIC command mode.
B.
If it is a short routine, you may simply want to POKE it into high
memory.
Telling BASIC where the USR routine starts
Before you can make the USR call, you have to tell BASIC the entry address
to the routine. Simply POKE the two-byte address into memory locations
16526-16527: least significant byte (LSB) into 16526, most significant byte
(MSB) into 16527.