DR-DOS System and Programmer's Guide (original) (raw)

[Front] [Prev Chapter] [Next Chapter]


Chapter 3 DR-DOS Support for Interrupts

INT 20H — Program Terminate

INT 21H — Invoke a System Call

INT 22H — Terminate Address

INT 23H — Ctrl-Break Address

INT 24H — Critical ErrorHandler

INT 25H — Absolute Disk Read

INT 26H — Absolute Disk Write

INT 27H — Terminate and Stay Resident

INT 2FH — Multiplex Interrupt


DR-DOS supports the interrupts listed in Table 3-1.

Table 3 1 Interrupts Supported by DR-DOS

DOS Interrupt Description
20H Program Terminate
21H DOS Function Request
22H Terminate Address
23H Ctrl-Break Exit Handler Vector
24H Critical Error Handler Vector
25H Absolute Disk Read
26H Absolute Disk Write
27H Terminate and Stay Resident
2FH Multiplex Interrupt

3.1 INT 20H — Program Terminate

Issuing INT 20H restores the terminate (INT 22), Ctrl-Break (INT 23), and critical error handler address (INT 24) fields in the interrupt table to the values they contained when the current program was loaded.

DR-DOS flushes all file buffers in response to an INT 20H instruction. If any file that has changed in length is not closed prior to an INT 20H, the directory entries for its length, date, and time will not be correctly recorded (see the Close File (10H) and Close a File Handle (3EH) calls in Chapter 4, DR-DOS System Calls). If you want your program to pass an error or completion code before terminating, use Terminate a Process (4CH).

Notes: Before issuing an INT 20H, your program must ensure that the CS register contains the segment address of its PSP. See the EXEC (4BH) system call in Chapter 4 for a description of the PSP control block. INT 20H is supported for compatibility with earlier programs only; the preferred method for terminating a program is function 4CH Terminate a Process.

3.2 INT 21H — Invoke a System Call

Section 2.1 in Chapter 2, DR-DOS System Call Parameters, describes how to use INT 21H to invoke a system call, and Chapter 4 describes the individual system calls.

3.3 INT 22H — Terminate Address

This interrupt location contains the address to which DR-DOS transfers control when the current program terminates.

DR-DOS copies this address into offset 0AH of the program’s Program Segment Prefix when the segment is created.

Note: Do not issue interrupt 22H directly.

3.4 INT 23H — Ctrl-Break Address

DR-DOS executes Interrupt 23H when the user enters Ctrl-Break during standard I/O or standard printer or asynchronous communications operations. If a user enters Ctrl-Break when the current state of Ctrl-Break checking is on (see Ctrl-Break Check (33H) system call), DR-DOS issues Interrupt 23H on the next system call.

If your Ctrl-Break routine saves all registers, it can continue program execution by ending with an interrupt return instruction (IRET). DR-DOS places no restrictions on the routine, including its use of DOS calls, when the registers are saved before it issues an IRET. If your interrupt routine returns with a long return, the Carry flag determines whether the program will continue to execute. When the flag is set, the program will end; otherwise, it will continue as with an IRET.

If Ctrl-Break interrupts system calls Print String (09H), or Buffered Keyboard Input (0AH), DR-DOS outputs a Ctrl-C, carriage-return, and linefeed. I/O then continues from the start of the new line if program execution is allowed to continue with an IRET. When the interrupt is issued, all registers are returned to the values they contained during the original DOS system call.

3.5 INT 24H — Critical ErrorHandler

DR-DOS transfers control to Interrupt 24H when a critical error occurs during the execution of a DOS program. BP:SI is set to point to the Device Header Control Block, which provides additional information. See Figure 6-1 for full details of the Device Header Control Block. INT 24H sets the registers so that if an IRET is executed, DR-DOS responds according to one of the following values in AL:

0 = ignore the error

1 = retry the operation that resulted in the error

2 = terminate application

3 = fail the current function

DR-DOS will not take an INT 24H exit for disk errors that occur during an INT 25H or 26H. It takes an INT 24H exit only when the disk error is the result of an INT 21H system call.

3.5.1 Disk Errors

Bit 7 (high-order) of register AH equal to zero indicates a disk error. When AH bit 7 = 0, register AL contains the number of the drive on which the error occurred (0 corresponds to drive A). Bits 0 through 2 of AH indicate which operation was in effect and the area of the disk involved in the error. Bits 3 through 5 of AH indicate valid responses to the disk error. Table 3-2 lists the values assigned to these bits.

Table 3 2 INT 24H Disk Error and Response Indicators

AH Bit Meaning
Error Indicators
0 0 Read operation1 Write operation
2-1 00 System area01 FAT10 Directory11 Data area
Response Indicators
3 0 Fail is not allowed1 Fail is allowed
4 0 Retry is not allowed1 Retry is allowed
5 0 Ignore is not allowed1 Ignore is allowed

If the Critical Error handler returns an invalid response, then a default response is assumed, as shown below:

Invalid Response Default Response
Ignore Fail
Retry Fail
Fail Terminate

DR-DOS sets all registers to retry the operation and passes an error code in the low-order byte of register DI. The high-order byte of DI is undefined. Table 3-3 lists these error codes.

Table 3 3 DR-DOS Critical Error Codes

Value of DI (Low-order) Error
00H Attempted write on protecteddiskette
01H Unit unknown
02H Drive not ready
03H Command unknown
04H CRC error
05H Bad request structure length
06H Seek error
07H Media type unknown
08H Sector not found
09H Printer out of paper
0AH Write failure
0BH Read failure
0CH General failure

DR-DOS places the information shown in Figure 3-1 on the user stack.

Undisplayed Graphic

Figure 3-1
User Stack at INT 24H

3.6 INT 25H — Absolute Disk Read

Interrupt 25H
Absolute Disk Read
Entry Parameters:
Register AL: Drive number
CX: Number of sectors to read
DX: Beginning logical sector number
DS: Transfer address - Segment
BX Transfer address - Offset
Returned Values:
Register AX: Error code, if Carry flag is set

INT25Htransfers data from a specified location on disk to memory. On entry, register CX specifies the number of sectors to be read from disk, starting at the logical sector number contained in register DX. Logical sector numbers are calculated from the start of the logical disk (this may also be the start of the physical disk, but not necessarily so). Numbering continues through the sectors on the same track, then sectors on the other tracks of the head, then the other heads. Sectors with consecutive logical sector numbers may not be adjacent on the disk if the disk uses sector interleaving.

If the transfer is successful, the Carry flag is set to zero on return. If the transfer failed the Carry flag is set to 1, and AX contains an error codes. The code returned in AL is one of those listed in Table 3-3. The code returned in AH is one of those listed in Table 3-4.

On return, only the segment registers are preserved by this call. DR-DOS returns to the caller with a Far Return instruction so the original flags remain on the stack and must be explicitly popped off.

Note: To address partition sizes greater than 32 Mb an extended format is provided which allows INT 25 to pass a 32-bit value for the number of the starting sector. If CX contains FFFFH, DS:BX points to a packet that contains the information for the absolute disk read. The packet contains the sector number of the starting sector, the number of sectors to read and the transfer address. This is illustrated below in Figure 3.2.

Undisplayed Graphic

Figure 3-2
Packet for Absolute Disk Read

Either the original format or the extended format may be used to address partitions smaller than 32Mb.

Table 3 4 Absolute Disk Read/Write Error Codes

AH Value Error
002 General error
03H Attempted write on protected diskette
04H Sector not found
08H Bad CRC on read
40H SEEK failed
80H Attachment failed to respond

3.7 INT 26H — Absolute Disk Write

Interrupt 26H
Absolute Disk Write
Entry Parameters:
Register AL: Drive number
CX: Number of sectors to write
DX: Beginning logical sector number
DS: Transfer address - Segment
BX: Transfer address - Offset
Returned Values:
Register AX: Error code, if Carry flag is set

