Commodore 128 Programmer's Reference Manual page 714

Hide thumbs Also See for 128:
Table of Contents

Advertisement

704
COMMODORE 128
0
The XTHL instruction exchanges the HL register pair with the top of the stack.
This places the computed address on the top of the stack and the entry values of HL
back in HL. When the RETurn instruction is reached by the Z80, program control is
J j
therefore passed to the USERF vector, entry 30 in the CP/M BIOS jump table. When
u->
the function has completed, control returns to the instruction immediately following the
CALL User$Fun instruction (INR B).
) j
In order for the routines to be called successfully, the proper required input
|J
parameters must be placed in the appropriate registers. The user function number must
be placed in the A register, the subfunction number is placed in L, if any. Additional
inputs must be placed in the correct register or variable prior to calling the user function.
The above example calls user function 2, the keyscan function. To call any other
u
user function, load the subfunction number into the A register. To call a subfunction,
load the L register with a subfunction number on the beginning of the main (calling)
j j
program as follows:
o
MVI L, subfim
The way this program is written, the value in L, which you will load at the beginning
m
of the program with the above instruction, is placed back in L from the stack when the
XTHL is reached at the end of the subroutine. Use this example as a template when
calling other subfunctions. Make sure the proper inputs are present in the correct
(
locations prior to calling the user function.
<J
CALLING A CP/M BIOS ROUTINE
j
Making a direct BIOS call is different from calling a user function. User function calls
always enter jump number 30 in the CP/M BIOS jump table. A direct BIOS call enters
any of the first 30 (0-29) jump vectors. These are the input and output routines that are
a part of any CP/M system on any microcomputer. The standard method of calling a
CP/M BIOS routine is via BIOS function 50. This function handles the banking of the
two 64K RAM banks in the C128.
You could call a CP/M BIOS routine similar to the first example, but there is a
limitation. With the user function call method, you are only able to call BIOS routines
that reside in RAM bank 1. The TPA resides in bank 1, while the Z80 function code is
stored in RAM bank 0. If you try to call a direct BIOS routine in bank 0, the system will
crash because bank 1 is in context. This is why it is important to make direct
CP/M BIOS calls through user function 50. Refer to the Digital Research CP/M Plus
documentation for more details on user function 50.
Here's a program example that illustrates how to call a CP/M BIOS function.
main
MVI C,50
;store function no. 50 in reg. C
LXI D,bios$pb
;load immediate a 16 bit pointer in DE
CALL 5
standard BIOS call

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents