CP/M Interface¶
CP/M provides a universal interface linking application programs into the operating system. Through a system of calls to one location (0005 Hex) with the CPU register C set to the call number, the ROM-based operating system in HUNTER will implement the function and return to the user program. HUNTER is therefore compatible with many readily available commercial products,conforming to these standard system calls.
System Calls¶
CP/M system calls fall into two distinct categories. They are console (e.g. keyboard/LCD display) I/O and file I/O. Files are organised as CP/M disk files and may be accessed through a file control block (FCB).
Call No. |
Name |
Call No. |
Name |
---|---|---|---|
0 |
System Reset |
19 |
Delete File |
1 |
Console Input |
20 |
Read Sequential |
2 |
Console Output |
21 |
Write Sequential |
3 |
Reader Input |
22 |
Make File |
4 |
Punch Output |
23 |
Rename File |
5 |
List Output |
24 |
Return Login Vector |
6 |
Direct Console I/O |
25 |
Return Current Disk |
7 |
Get I/O Byte |
26 |
Set DMA Address |
8 |
Set I/O Byte |
27 |
Get Addr(Alloc) |
9 |
Print String |
28 |
Write Protect Disk |
10 |
Read Console Buffer |
29 |
Get R/0 Vector |
11 |
Get Console status |
30 |
Set File Attributes |
12 |
Return Version Number |
31 |
Get Addr(Disk Parms) |
13 |
Reset Disk System |
32 |
Set /Get User Code |
14 |
Select Disk |
33 |
Read Random |
15 |
Open File |
34 |
Write Random |
16 |
Close File |
35 |
Compute File Size |
17 |
Search for First |
36 |
Set Random Record |
18 |
Search for Next |
37 |
Reset Drive |
System calls 38-47 refer to HUNTER operating system only.
File Control Block¶
The FCB contains 36 bytes of information on the current file being accessed. On HUNTER, the default FCB location is at 005CH, containing the following Information :-
Byte |
Description |
---|---|
1 |
Drive code (zero) |
2-9 |
Eight Character ASCII filename |
10-12 |
ASCII file extension |
13 |
Current extent number |
14-15 |
Reserved |
16 |
Record count for extent |
17-32 |
Reserved for system use |
33 |
Current record in sequential file operation |
34-36 |
Random record number |
HUNTER System Calls¶
This manual does not contain an exhaustive description of each system call, since they are defined and explained in great depth in many other publications. However, there does follow a brief description of each call, together with details of extra calls specific to HUNTER.
The C register is loaded with the call number plus any other parameters into other registers, and the A call is made to address 0005. Registers not mentioned are irrelevant on entry, and none are necessarily preserved on exit. For making these calls from Basic, see the CALL and ARG and Machine Code Calls.
Function |
Call No |
Entry |
Exit |
Remarks |
---|---|---|---|---|
System Reset |
0 |
None |
None |
A system restart, re-entering HUNTER’S operating system. |
Console Input |
1 |
None |
A=ASCII character |
Read keyboard and echo onto screen. The call will wait until a key is pressed. |
Console Output |
2 |
E=ASCII character. |
None |
The character is displayed on the screen at the location of the cursor. |
Reader Input |
3 |
None |
A=ASCII character. |
The next character is read from the serial I/O buffer. |
Punch Output |
4 |
E=ASCII character. |
None |
The character is sent out through the serial port. |
List Output |
5 |
E=ASCII character. |
None |
As call 4. |
Direct Console I/O |
6 |
E=0FFH for input, E=ASCII character for output. |
A=ASCII character if input, A=status if output. |
Similar to calls 1 and 2, but there is no automatic echo to the screen. If a character is not ready from the keyboard then A=00 on return. |
Get I/O Byte |
7 |
None |
A=I/O status. |
The present I/O status byte is returned. |
Set I/O Byte |
8 |
E=I/0 value. |
None |
I/O byte is set. |
Print String to Console |
9 |
DE=string address. |
None |
An ASCII string whose start address is loaded into DE, is displayed on the screen. The string must be terminated with “$”. |
Read Console |
10 |
DE=buffer address. |
None |
The keyboard is read and the characters are placed into a buffer, the start address having been loaded into DE. The first byte contains the maximum number of characters to read into the buffer, the second byte contains the number of characters that have been placed into the buffer when input has been terminated with C/R or L/F. See Read Console Buffer for for further information. |
Get Console Status |
11 |
None |
A=console status. |
If a character has been typed in then 01H is returned, OOH if not. |
Return Version Number |
12 |
None |
HL=version number. |
HUNTER is CP/M version 2.2 compatible, so 0022H is returned. |
Reset Disk System |
13 |
None |
None |
The filing system is reset, and the DMA address is returned to 80H. |
Select Disk |
14 |
None |
None |
HUNTER has “RAM disks” so this call produces no action. |
Open File |
15 |
DE=FCB address. |
A=directory code. |
The file specified by the FCB is opened. If successful A=0,1,2 or 3. If not, then A=0FFH. |
Close File |
16 |
DE=FCB address. |
A=directory code. |
If successfully closed, A=0,1,2 or 3, otherwise A=0FFH. |
Search for First |
17 |
DE=FCB address. |
A=directory code. |
The directory is searched for the first match of the FCB. A=0FFH if there is no match, and 0,1,2 or 3 if there is. The filename is returned into the current DMA buffer. The search function returns the complete entry from the buffer. |
Search for Next |
18 |
None |
A=directory code. |
Similar to CALL 17, except that the next entry is looked for. The search function returns the complete entry from the buffer. |
Delete file |
19 |
DE-FCB address. |
A=directory code. |
Files which match the FCB are deleted. If none exist A=0FFH is returned. |
Read Sequential |
20 |
DE=FCB address. |
A=directory code. |
The specified file is read, and the sector copied to the current DMA address. A=00 for a successful read. |
Write Sequential |
21 |
DE=FCB address. |
A=directory code. |
The record at the current DMA address is written to the disk. A=00 indicate a successful write. |
Make File |
22 |
DE=FCB address. |
A=directory code. |
The specified file is created. A=0-3 if successful, or A=0FFH if not. |
Rename a File |
23 |
DE=FCB address. |
A=directory code. |
The file specified in the first 16 bytes of the FCB is renamed to the name in the second 16 bytes. |
Return Login Vector |
24 |
None |
HL=login vector. |
HUNTER returns HL=1 and A=1, indocating a single disk system. |
Return Current |
25 |
None |
A=current disk. |
Zero is always returned on HUNTER. |
Set DMA Address |
26 |
DE=DMA address. |
None |
The current disk data buffer area is set to DE. |
Get Allocation Address |
27 |
None |
HL =allocation address. |
Zero only is returned. |
Write Protect Disk |
28 |
Returns with no effect. |
||
Get Read Only Vector |
29 |
Returns with no effect. |
||
Set File Attributes |
30 |
DE=FCB address. |
A=directory code. |
File attributes for readonly etc. are set or reset as specified. |
Disk Parameter Address |
31 |
None |
HL=disk parameter block address. |
Disk parameters are returned which indicate a double sided double density disk. This is to allow for expansion within HUNTER. it should not be used for space calculation purposes. |
Get or Set User Code |
32 |
Returns with no effect. |
||
Read Random |
33 |
DE=FCB address. |
A=directory code. |
The file is read at the specified record. Normally non zero directory codes mean an error. |
Write Random |
34 |
DE=FCB address. |
A=directory code. |
The file is written at the specified record. A=0 means a successful write. |
Compute File Size |
35 |
DE=FCB address. |
None |
Random record field set to one plus the last record. |
Set Random Record |
36 |
DE=FCB address. |
None |
Random record field set. |
Reset Drive |
37 |
DE=drive vector. |
None |
HUNTER’S filing sytem is reset. |
Set up the RS-232 Serial Port |
38 |
None |
None |
The software setup routine is entered to set up the serial comm communications. |
Initialise the Clock |
39 |
None |
None |
The time and date buffer RAM is copied to the clock. |
Write Random with zero fill |
40 |
DE=FCB address. |
A=directory code. |
The write random with zero fill operation is similar to function 34, with the exception that a previously unallocated block is filled with zeros before data is written. NOTE: on early HUNTERs, this call was used for a different function. |
Initialise Communications |
41 |
None |
None |
This call allows configuration of the communications exactly as the standard initialise HUNTER communications routine. |
Serial Status |
42 |
None |
A=port status. |
To test for pending serial input characters A=0 for no characters read else A is non-zero. |
Terminal emulation call |
43 |
None |
None |
Enters terminal terminal emulation mode. |
Wand input call |
44 |
DE=Buffer Address |
None |
The Wand code is selected previously by setting the bartype location according to wand code being read. The code is read into the buffer. The user must provide the buffer address and, in the first location of the buffre, the user must provide the maximum number of characters to be read into the buffer. On exit, the second byte of the buffer contains the number of that have been placed in the buffer, followed by the wand character’s input. |
Fetch key without echo |
47 |
None |
A=ASCII code of character. |
|
Read the Clock |
48 |
None |
None |
The time and date is copied from the clock into the time and date buffer RAM (see Memory Locations) locations TENTHSEC to TENYR. |