Absolute Disk Write transfers data from memory to a specified location on disk. Like Absolute Disk Read (INT 25H), it uses a logical sector number to specify the disk location. The extended format described for INT 25H is also available for INT 26H. Return values are also handled in the same way. See Table 3-4 for error code definitions.

3.8 INT 27H — Terminate and Stay Resident

Issuing Interrupt 27H allows programs of less than 64K bytes to remain resident when the DR-DOS command processor regains control from the program. Programs that terminate but remain resident do not close files before returning control to DR-DOS. To improve the use of memory a program should call Free Allocated Memory (49H) with ES set to the segment contained in the word at offset 2CH of the PSP, before terminating with INT 27H. This de-allocates the block of memory containing the copy of the environment.Function call Keep Process (31H) allows the program to pass a completion code which can be interpreted within a batch file.

The INT 22H, INT 23H and INT 24H fields of the Interrupt table are restored to the values they contained when the program was loaded into the PSP. For this reason this method cannot be used to install a permanently resident Ctrl-Break or critical error handler routine.

Note that whenever possible Keep Process (31H) should be used instead of INT 27H to keep the program resident. INT 27H cannot be used for programs larger than 64K bytes, or by .EXE programs that are loaded into high memory.

3.9 INT 2FH — Multiplex Interrupt

INT2FH is a general-purpose interrupt. The function performed is determined by the value passed in register AH. You may add functions by saving the contents of the INT 2FH vector and installing your own INT 2FH handler. Any additional function should check for its specific function code, perform its function if indicated, and then return; otherwise, if there is no specific function code, it should pass control to the saved interrupt handler entry point.

Function codes 0 to 7F Hex are reserved for internal use. One function, the PRINT spooler function, is available for general use**.**

INT 2FH PRINT spooler function (AH = 1)

Requests to the resident PRINT spooler allow files to be added to or removed from the spool queue, and enable the spool queue to be read**.**

Print Request Get Installed State
Entry Parameters:
Register AL: 0
Returned Values:
Register AL: Printer status
0 = PRINT not installed, may be installed
1 = PRINT not installed, may notbe installed
ff = PRINT installed
Print Request Add File to Spool Queue
Entry Parameters:
Register AL: 1
Register DS:DX Request data address - offset 0 = 0 offset 1 = doubleword pointer (offset & segment) to null-terminated ASCII file specification. Wildcards are not allowed in the file specification.
Returned Values:
Register AX: Error code if Carry flag set
Print Request Remove File from Spool Queue
Entry Parameters:
Register AL: 2
Register DS:DX Null-terminated ASCII file specification, which may contain wildcard characters.
Returned Values:
Register AX: Error code if Carry flag set
Print Request Remove All Files from Spool Queue (includes the file that is currently printing)
Entry Parameters:
Register AL: 3
Returned Values:
Register AX: Error code if Carry flag set
Print Request Lock Spool Queue so it can be Read
Entry Parameters:
Register AL: 4
Returned Values:
Register AX: Error code if Carry flag set
DX: Count of print device errors since last successful output (if non-zero this normally indicates that the printer is off-line or out of paper)
DS:SI: Spool queue - consists of a list of entries each 64 bytes long, containing a null-terminated file specification. The end of the queue is indicated by an entry with a null character in the first byte.
Print Request Unlock Spool Queue
Entry Parameters:
Register AL: 5
Returned Values:
None

3.9.1 PRINT Spooler Request Error Codes

Request types 1 to 4 return Carry flag clear if there was no error. If the Carry flag is set, register AX contains the error codes shown in Table 3-5.

Table 3 5 PRINT Spooler Request Error Codes

AX Value Meaning
1 Invalid request code
2 File not found
3 Path not found
4 No file handles available(too many open files)
6 File could not be opened
8 Spool queue full
9 Spool queue is locked
12 Filename too long (maximum is
15 Drive invalid

[Front] [Prev Chapter] [Next Chapter]


info@caldera.com

Copyright © 1993, 1997 Caldera, Inc All rights reserved.