< Previous | Contents | Next >
B: DOS Interrupts – INT 20h to 27h | ||
The following is intended to be a guide to the main (user) interrupts provided in DOS Plus 2.1 for the 512. However, if fully detailed specifications of the calls as implemented in MS-DOS or PC-DOS are required there are many excellent books available covering the subject.
Each of the 512's DOS Plus supported user interrupts between 20h and 27h is shown with any entry conditions and returned values. The operation and purpose is described with brief appropriate additional comments.
This is one of several calls by which a program can terminate execution. It informs DOS that the program is complete and that occupied memory should be released.
Action: |
On execution the call restores vectors for INTs 22h to 24h from the program's PSP, flushes any buffers and transfers control to the terminate handler address. |
|
On entry: |
CS = Segment address of PSP |
|
Returns: |
Nothing |
|
Notes: |
The preferred termination method is INT 21h function 4Ch. Since this call has a memory addressing limit of 16 bits, (64k bytes) it is of limited use, and cannot be used in an EXE program. |
Most of the general functions and services offered by DOS are implemented through this interrupt . The functions available are well standardised and should be common to all MS-DOS, PC-DOS and DOS Plus systems. Well behaved programs, therefore, should use these facilities in preference to any other methods available for the widest range of compatibility.
INT 21h in the 512's implementation of DOS Plus 2.1 provides 77 official functions, two of which are non-functional and return with no action. Within this range some calls have subfunctions which further extend the range of operations.
In all calls, on entry AH defines the function. Other parameters may also be required in other registers. Where a memory block is used by the call this is specified in the normal segment:offset form. In all cases the general programming technique is to set AH to the function number, set up the required register contents (and the memory block if necessary) then to issue the call by the assembly code INT instruction. To call the recommended program terminate routine, INT 21h function 4Ch, the relevant parts of the code would be:
; Constant equates
Prog_exit equ 4ch
Function_despatcher equ 21h
org 0100
program code here
.......
.......
.......
exit: ; Common program exit
point mov al, Return_code ; Set up result
mov ah, Prog_exit ; Set up terminate
; process
int Function_despatcher ; And leave
; Variable data
Return_code db ? ; Default 0 = success
; Set value on failure
END
There are other methods of implementing INT calls, but they are not recommended as normal techniques and are less efficient. The two most likely to be encountered are included here only for infomation.
1. | Setting up the entry conditions and executing a long call to 0050h in the PSP
(only works in DOS v.2+). |
|
2. | Loading the CL register with the function number and executing an intra-segment call to offset 0050h in the PSP, which contains a long call to the function despatcher. This method only works for function calls of 24h or less, and has the further disadvantage that the contents of register AX are always destroyed. |
If calls are made by the approved method the contents of all registers are preserved through calls, except where those registers are used to return results. The obvious exception to this is function 4Bh, EXEC, which transfers control to a spawned program, when the state of all registers except the instruction pointers, but including the stack pointers, should be treated as undefined unless specific returned values are expected.
If spawning is employed register contents which must be be preserved should be pushed onto the stack, and the stack registers themselves (ie SS:SP) should be saved in known memory locations for explicit later retrieval.
INT 21h functions 00h to 24h are based on and are, with a few exceptions, direct equivalents of the corresponding CP/M calls. In these calls success or failure is typically signalled by the value returned in register AL. For the remaining (ie MS-DOS) calls, the carry flag is more usually used, carry clear indicating success, carry set indicating failure of the function, often accompanied by an error code in register AX.
Functions up to and including 57h are documented in this section, all INT 21h functions with a higher number applying to later versions of DOS than 2.11. Note that functions 32h, 34h and 50h and above are included, though they are not supported by DOS Plus, because these do occur in MS-DOS version 2.0 and above and might be encountered in MS-DOS v2.0 programs.
Action: |
On execution the call restores vectors for INTs 22h to 24h from the PSP, flushes any buffers and transfers control to the terminate handler address. |
|
On entry: |
AH = 0 |
|
Returns: |
Nothing |
|
Notes: |
Equivalent of CP/M BDOS call 00h. INT 21h function 4Ch is preferred. |
Action: |
Reads a character from the standard input device and echoes it to the standard output device. If no character is ready it waits until one is available. I/O can be re-directed, but prevents detection of EOF. |
|
On entry: |
AH = 01h |
|
Returns: |
AL = 8 bit data input |
|
Notes: |
Equivalent to CP/M BDOS call 01h, except that if the character is CTRL-C an INT 23h is performed. |
Action: |
Outputs a character to the standard output device. I/O can be re-directed, but prevents detection of 'disc full'. |
|
On entry: |
AH = 02h |
|
Returns: |
Nothing |
Action: |
Reads a character from the current auxilliary device. |
|
On entry: |
AH = 03h |
|
Returns: |
AL = 8 bit data input |
|
Notes: |
There is no way to read the status of the serial port or to detect errors through this call, therefore most PC comms packages drive the hardware directly, hence their general incompatibility with the 512. |
Action: |
Outputs a character to the current auxiliary device. |
|
On entry: |
AH = 04h |
|
Returns: |
Nothing |
|
Notes: |
There is no way to read the status of the serial port or to detect errors through this call. Comments as Function 3. |
Action: |
Sends a character to the current listing device. |
|
On entry: |
AH = 05h |
|
Returns: |
Nothing |
|
Notes: |
If the printer is busy this call will wait until the data is sent. There is no way to poll the printer status in DOS. |
Action: |
Reads a character from the standard input device or returns zero if no character available. Also can write a character to the current standard output device. I/O can be redirected but prevents detection of EOF on input or 'disc full' on output. |
|
On entry: |
AH = 06h |
|
Returns: |
If output – nothing |
|
Notes: |
This call ignores CTRL-X. |
Action: |
Reads a character from the standard input device without echoing it to the display. If no character is ready it waits until one is available. |
|
On entry: |
AH = 07h |
|
Returns: |
AL = 8 bit data input |
|
Notes: |
This call ignores CTRL-C. Use function 8 if CTRL-C processing is required. There is no CP/M equivalent. |
Action: |
Reads a character from the standard input device without copying it to the display. If no character is ready it waits until one is available. |
|
On entry: |
AH = 08h |
|
Returns: |
AL = 8 bit data input |
|
Notes: |
If CTRL-C is detected INT 23h is executed. |
Action: |
Writes a string to the display. |
|
On entry: |
AH = 09h |
|
Returns: |
Nothing |
|
Notes: |
The string must be terminated by the $ character (24h) which is not transmitted. Any ASCII codes can be embedded within the string. |
Action: |
Reads a string from the current input device up to and including an ASCII carriage return (0Dh) placing the received data in a user-defined buffer. Input can be redirected, but this prevents detection of EOF. |
|
On entry: |
AH = 0Ah |
|
Returns: |
Nothing |
|
Notes: |
The first byte of the buffer specifies the maximum number of characters it can hold (1 to 255). This value must be supplied by the user. The second byte of the buffer is set by DOS to the number of characters actually read, excluding the terminating RETURN. If the buffer fills to one less than its maximum size the bell is sounded and subsequent input is ignored. If a CTRL-C is detected an INT 23h is executed. Normal DOS keyboard editing is supported during input. |
Action: |
Checks whether a character is available from the standard input device. Input can be redirected. |
|
On entry: |
AH = 0Bh |
|
Returns: |
AL = 0 if no character available |
|
Notes: |
If an input character is waiting this function continues to return a true flag until the character is read by a call to function 1, 6, 7, 8 or 0Ah. |
Action: |
Clears the standard input buffer then invokes one of the standard input functions. |
|
On entry: |
AH = 0Ch |
|
Returns: |
If function 0Ah – Nothing |
|
Notes: |
The purpose of this function is to ignore any type-ahead data and force a wait for new character input which must occur after the call is issued. |
Action: |
Flush all outstanding file buffers by physically updating to disc. |
|
On entry: |
AH = 0Dh |
|
Returns: |
Nothing |
|
Notes: |
This call does not update disc directories for any open files. If the program fails to close files before the disc is removed and the files have changed size, their directory entries will be incorrect. |
Action: |
Sets the specified drive to be the default drive and returns the total number of logical drives in the system. |
|
On entry: |
AH = 0Eh |
|
Returns: |
AL = the number of logical drives in the system. |
|
Notes: |
In the 512's DOS Plus (2.1) this call always returns five as the number of logical drives, though a maxirnum of four are supported. <But see here – YP> |
Action: |
Opens a file and makes it available for read/write operations. |
|
On entry: |
AH = 0Fh |
|
Returns: |
AL = 0 if file found |
|
Notes: |
This call requires a user allocated memory control block. If the call is successful the FCB data is filled by DOS. |
Action: |
Closes a file and updates the directory if the file has been modified. |
|
On entry: |
AH = 10h |
|
Returns: |
AL = 0 if directory updated successfully |
|
Notes: |
This call may only be used after a file has been successfully opened and an FCB created. |
Action: |
Search for a specified filename in the current directory of the current drive. |
|
On entry: |
AH = 11h |
|
Returns: |
AL = 0 if matching filename found |
|
Notes: |
It is important to use INT 21h function 1Ah to set the DTA to a buffer of adequate size before using this call. In MS-DOS v2 only the '?' wildcard is permitted. If wildcards are specified the first matching name is returned. If an extended FCB is used, an attribute byte determines the type of files searched for. INT 21h function 4Eh is preferred to this call. |
Action: |
Searches the current directory in the current drive for the next matching filename after a previously successful call to function 11h. |
|
On entry: |
DS:DX = segment:offset of the FCB |
|
Returns: |
AL = 0 if matching filename found |
|
Notes: |
As for Function 11h. Function 4Fh is preferred. |
Action: |
Deletes all matching files from the current directory. |
|
On entry: |
AH = 13h |
|
Returns: |
AL = 0 if matching file(s) deleted |
|
Notes: |
The '?' wildcard is permitted. If more than one match occurs all matched filenames will be deleted. |
Action: |
Reads the next sequential block of data from a file and increments the file pointer. |
|
On entry: |
AH = 14h |
|
Returns: |
AL = 0 if successful |
|
Notes: |
The record is read into memory at the DTA address specified by the most recent call to function 1Ah. The size of the block read is specified by the record size field in the FCB. |
Action: |
Writes the next sequential block of data to a file and increments the file pointer. |
|
On entry: |
AH = 15h |
|
Returns: |
AL = 0 if successful |
|
Notes: |
The record is written from memory at the DTA address specified by the most recent call to function 1Ah. The size of the block written is specified by the record size field in the FCB. |
Action: |
Creates a new entry in the current directory for the named file, or truncates the length of an existing file of the given name to zero length. The file is opened for read/wnte access. |
|
On entry: |
AH = 16h |
|
Returns: |
AL = 00h if successful |
|
Notes: |
Notes: This call is the equivalent of 'OPENOUT' in BBC BASIC and should be used with care. By using an extended FCB and setting the appropriate bit the opened file may be assigned an attribute. To create files in other directories use function 3Ch. |
Action: |
Renames all matching files in the current directory |
|
On entry: |
AH = 17h |
|
Returns: |
AL = 0 if successful |
Action: |
Returns the drive code of the current or default drive. |
|
On entry: |
AH = 19h |
|
Returns: |
AL = drive code (0 = A:, 1 = B: etc) |
|
Notes: |
Some DOS functions use drive codes starting at 1 (eg function 1Ch) reserving zero for the current dnve. |
Action: |
Specifies the memory area to be used for subsequent FCB operations. |
|
On entry: |
AH = 1Ah |
|
Returns: |
Nothing |
|
Notes: |
If this function is not used by a program, the DTA defaults to a 128 byte buffer in the PSP at 080h, the area used to hold the original command tail, which will then be destroyed by any disc activity. It is the programmer's responsibility to ensure that the DTA is large enough for any relevant disc operation. The only exception is that DOS will abort any transfer which would wrap around within the segment. This function must be called before using functions 11h, 12h, 14h or 4Fh, to ensure that DOS has a large enough scratch area when searching directories. |
Action: |
Obtains selected information about the current disc drive and a pointer to the identification byte of the FAT. |
|
On entry: |
AH = 1Bh |
|
Returns: |
If successful |
|
Notes: |
DS:BX points only to the FAT information byte. To read the contents of the FAT into memory use INT 25h. To obtain infomation about discs other than the default drive use function 1Ch. See also function 36h which returns similar data. |
Action: |
Action: As for Function 1Bh, but any drive can be specified. |
|
On entry: |
AH = 1Ch |
|
Returns: |
If successful |
|
Notes: |
Except for the ability to specify a drive this call is the equivalent of Function 1Bh. |
Action: |
Reads a selected record from an opened file. |
|
On entry: |
AH = 21h |
|
Returns: |
AL = 0 if successful |
|
Notes: |
The record is read into memory at the DTA address specified by the most recent call to Function 1Ah. The size of the block read is specified by the record size field in the FCB. If the size of the DTA and the record are such that segment wrap occurs, the call fails with a return code of 2. If a partial record read occurs the remaining space is padded with zeros. The current file pointer is not advanced after this function. |
On entry: |
AH = 22h |
|
Returns: |
AL = 0 if successful |
|
Notes: |
The record is written from memory at the DTA address specified by the most recent call to Function 1Ah. The size of the block written is specified by the record size field in the FCB. If the size of the record and the location of the DTA are such that segment wrap occurs, the call fails with a return code of 2. |
Action: |
Returns the record count of a matching file. |
|
On entry: |
AH = 23h |
|
Returns: |
AL = 0 if matching file found |
|
Notes: |
Before using this call you must set an appropriate record size in the FCB's record size field. After the call the random record field is set to the record count of the specified file. |
Action: |
Sets the random record field of an FCB to correspond to the current file position as recorded in the opened FCB. |
|
On entry: |
AH = 24h |
|
Returns: |
Nothing. The random record field in the FCB is updated |
|
Notes: |
This function is used to change from sequential to random I/O file access. |
Action: |
Initialises an interrupt vector to point to the supplied address. |
|
On entry: |
AH = 25h |
|
Returns: |
Nothing |
|
Notes: |
This is the approved way to amend interrupt vector contents. Before changing the contents of a vector, Function 35h should be used to obtain the original entry, which should be re-instated when your code terminates. The only exceptions to this rule are interrupt vectors 22h to 24h, which are automatically restored from the PSP on program termination. |
Action: |
Copies the PSP of the current program to a specified segment address in free memory, then updates the new PSP to make it usable by a new program. |
|
On entry: |
AH = 26h |
|
Returns: |
Nothing |
|
Notes: |
This call has been rendered obsolete by EXEC, Function 4Bh in DOS 2.0 and later and should no longer be used. |
Action: |
Reads one or more sequential records from an open file starting at the file's current record position |
|
On entry: |
AH = 27h |
|
Returns: |
AL = 0 if all requested records read |
|
Notes: |
The records are read into memory at the DTA address specified by the most recent call to Function 1Ah. The size and number of blocks read is specified by the random record and the record size field in the FCB. If the size and location of the DTA and the number of records to be read are such that segment wrap occurs, the call fails with a return code of 2, possibly after reading one or more records. If a partial record read occurs at the end of the file the remaining record space is padded with zeros. The random record, current block and current record fields are updated after this function. The call is similar to Function 21h except that multiple blocks are permitted. |
Action: |
Write one or more sequential records to an open file starting at the file's current record position. |
|
On entry: |
AH = 28h |
|
Returns: |
AL = 0 if all requested records written |
|
Notes: |
The records are written from memory at the DTA address specified by the most recent call to Function 1Ah. If the size and location of the DTA and the number of records to be written are such that segment wrap occurs the call fails with a return code of 2, possibly after writing one or more records. The random record, current block and current record fields are updated after this function. The call is similar to Function 21h except that multiple records may be read. If the call is executed with zero in CX no data is written, but the file length is set to the value implied by the current random record field and the record size. This call is similar to function 22h, except that multiple records may be written. |
Action: |
Parses a text string into the various fields of an FCB. |
|||||||||||||||||
On entry: |
AH = 29h
DS:SI = Segment:offset of text string |
|||||||||||||||||
Returns: |
AL = 0 if no global (wildcard) characters encountered |
|||||||||||||||||
Notes: |
Permitted separators are: - : . ; , = + TAB and SPACE. The call regards all control characters, the above separators (when trailing) and < > | / " [ and ] as terminating characters. If no valid filename is present the contents of ES:DI+1 is a blank. If a '*' occurs in an extension, it and all remaining characters in the FCB are set to '?'. This function (and FCBs in general) cannot be used with file specifications which include a path. |
Action: |
Returns the system day, month and year plus the day of the week. |
|
On entry: |
AH = 2Ah |
|
Returns: |
CX = year (1980 to 2099) |
|
Notes: |
The format of the registers returned by this call is the same as that required by Function 2Bh. Although shown above as decimal values for clarity, all values are in hex. |
Action: |
Reset the date held in the system clock |
|
On entry: |
AH = 2Bh |
|
Returns: |
AL = 0 if successful |
|
Notes: |
The system time of day is unaffected by this call. |
Action: |
Returns the time of day as held by the system clock. |
|
On entry: |
AH = 2Ch |
|
Returns: |
CH = hour(0 to 23) |
|
Notes: |
The register format returned by this call is the same as that required by Function 2Dh. |
Action: |
Sets the time of day held in the system clock. |
|
On entry: |
AH = 2Dh |
|
Returns: |
AL = 0 if time reset successfully |
Action: |
Sets or cancels the system read after write verify flag. |
|
On entry: |
AH = 2Fh |
|
Returns: |
Nothing |
|
Notes: |
This call is intended to provide increased data integrity by allowing read after write verification on all data written to disc. It is the equivalent to the DOS command VERIFY and, like the manual command, is non-functional in DOS Plus 2.1. |
Action: |
Returns the segment:offset of the current DTA for read/write operations. |
|
On entry: |
AH = 2Fh |
|
Returns: |
ES:BX = Segment.offset of current DTA |
|
Notes: |
If the DTA has not been explicitly set it defaults to 080h in the PSP. |
Action: |
Returns the version number of the Operating System. |
|
On entry: |
AH = 30h |
|
Returns: |
AL = Major version number (e.g. 2.10 = 2) |
|
Notes: |
In the 512 this call returns 2.11. |
Action: |
Terminate program execution but leave memory allocated. |
|
On entry: |
AH = 31h |
|
Returns: |
Nothing |
|
Notes: |
TSR programs are usually re-entered by having previously re-directed an interrupt vector to point back into the code. In this way the program may be re-entered as a result of normal system activity, or as a result of an explicit call by another program. |
Action: |
Returns the pointer to the specified disc drive information block |
|
On entry: |
AH = 32h |
|
Returns: |
AL = 0 if drive valid |
|
Notes: |
This call is unofficial and is not supported by DOS Plus. |
Action: |
Returns or sets the CTRL-BREAK action |
|
On entry: |
AH = 33h |
|
Returns: |
DL = 0 if CTRL-BREAK checking off |
|
Notes: |
Notes: This command is the functional equivalent of the DOS command BREAK. Like that command, in the 512 this call is non-functional. |
Action: |
Returns the number of currently active processes |
|
On entry: |
AH = 34h |
|
Returns: |
ES:BX = Segment:offset of active byte address |
|
Notes: |
This call is unofficial and is not supported by DOS Plus. In MS-DOS it is mainly used by TSRs. |
Action: |
Returns the segment:offset of a nominated vector. |
|
On entry: |
AH = 35h |
|
Returns: |
ES:BX = Segment offset of interrupt vector contents |
|
Notes: |
This is the approved way to read interrupt vector contents. The original contents of the vector, after storage, can be amended by a call to function 25h. |
Action: |
Gives the number of free clusters on a specified disc. |
|
On entry: |
AH = 36h |
|
Returns: |
If specified drive valid: |
|
Notes: |
Similar information is returned by functions 1Bh and 10h |
Action: |
Reading geographically variable system constants. |
|||||||||
On entry: |
AH = 38h |
|||||||||
Returns: |
If unsuccessful Carry flag set If successful the 32 byte block contents are as follows. 5 byte currency symbol field, null terminated 1 byte bit field currency format:
1 byte time format: Bit 0: clear for 12 hour clock, set for 24 hour clock 2 words for case map call address |
|||||||||
Notes: |
Unlike its MS-DOS counterpart, this call does not permit the stored information to be amended. |
Action: |
Creates a new subdirectory using the specified drive and path data. |
|||||||||||||
On entry: |
AH = 39h |
|||||||||||||
Returns: |
Carry: clear if successful, set if unsuccessful, when: |
|||||||||||||
Notes: |
The function fails if:
|
Action: |
Deletes a specified subdirectory. |
|||||||||||||
On entry: |
AH = 3Ah |
|||||||||||||
Returns: |
Carry clear if succesful |
|||||||||||||
Notes: |
The function fails if:
|
Action: |
Sets the specified directory to be the current directory. |
|
On entry: |
AH = 3Bh |
|
Returns: |
Carry clear if successful, |
|
Notes: |
The call fails if any part of the pathname does not exist. Commonly the current directory is ascertained by a call to function 47h, then stored by a program so the original current directory can be reset on completion of operations. |
Action: |
Creates a new entry in the specified directory on the specified drive for the named file, or truncates the length of an existing file of the given name and path specification to zero length. The file is opened for read/write access and a 16 bit handle is returned for future access. |
|||||||||||||
On entry: |
AH = 3Ch |
|||||||||||||
Returns: |
Carry clear if successful: AX = file handle |
|||||||||||||
Notes: |
The function fails if:
|
Action: |
Opens a file in the specified or default directory on the specified drive for the named file. A 16-bit handle is returned for future access. |
|||||||||
On entry: |
AH = 3Dh |
|||||||||
Returns: |
Carry clear if successful: AX = file handle |
|||||||||
Notes: |
Any normal system or hidden file with a matching name will be opened by this function. On return the read/write pointer is set to zero, the start of the file.The call fails if:
|
Action: |
Closes a successfully opened file. All buffers are flushed to disc and the file handle is freed for re-use. If the file was modified, the date and time stamps and the file length are updated in the directory entry. |
|
On entry: |
AH = 3Eh |
|
Returns: |
Carry clear if successful, set if failed, when AX = error code 6, invalid handle or not open |
|
Notes: |
In MS-DOS calling this function with a handle of zero closes the standard input device! DOS Plus does not suffer from this bug. |
Action: |
Reads a specified number of bytes from a successfully opened file or device. |
|
On entry: |
AH = 3Fh |
|
Returns: |
Carry clear if successful |
|
Notes: |
If reading from a character device in cooked mode, a maximum of one line will be read, as a carriage return (0Dh) is treated as a record terminator. If the carry flag is clear and AX is less than CX a partial record was read or there was an error. |
Action: |
Reads a specified number of bytes from a successfully opened file or device. |
|
On entry: |
AH = 40h |
|
Returns: |
Carry clear if successful, when |
|
Notes: |
If the carry flag is clear and AX is less than CX, this means that a partial record was written or there was an error. |
Action: |
Deletes a file from the specified or default disc and directory. |
|||||||||
On entry: |
AH = 41h |
|||||||||
Returns: |
Carry clear if successful, set if failed, when AX = Error code as follows: |
|||||||||
Notes: |
This deletes a file by deleting its directory entry. The ASCIIZ string specifying the file may not include wildcards. The function fails if:
|
Action: |
Sets the file pointer to the specified position relative to the start or end of the file, or to the current pointer location. |
|
On entry: |
AH = 42h, |
|
Returns: |
Carry clear if successful |
|
Notes: |
The method code determines the relative base for the pointer move, which uses a 32-bit integer to set the new location. Method 2, if called with an offset of zero returns the length of the file as the new pointer value. Method 1 or 2 can set the pointer to a location before the start of the file, but an error will occur if a subsequent attempt is made to use this pointer location. For all methods (and results) the returned pointer location is always an absolute byte offset from the start of the file. |
Action: |
Obtains or sets the attributes of the specified file. |
|
On entry: |
AH = 43h |
|
Returns: |
Carry clear if successful, |
|
Notes: |
This function cannot be used to set a file's volume label bit (3), or the sub-directory bit (4). These may only be changed by using an extended FCB. |
Action: |
Passes information directly between an application and a device driver. |
|
On entry: |
AH = 44h |
|
Returns: |
Carry clear if successful |
|
Notes: |
This call is a partial implementation of the full MS/PC-DOS function, as it only supports status checking in the 512. |
Action: |
Returns a second handle for a file or device which has already been successfully opened. |
|
On entry: |
AH = 45h |
|
Returns: |
Carry clear if successful |
|
Notes: |
If the file pointer attached to one handle is implicitly moved by a seek, read or write, the pointer for the other handle is also moved. The purpose of this call is to force directory updating for a file without having to close it (and then re-open it). After obtaining the new handle, the logical file associated with it is closed by function 3Eh, forcing a directory update, but leaving the original handle available for further input/output operations. |
Action: |
Given two handles, make the second refer to the same file at the same point as the first. |
|
On entry: |
AH = 46h |
|
Returns: |
Carry clear if successful, set if failed when AX = Error code |
|
Notes: |
If the handle specified in CX already refers to an open file, that file is closed before this function is performed. After the call, if the file pointer attached to one handle is implicitly moved by a seek, read or write, the pointer for the other handle is also moved. |
Action: |
Obtains the ASCIIZ string of the current directory's path. |
|
On entry: |
AH = 47h |
|
Returns: |
Carry clear if successful, full directory pathnarne is placed in the buffer. |
|
Notes: |
The returned pathname does not include the drive ID, nor is it prefixed with a '\'. It is terminated by a null byte, therefore if this call is issued from the root directory, the first byte in the buffer will be zero. |
Action: |
Allocates a block of memory and returns a pointer to the start of the area. |
|
On entry: |
AH = 48h |
|
Returns: |
Carry clear if successful when AX = first segment of allocated block |
|
Notes: |
If the call succeeds AX:0000 points to the start of the block. When a COM file loads, it conceptually owns all the remainder of memory from its PSP upwards. This call may be used to lirnit a program's memory allocation to its immediate requirements. |
Action: |
Releases memory to make it available to other programs. |
|
On entry: |
AH = 49h |
|
Returns: |
Carry clear if successful, set if failed when AX = Error code as follows: |
|
Notes: |
This call modifies the size of a block of memory previously allocated through Function 48h. The call must be used by a COM program to release all unused memory before spawning by means of EXEC, Function 4Bh. EXE programs may also use this call. |
<Function 4Ah (Modify memory allocation in MS-DOS) is not mentioned here in the original book, though it is listed in the tables in Appendix A – YP>
Action: |
Loads a program for execution under the control of an existing program. By means of altering the INT 22h to 24h vectors, the calling prograrn can ensure that, on termination of the called program, control returns to itself. |
|
On entry: |
AH = 4Bh |
|
Returns: |
Carry clear if successful. On return all register contents are destroyed, including the stack pointers. |
|
Notes: |
To protect the caller's register contents they should be pushed on the stack and the stack pointers SS:SP stored in a known location before the call. On return these should be retrieved immediately with interrupts disabled to prevent interrupts occuring before stack integrity is regained. The ASCIIZ pathname must include the drive, path and filename of the program to be loaded. The environment block must be paragraph-aligned and consist of one or more ASCIIZ strings, all terminated by an extra zero byte. Command tails are in the usual format for PSPs, that is, a count byte and the command tail terminated by a carriage return, which is not included in the count. All active handles, devices and I/O redirection assignments in the calling program are inherited by the executed program. |
Action: |
Terminates execution of a program with return to COMMAND.COM or a calling routine, passing back a return code. Allocated memory is freed, vectors for interrupts 22h to 24h are restored from the PSP and all file buffers are flushed to media. All files are closed and directories are updated. |
|
On entry: |
AH = 4Ch |
|
Returns: |
Nothing |
|
Notes: |
This is the approved method of terminating program execution. It is the only way that does not rely on the contents of any segment register and is thus the simplest exit, particularly for EXE files. The return code can be interrogated by a calling program by means of function 4Dh, and by the batch file command IF ERRORLEVEL. Conventionally a return code of zero indicates success, any other value failure. Standard DOS return codes are: 0: Successful operation Return code values can be used at the discretion of the programmer (avoiding codes 1 to 3), thus both success or a wide range of failure types may be indicated by varying the code. For the return of result codes to the caller by an EXECed program a better method is to use other registers, but only the contents of register AL are significant to the batch command ERRORLEVEL. |
Action: |
Used by a parent task to obtain the return code of a program executed by a call to function 4Bh. |
|
On entry: |
AH = 4Dh |
|
Returns: |
AH = Exit type: |
|
Notes: |
This call is a 'one-shot' function, that is, it will yield the return code of a called program once only. |
Action: |
Searches the default or specified drive:directory for the first occurrence of a matching filename. |
|||||||||||||||||||||||||||||||||
On entry: |
AH = 4Eh |
|||||||||||||||||||||||||||||||||
Returns: |
CX = Attribute to use in search |
|||||||||||||||||||||||||||||||||
Notes: |
CX = 0 if successful. The current DTA is filled as follows:
Carry set if failed, AX = Error code as follows This call assumes the DTA has been set up by a successful call to function 1Ah. Both wildcards (? and *) are permitted in filenames, but only the first matching name is returned. If the attribute in CX is zero only normal files are searched. If the volume label attribute bit is set only volume labels are returned. For all other attribute settings (ie hidden, system or directory) those files and normal files are searched. |
Action: |
Searches for the next matching file after a previously successful call to Function 4Eh. |
|||||||||||||||||||||||||||||||||
On entry: |
AH = 4Fh |
|||||||||||||||||||||||||||||||||
Returns: |
Carry clear if successful
Carry set if failed, AX = Error code |
|||||||||||||||||||||||||||||||||
Notes: |
When used this call requires a DTA containing returned data from a previously successful call to function 4Eh or 4Fh. Use of function 4Fh is only relevant when the original file specification used in function 4Eh included at least one wildcard. |
Action: |
Returns a pointer to the disc information block. |
|
On entry: |
AH = 50h |
|
Returns: |
AL = 0 if drive exists |
|
Notes: |
This call is unofficial and is not supported by DOS Plus. |
Action: |
Reads the current state of the verify flag. |
|
On entry: |
AH = 54h |
|
Returns: |
AL = 0 if verify off |
|
Notes: |
This call is the counterpart of function 2Eh. In DOS Plus AL is always returned as zero. |
Action: |
Renames a file and or moves its directory entry to a different directory on the disc. |
|||||||||||||||||
On entry: |
AH = 55h |
|||||||||||||||||
Returns: |
Carry clear if successful |
|||||||||||||||||
Notes: |
The call fails if:
|
On entry: |
AH = 57h |
|
Returns: |
Carry clear if successful |
|
Notes: |
The file must have been previously opened or created by a call to function 3Ch or 3Dh. For simplicity the date and time formats are shown above in the sequence they are stored in the directory. |
This completes the list of INT 21h function codes valid in DOS PIus 2.1. Functions 58h and above are only available in versions of MS-DOS later than 2.11, and with the exception of function 63, later than version 3.0.
Interrupts 22h through 24 are not user callable and are therefore not documented (see chapter 8).
Action: |
Provides a direct link into the XIOS to allow data to be read from a specified memory location to disc, starting at a specified logical disc sector into a specified memory location. |
|
On entry: |
AL = Drive number (0 = A:, 1 = B: etc) |
|
Returns: |
Carry clear if successful AH = |
|
Notes: |
All register contents except those of the segment registers may be destroyed. When this call returns, the CPU flags, originally pushed onto the stack, are still on the stack. The calling program should issue a POPF instruction or ADD SP,2 to prevent uncontrolled stack growth and to make earlier data pushed on the stack accessible correctly. Logical disc sectors begin at one (unlike BBC media), so the total number of sectors per disc is also the number of the last sector. Sectors are read logically by this call so, although it performs as a hardware command, formatting skew factors are catered for. |
Action: |
Provides a direct link into the XIOS to allow data to be written from a specified memory location to disc, starting at a specified logical disc sector. |
|
On entry: |
AL = Drive number (0 = A:, 1 = B: etc) |
|
Returns: |
Carry clear if successful |
|
Notes: |
See INT 25h. All comments apply. |
Action: |
Terminates execution of the current program but reserves part or all of its memory so that it will not be overwritten by the subsequent programs. The vectors for interrupts 22h to 24h are restored from the program's PSP. Open files are not closed. |
|
On entry: |
DX = Offset of last byte+1 (relative to the PSP) to be protected |
|
Returns: |
Nothing |
|
Notes: |
This interrupt is typically used by programs which are to be re-entered by redirected interrupt vectors, but its use should be strictly avoided unless compatibility with MS-DOS v.1 is vital. The maximum amount of memory that can be theoretically reserved by this function is one segment (64k bytes), but must not be used in .EXE programs. In addition the call does not work correctly when DX contains a value in the range 08000h to 0FFFFh (32 to 64k bytes). <Original text says "0FFF1h to 0FFFFh (32 to 64k bytes)> The high bit is discarded by MS-DOS, resulting in a memory reservation of up to 32K bytes less than expected. The recommended call instead of this one is INT 21h function 31h, which works correctly and also allows any amount of memory to be reserved. |
< Previous | Contents | Next >