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: 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 :doc:`../basic-functions/call` and :doc:`../basic-functions/arg` and :doc:`../basic-programming/machine-code-calls`. +-------------+------+-------------+-------------+--------------------+ | Function | Call | Entry | Exit | Remarks | | | No | | | | +=============+======+=============+=============+====================+ | System | 0 | None | None | A system restart, | | Reset | | | | re-entering | | | | | | HUNTER'S operating | | | | | | system. | +-------------+------+-------------+-------------+--------------------+ | Console | 1 | None | A=ASCII | Read keyboard and | | Input | | | character | echo onto screen. | | | | | | The call will wait | | | | | | until a key is | | | | | | pressed. | +-------------+------+-------------+-------------+--------------------+ | Console | 2 | E=ASCII | None | The character is | | Output | | character. | | displayed on the | | | | | | screen at the | | | | | | location of the | | | | | | cursor. | +-------------+------+-------------+-------------+--------------------+ | Reader | 3 | None | A=ASCII | The next character | | Input | | | character. | is read from the | | | | | | serial I/O buffer. | +-------------+------+-------------+-------------+--------------------+ | Punch | 4 | E=ASCII | None | The character is | | Output | | character. | | sent out through | | | | | | the serial port. | +-------------+------+-------------+-------------+--------------------+ | List Output | 5 | E=ASCII | None | As call 4. | | | | character. | | | +-------------+------+-------------+-------------+--------------------+ | Direct | 6 | E=0FFH for | A=ASCII | Similar to calls 1 | | Console I/O | | input, | character | and 2, but there | | | | E=ASCII | if input, | is no automatic | | | | character | A=status if | echo to the | | | | for output. | output. | screen. If a | | | | | | character is not | | | | | | ready from the | | | | | | keyboard then A=00 | | | | | | on return. | +-------------+------+-------------+-------------+--------------------+ | Get I/O | 7 | None | A=I/O | The present I/O | | Byte | | | status. | status byte is | | | | | | returned. | +-------------+------+-------------+-------------+--------------------+ | Set I/O | 8 | E=I/0 | None | I/O byte is set. | | Byte | | value. | | | +-------------+------+-------------+-------------+--------------------+ | Print | 9 | DE=string | None | An ASCII string | | String to | | address. | | whose start | | Console | | | | address is loaded | | | | | | into DE, is | | | | | | displayed on the | | | | | | screen. The string | | | | | | must be terminated | | | | | | with "$". | +-------------+------+-------------+-------------+--------------------+ | Read | 10 | DE=buffer | None | The keyboard is | | Console | | address. | | 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 |RCB| for | | | | | | for further | | | | | | information. | +-------------+------+-------------+-------------+--------------------+ | Get Console | 11 | None | A=console | If a character has | | Status | | | status. | been typed in then | | | | | | 01H is returned, | | | | | | OOH if not. | +-------------+------+-------------+-------------+--------------------+ | Return | 12 | None | HL=version | HUNTER is CP/M | | Version | | | number. | version 2.2 | | Number | | | | compatible, so | | | | | | 0022H is returned. | +-------------+------+-------------+-------------+--------------------+ | Reset Disk | 13 | None | None | The filing system | | 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 | A=directory | The file specified | | | | address. | code. | by the FCB is | | | | | | opened. If | | | | | | successful A=0,1,2 | | | | | | or 3. If not, then | | | | | | A=0FFH. | +-------------+------+-------------+-------------+--------------------+ | Close File | 16 | DE=FCB | A=directory | If successfully | | | | address. | code. | closed, A=0,1,2 or | | | | | | 3, otherwise | | | | | | A=0FFH. | +-------------+------+-------------+-------------+--------------------+ | Search for | 17 | DE=FCB | A=directory | The directory is | | First | | address. | code. | 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 | 18 | None | A=directory | Similar to CALL | | Next | | | code. | 17, except that | | | | | | the next entry is | | | | | | looked for. The | | | | | | search function | | | | | | returns the | | | | | | complete entry | | | | | | from the buffer. | +-------------+------+-------------+-------------+--------------------+ | Delete file | 19 | DE-FCB | A=directory | Files which match | | | | address. | code. | the FCB are | | | | | | deleted. If none | | | | | | exist A=0FFH is | | | | | | returned. | +-------------+------+-------------+-------------+--------------------+ | Read | 20 | DE=FCB | A=directory | The specified file | | Sequential | | address. | code. | is read, and the | | | | | | sector copied to | | | | | | the current DMA | | | | | | address. A=00 for | | | | | | a successful read. | +-------------+------+-------------+-------------+--------------------+ | Write | 21 | DE=FCB | A=directory | The record at the | | Sequential | | address. | code. | current DMA | | | | | | address is written | | | | | | to the disk. A=00 | | | | | | indicate a | | | | | | successful write. | +-------------+------+-------------+-------------+--------------------+ | Make File | 22 | DE=FCB | A=directory | The specified file | | | | address. | code. | is created. A=0-3 | | | | | | if successful, or | | | | | | A=0FFH if not. | +-------------+------+-------------+-------------+--------------------+ | Rename a | 23 | DE=FCB | A=directory | The file specified | | File | | address. | code. | in the first 16 | | | | | | bytes of the FCB | | | | | | is renamed to the | | | | | | name in the second | | | | | | 16 bytes. | +-------------+------+-------------+-------------+--------------------+ | Return | 24 | None | HL=login | HUNTER returns | | Login | | | vector. | HL=1 and A=1, | | Vector | | | | indocating a | | | | | | single disk | | | | | | system. | +-------------+------+-------------+-------------+--------------------+ | Return | 25 | None | A=current | Zero is always | | Current | | | disk. | returned on | | | | | | HUNTER. | +-------------+------+-------------+-------------+--------------------+ | Set DMA | 26 | DE=DMA | None | The current disk | | Address | | address. | | data buffer area | | | | | | is set to DE. | +-------------+------+-------------+-------------+--------------------+ | Get | 27 | None | HL | Zero only is | | Allocation | | | =allocation | returned. | | Address | | | address. | | +-------------+------+-------------+-------------+--------------------+ | Write | 28 | | | Returns with no | | Protect | | | | effect. | | Disk | | | | | +-------------+------+-------------+-------------+--------------------+ | Get Read | 29 | | | Returns with no | | Only Vector | | | | effect. | +-------------+------+-------------+-------------+--------------------+ | Set File | 30 | DE=FCB | A=directory | File attributes | | Attributes | | address. | code. | for readonly etc. | | | | | | are set or reset | | | | | | as specified. | +-------------+------+-------------+-------------+--------------------+ | Disk | 31 | None | HL=disk | Disk parameters | | Parameter | | | parameter | are returned which | | Address | | | block | indicate a double | | | | | address. | sided double | | | | | | density disk. This | | | | | | is to allow for | | | | | | expansion within | | | | | | HUNTER. it should | | | | | | not be used for | | | | | | space calculation | | | | | | purposes. | +-------------+------+-------------+-------------+--------------------+ | Get or Set | 32 | | | Returns with no | | User Code | | | | effect. | +-------------+------+-------------+-------------+--------------------+ | Read Random | 33 | DE=FCB | A=directory | The file is read | | | | address. | code. | at the specified | | | | | | record. Normally | | | | | | non zero directory | | | | | | codes mean an | | | | | | error. | +-------------+------+-------------+-------------+--------------------+ | Write | 34 | DE=FCB | A=directory | The file is | | Random | | address. | code. | written at the | | | | | | specified record. | | | | | | A=0 means a | | | | | | successful write. | +-------------+------+-------------+-------------+--------------------+ | Compute | 35 | DE=FCB | None | Random record | | File Size | | address. | | field set to one | | | | | | plus the last | | | | | | record. | +-------------+------+-------------+-------------+--------------------+ | Set Random | 36 | DE=FCB | None | Random record | | Record | | address. | | field set. | +-------------+------+-------------+-------------+--------------------+ | Reset Drive | 37 | DE=drive | None | HUNTER'S filing | | | | vector. | | sytem is reset. | +-------------+------+-------------+-------------+--------------------+ | Set up the | 38 | None | None | The software setup | | RS-232 | | | | routine is entered | | Serial Port | | | | to set up the | | | | | | serial comm | | | | | | communications. | +-------------+------+-------------+-------------+--------------------+ | Initialise | 39 | None | None | The time and date | | the Clock | | | | buffer RAM is | | | | | | copied to the | | | | | | clock. | +-------------+------+-------------+-------------+--------------------+ | Write | 40 | DE=FCB | A=directory | The write random | | Random with | | address. | code. | with zero fill | | 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 | 41 | None | None | This call allows | | Communicat\ | | | | configuration of | | ions | | | | the communications | | | | | | exactly as the | | | | | | standard | | | | | | initialise HUNTER | | | | | | communications | | | | | | routine. | +-------------+------+-------------+-------------+--------------------+ | Serial | 42 | None | A=port | To test for | | Status | | | status. | pending serial | | | | | | input characters | | | | | | A=0 for no | | | | | | characters read | | | | | | else A is | | | | | | non-zero. | +-------------+------+-------------+-------------+--------------------+ | Terminal | 43 | None | None | Enters terminal | | emulation | | | | terminal emulation | | call | | | | mode. | +-------------+------+-------------+-------------+--------------------+ | Wand input | 44 | DE=Buffer | None | The Wand code is | | call | | Address | | 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 | 47 | None | A=ASCII | | | without | | | code of | | | echo | | | character. | | +-------------+------+-------------+-------------+--------------------+ | Read the | 48 | None | None | The time and date | | Clock | | | | is copied from the | | | | | | clock into the | | | | | | time and date | | | | | | buffer RAM (see | | | | | | |ML|) locations | | | | | | TENTHSEC to TENYR. | +-------------+------+-------------+-------------+--------------------+ .. |ML| replace:: :doc:`../appendix/memory-locations` .. |RCB| replace:: :doc:`../appendix/read-console-buffer`