Commodore 128 Programmer's Reference Manual page 713

Hide thumbs Also See for 128:
Table of Contents

Advertisement

n
APPENDIXES
703
f 1
I \
recalling the CP/M jump vector on page 677 of Appendix K. The first 30 jumps (0-29)
are direct calls to CP/M BIOS routines. Jump number 30 is the call to the user functions, of
which user function 4 is the 8502 BIOS. The 8502 BIOS is a subset of the CP/M user
functions. The user function call is 1 of 31 system routine calls within the CP/M BIOS
jump table.
The following example calls user function 2 the keyscan function. The calling
routine starts at "waitkey" and the subroutine starts at "user$fun".
waitkey:
MVI useroffset,30
MVI A,2
CALL user$fun
INRB
JZ waitkey
DCRB
; load A reg. with function no. 2
;calls subroutine user$fun
increment B—test for -1 if no key is pressed
;jump to wait key if none
;decrement B if B not equal to 0
;this restores original matrix value
Rest of Program
user$fun
PUSH H
;place HL reg. pair on stack
LHLD 1
;load address of jump vector 1 (WBOOT) into HL
MVI L, useroffset * 3 ;get offset of 90 (30*3) to L
XTHL
;exchange HL with top of stack
RET
;jump to new HL pointer location of routine
First, the main program loads the user function number (2) into the A register. To
call a user function, place the required input parameter, the user function number, in the
A register. If a subfiinction is going to be called, like in user function 4 (8502 BIOS), the
input parameter for the subfunction number must be placed in L.
The second instruction in the main routine is a CALL to the subroutine user$fun.
However, in this example of the keyscan user function, the returned value B is -1 if
no key is pressed. If this is the case, B is incremented to zero and the main program
jumps to waitkey and scans the keyboard again. Otherwise, the rest of the program
continues processing.
When the subroutine is called, the first instruction saves the HL register pair, the
address pointer, on top of the stack. The next instruction loads memory location 1 (low)
and 2 (high) into register pair HL. The high byte points to the page number that the
jump vectors are on and the low byte is always 3 (Jump #1 the warm boot vector). Next
the jump number times 3 is loaded into the low byte (L) of register pair HL. This adds the
offset of 90 memory locations to base address of the CP/M BIOS jump table, which now
points to jump number 30, USERF.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents