25% developed

First steps towards system programming under MS-DOS 7/Selected interrupt handlers

From Wikibooks, open books for an open world
Jump to navigation Jump to search


Clipboard

To do:
this whole chapter needs formatting


Chapter 8. Selected interrupt handlers

There are occasions when normal succession of CPU's operations has to be interrupted in order to respond to an urgent request. Interruptions can be initiated by both hardware and software. CPU itself invokes interrupts in case of unexpected errors (exceptions). Other hardware devices send their interrupt requests via interrupt controller lines IRQ 00 – IRQ 15. Programs cause "software" interrupts with INT command (7.03-28). In any case interrupt leads to execution of a certain interrupt handler subroutine which performs the requested action.

A large number of interrupt handlers is permanently present in computer's memory since computer is switched on. These handlers can be regarded as a library of standard subroutines. Effectiveness of your programming efforts depends largely on your skill in making use of this library.

Entry point addresses of interrupt handlers are stored in interrupt table. Different interrupt tables are used in CPU's real and protected modes.

Protected mode interrupt table is filled with 8-byte descriptors, specifying access rights and entry point addresses of interrupt handlers and API services. Selection of interrupt handlers, their arrangement and placement of interrupt table in memory are arbitrary regulated by that program or by that operating system, which controls computer's functioning in protected mode.

Contrary to that, real mode interrupt table is strictly institutionalized. In all AT-compatible computers it occupies the same memory area, from 0000:0000h to 0000:03FFh. It is filled not by descriptors, but by 4-byte addresses of interrupt handler's entry points. Unified addresses placement for particular BIOS functions constitutes the basis of software compatibility. The latter feature defines an important role of real mode interrupt table and induces our special interest in it.

After switching CPU to protected mode the real mode interrupt table is preserved intact and still may be addressed. Real mode interrupt handlers may be needed for specific motherboard hardware and for execution of DOS functions, called by programs from "DOS box". For the time of execution of real mode interrupt handlers the protected mode operating systems switch CPU back to real mode. Due to these hidden manipulations DOS programs inside "DOS box" are executed considerably slower, than in real mode.

Offset of any required address in real mode interrupt table is calculated automatically by multiplying interrupt number by 4. Each address is a double word pointer, which should be interpreted in reverse order: fourth and third bytes constitute segment address, second and first bytes constitute entry point offset. For example, dump 59 F8 00 F0 corresponds to handler's entry point address F000:F859h.

Any interrupt request implies that submitted address points at an entry point to handler's executable code. There are exceptions, though: offsets 0074h, 0078h, 007Ch, 0104h, 010Ch, 0118h in real mode interrupt table point at non-executable data tables (A.12-1). Corresponding numbers 1Dh, 1Eh, 1Fh, 41h, 43h, 46h can't be used to enumerate interrupts.

Interrupt table is partially filled by BIOS, generally up to INT 1C. The core of MS-DOS 7 adds its own pointers (most known INT 20 - INT 2E), and later almost each driver sets double-word (dword) pointer(s) to its own handler(s). At each step any previously loaded pointer may be replaced; some are overwritten more than twice. Thus interrupts may become intercepted by new handlers. Most often interrupt interception is intended to provide conditional access to new functions, otherwise readdressing the call to the former handler. For a large part of interrupts one can't be sure whether their handlers belong to BIOS or to DOS or to something else: it may depend on particular configuration settings in your PC.

Since interrupt handling depends on PC's BIOS and may be changed by software, MS-DOS 7 cannot be responsible for keeping it strictly defined once and for ever. The validity of results has to be checked after almost any interrupt call. Nevertheless there is a large number of API functions, which are preserved intact for compatibility reasons and almost certainly will be encountered in any PC under MS-DOS 7. Selected interrupt calls invoking such functions are described below in this chapter.

8.01 Interrupt handlers, loaded by PC's BIOS (INT 00 – INT 1C)[edit | edit source]

8.01-01 INT 00 – divide by zero error[edit | edit source]

If after DIV (7.03-21) or IDIV (7.03-24) commands the quotient overflows the result register, then CPU generates a call for INT 00h handler. The default INT 00 handler terminates execution of current program, displays a message : "Your program caused a divide overflow error…", and transfers control to DOS.

Note 1: If a call for INT 00 handler is initiated by CPU, then CPU leaves in stack a return address, pointing not to the next command, but to that division command, which has caused the overflow.

8.01-02 INT 01 – single step interrupt[edit | edit source]

If trap flag TF (A.11-4) in flags register is set, then CPU calls for INT 01 handler after execution of each command. This feature is used in order to trace execution of programs step-by-step. Besides that, modern CPUs, from model 80386 and on, have internal debugging registers (A.11-5), invoking INT 01 handler each time, when CPU addresses predefined memory region(s) or predefined port(s). INT 01 handler may also be invoked by execution of undocumented code F1h.

Instead of INT 01 handler's address the PC's BIOS system installs a reference to IRET command (7.03-30), which just returns CPU to execution of the next command.

Debugging utilities have to replace this reference in interrupt table by an address of their own handler, enabling to transfer control to that process, which has initiated execution of the program under test (for example, to debugger DEBUG.EXE).

Note 1: Trap flag TF is cleared after execution of each command, but its original state (the one before it has been cleared) is saved in stack together with return address just when INT 01 handler is called. Therefore INT 01 handler's code itself is performed while TF flag is cleared, but final handler's command IRET restores that original state of TF flag from stack.

Note 2: Return address, saved in stack at the moment INT 01 handler is called, usually points at the next command in a program under test. But when a call for INT 01 handler is invoked by a debugging register, then return address points just to that command, which has met the predefined condition. Flags in debugging register DR6 (A.11-5) enable to discriminate the cause of INT 01 call.

8.01-03 INT 02 – non-maskable interrupt[edit | edit source]

A call for INT 02 handler is caused by a signal sent to NMI (Non-Maskable Interrupt) CPU's pin. Contrary to other hardware interrupts, a call via NMI pin can't be blocked by CLI command (7.03-12) or by a mask in interrupt controller. INT 02 handler has a special mission: it responds to emergency accidents, for example, to memory failures. For most such accidents INT 02 handler displays an error message and halts further execution, bringing CPU to a standstill. In many PCs a signal sent to NMI pin informs about first symptoms of imminent power supply failure. In such cases INT 02 handler undertakes urgent actions, aimed to prevent data loss, and then returns control to interrupted process : it is given a chance to be resumed, if alarm turns to be false, and power supply failure really wouldn't happen.

Notes
  1. A call to CPU's NMI pin can be temporary blocked, if a byte with 7th bit set is sent by OUT command (7.03-66) to CMOS memory port 70h. This operation is implied to be followed by sending another byte to port 71h.[Note 1 to A.14-1] Blocking of NMI requests for the time of access to CMOS memory prevents distortion of CMOS data.

8.01-04 INT 03 – a breakpoint[edit | edit source]

When code CCh (7.03-28) is encountered in place of the first byte in machine command, then processor generates a call for INT 03 handler. Code CCh is usually inserted by debugging utilities in order to stop execution of the program under test at the desired point (breakpoint). In particular, just in this way breakpoints are set by debugger DEBUG.EXE.

Instead of INT 03 handler's address the PC's BIOS system installs a reference to IRET command (7.03-30), which just returns CPU to execution of the next command. Debugging utilities have to replace this reference in interrupt table by an address of their own handler, which is to serve the INT 03 calls.

8.01-05 INT 04 – response to overflow error[edit | edit source]

Contrary to interrupt INT 00, which compels to respond to overflow errors at once, interrupt INT 04 enables a retarded response to overflows, initiated by INTO command (7.03-29). Having encountered code CEh of INTO command, processor checks the state of overflow flag OF: if it is not cleared, the INT 04 handler is called for. The default INT 04 handler just returns control to the caller program. Each program is given an opportunity to replace the default INT 04 handler with its own INT 04 handler, providing a desirable response to overflow errors.

8.01-06 INT 05 – screen dump and boundaries check[edit | edit source]

Due to IBM's and Intel's mutually inconsistent technical decisions, the INT 05 real mode handler has been charged with two different missions.

In IBM-compatible PCs the BIOS installs interrupt INT 05 handler, which sends active screen page to printer. Printing procedure is initiated by user's Shift-PrtSc keystroke. Having identified this key combination, INT 09 handler (8.01-09) calls for IBM's INT 05 handler. The latter checks printer's status byte at address 0000:0500h in BIOS data area (A.12-1). States of printer status byte have the following meaning :

00h – printer is connected to LPT1 port and is ready ;
01h – printer is busy, previous task isn't finished yet ;
FFh – previous request to printer has failed.

If the status byte has 00h state, then active screen page is sent to LPT1 port and is printed.

Intel's processors, from model i80286 and on, call for INT 05 handler, if violation of bounds is detected by the BOUND machine command (code 62h). Obviously, this mission of INT 05 handler must be quite different.

The BOUND command is not "known" to DEBUG.EXE and this is why it is not described in chapter 7. In order to avoid conflicts, caused by using the BOUND command in real mode, the concerned program must install its own interrupt handlers, which are able to cope with the problem of call source ambiguity. This problem is not inherent to protected mode, because interrupt table for protected mode is arranged anew so that INT 05 calls are not charged with screen page printing mission.

Note 1: Original INT 05 handler is often replaced by another one, supplied by video card and invoked by PrtSc keystroke (8.01-66).

Note 2: If a call for INT 05 handler is induced by BOUND command, then CPU leaves in stack return address not of the next command, but of the BOUND command itself. Such calls shouldn't be directed to IRET command, because PC will get hanged in endless cycle of calls and returns.

8.01-07 INT 06 – invalid code exception[edit | edit source]

CPU responds with a call for INT 06 handler to invalid code execution attempts, in particular, to

  • protected-mode commands while processor works in real mode ;
  • applying LOCK prefix to commands, which don't write to memory ;
  • specifying register for commands, accepting memory operands only ;
  • command codes, which can't be recognized by CPU.

As far as a call for INT 06 handler is induced by any "unknown" machine code, INT 06 handlers are sometimes used in order to emulate commands of modern CPUs in PCs with obsolete CPU. But the default INT 06 handler just returns control back to the next command in the caller program.

8.01-08 INT 07 – coprocessor service exception[edit | edit source]

CPU calls for INT 07 handler in response to attempts to execute the ESC command (7.03-22) or any coprocessor's command (7.04), if in control register CR0 (A.11-4) its bit 02h ("Coprocessor emulation") is set. Bit 02h may be set intentionally in order to call for a handler, emulating coprocessor's functions. Some BIOS systems do it automatically in those PCs, which are not equipped with arithmetical coprocessor.

Modern PCs have arithmetical coprocessor integrated in main CPU, so that emulation of coprocessor's functions is not needed. Therefore INT 07 handler can be charged with another mission: undertaking of appropriate measures in response to registration of nonmasked exceptions in arithmetical coprocessor. For this purpose a call for INT 07 handler may be induced by WAIT prefix (7.02-05), if in control register CR0 (A.11-4) both bits 01h and 03h are set. In order to ignore the WAIT prefix, bit 01h in CR0 register should be cleared.

Implementation of any INT 07 mission implies loading of appropriate handler. The default INT 07 handler just returns control back to the next command in the caller program.

8.01-09 INT 08 – INT 0F: interrupt requests IRQ 0 – IRQ 7[edit | edit source]

While CPU is in real mode, the INT 08 – INT 0F group of interrupt handlers responds to requests, sent via IRQ 0 – IRQ 7 lines from various devices to the first interrupt controller. Some IRQ lines have dedicated hardware sources, listed in the fourth column of the following table, but some other IRQ lines are free to receive a request from any device, which is tuned to send requests via one of these lines and is supported by a driver, loading a handler for the corresponding interrupt.

Besides responding to external IRQ requests, some interrupt handlers in the same INT 08 – INT 0F group may be called by CPU in order to cope with certain specific errors (exceptions). Those exceptions, which may induce calls for INT 08 – INT 0F handlers in real mode, are described in notes to the following table. Interrupt controller doesn't register interrupt calls, generated by CPU. If a byte 0Ah is sent by OUT command (7.03-66) into port 20h of interrupt controller, then from the same port 20h the IN command (7.03-26) will be able to read a byte, marking reception of a request via each IRQ line by setting TRUE state of corresponding bit, specified in the third column of the following table. Cleared state of corresponding bit is an evidence that this particular interrupt is initiated by CPU.

If a call for interrupt handler is induced by exception, then CPU leaves in stack return address not of the next command, but of that current command, which has induced the exception call. This gives an opportunity to repeat the operation, if the cause of exception can be removed, but, on the other hand, such calls shouldn't be directed to IRET command, because PC will get hanged in endless cycle of calls and returns. If interrupt handler can't emend the situation, repetition must be prevented either by terminating execution or by correction of return offset in stack. Besides that, while the handler performs its job, reception of concurrent interrupt requests via interrupt controller must be blocked. This can be done by OUT command (7.03-66), sending into port 21h a mask byte with TRUE state of that bit, which corresponds to concurrent IRQ line, as it is shown in third column of the following table.

Interrupt Line Mask Source of requests Comments
INT 08 IRQ 0 bit 0 System timer Note *1
INT 09 IRQ 1 bit 1 Keyboard controller Note *2
INT 0A IRQ 2 bit 2 2nd interrupt controller Note *3
INT 0B IRQ 3 bit 3   Note *4
INT 0C IRQ 4 bit 4 Serial port COM 1 Note *5
INT 0D IRQ 5 bit 5   Note *6
INT 0E IRQ 6 bit 6 Floppy drive controller Note *7
INT 0F IRQ 7 bit 7 Parallel port LPT 1

Note 1: Calls for INT 08 handler proceed regularly 18.2 times per second in order to sustain time counting. In its turn, INT 08 handler invokes INT 1C (8.01-96), giving an opportunity to intercept the latter to application programs. INT 08 handler also can be called by CPU in case of "double fault" exception, which usually leads to reboot.

Note 2: The INT 09 handler senses each keystroke, controls keyboard buffer and prepares codes, shown in appendix A.02-1 and presented to application programs via INT 16. But INT 09 handler responds with explicit immediate actions only to a few key combinations, listed in article 1.01.

Note 3: The second interrupt controller accepts interrupt requests via lines IRQ 8 – IRQ 15 and induces calls to INT 70 – INT 77 handlers (8.03-75).

Note 4: Most probable source of interrupt requests for the IRQ 3 line is second serial port COM 2 (if it exists).

Note 5: The INT 0C handler also can be called by CPU in case of "stack overflow" exception, when stack grows beyond its predefined limit.

Note 6: The INT 0D handler can be called by CPU in case of segment limits violation exception, i.e. attempt to address code or data beyond predefined segment limits.

Note 7: A call for INT 0E handler may be initiated by CPU in response to an attempt to address "closed" memory pages (those, which can't be found in CPU's TLB buffer).

Note 8: Mapping of external requests IRQ 0 – IRQ 7 onto calls for INT 08 – INT 0F handlers can be changed by reprogramming interrupt controller, so that external requests wouldn't invoke those handlers, which are designed to cope with CPU's exceptions. Such reprogramming is usually performed in course of preparation to switching CPU into protected mode in coordination with formation of a new interrupt table for protected mode.

8.01-10 INT 10\AH=00h – setting of a videomode[edit | edit source]

Prepare : AH = 00h AL – code of videomode to be set (A.10-1) On return : AL contents may be altered

Note 1: This function switches all video cards, including modern ones, to videomodes, compatible with obsolete VGA video cards. Modern SVGA videomodes should be set by function INT 10\AX=4F02h.

Note 2: Code of current videomode is written in BIOS data area (A.10-6) at address 0040:0049h.

Note 3: Videomode switching coordinated with mouse pointing device parameters switching may be performed by mouse driver, called via interrupt INT 33\AX=0028h.

Note 4: Switching of videomodes causes screen blanking (darkening) for up to 2 seconds, discomfortable for visual perception. Therefore excessive switching of videomodes should be avoided. For screen clearing a call INT 10\AH=06h (8.01-15) should be preferred.

8.01-11 INT 10\AH=01h – cursor's size in textual videomodes[edit | edit source]

Prepare : AH = 01h CH – bits 7, 6, 5: – cleared to zero – bits 0–4: – cursor's topmost line number CL – bits 7, 6, 5: – cleared to zero – bits 0–4 – cursor's bottom line number

Note 1: Lines are counted within current font height from top downwards. Current numbers of topmost and bottom cursor's lines are written into BIOS data area (A.10-6) at address 0040:0060h. Current font height may be determined via a call for INT 10\AX=1130h handler or may be directly read from 0040:0085h memory cell.

Note 2: Setting bit 5 in CH register to TRUE state makes cursor invisible.

8.01-12 INT 10\AH=02h – set cursor's position[edit | edit source]

Prepare : AH = 02h BH – screen page number (notes 1 and 2 to INT 10\AH=05h) DH – row number (counted from 00h – the topmost row) DL – column number (counted from 00h – the leftmost column)

Note 1: Cursor's position is defined separately for each screen page.

Note 2: Pairs of cursor's coordinates for up to 8 screen pages are written into BIOS data area at addresses from 0040:0050h and on (A.10-6).

8.01-13 INT 10\AH=03h – determination of cursor's size and position[edit | edit source]

Prepare : AH = 03h BH – screen page number (notes 1 and 2 to INT 10\AH=05h) On return : CH – cursor's size topmost line number CL – cursor's size bottom line number DH – row number (counted from 00h – the topmost row) DL – column number (counted from 00h – the leftmost column)

Note 1: Some BIOS versions return zero in AX register.

8.01-14 INT 10\AH=05h – selection of active screen page[edit | edit source]

Prepare : AH = 05h AL – requested screen page number

Note 1: If requested page number is greater than maximum allowable page number for current videomode, then selection will not be confirmed by INT 10\AH=0Fh function. Maximum allowable page number for VGA videomodes is shown in a table returned by INT 10\AX=1B00h function (A.10-2, offset 29h), and for SVGA videomodes, in a table returned by INT 10\AX=4F01h function (A.10-7, offset 1Dh).

Note 2: Screen pages are numerated from 00h and on, so that maximum allowable page number is by 1 less than total number of screen pages. The most popular textual videomode 03h provides 4 screen pages numerated from 00h to 03h.

Note 3: Selection of a screen page, coordinated with mouse cursor switching to the same page, may be performed by mouse driver, called via interrupt INT 33\AX=001Dh (8.03-47).

8.01-15 INT 10\AH=06h–07h – scrolling over screen window[edit | edit source]

The term "scrolling" denotes moving the displayed contents up or down within the whole screen or inside a "window", i.e. a rectangular region, constituting a part of the whole screen. The lines, appearing from beneath the "window's" border, have no contents and are just filled with prescribed color. Being given AL = 00h, scrolling procedure enables to clear and to fill with uniform color the whole rectangular "window" or the whole screen.

Prepare : AH – scrolling direction: = 06h – to scroll up, = 07h – to scroll down AL – number of lines to scroll (or 00h – clear the whole window) BH – color to fill new lines: bits 0–3: – clear to zero, bits 4–7: – color code from column 1 of table A.10-5. CH – row, CL – column of window's upper left corner DH – row, DL – column of window's lower right corner

Note 1: Scrolling procedure is valid exclusively for textual videomodes.

Note 2: Scrolling procedure affects active screen page only, other screen pages are preserved intact.

Note 3: On return from scrolling procedure some BIOS versions may alter contents of BP or DS register.

8.01-16 INT 10\AH=08h – read a character at cursor's position[edit | edit source]

Prepare : AH = 08h BH – screen page number (notes 1 and 2 to INT 10\AH=05h) On return : AH – color byte as in table A.10-5 (in textual videomodes only) AL – ASCII code of the read character

Note 1: In graphic videomodes, only those characters drawn with white foreground pixels can be recognized properly. If character can't be recognized, then AL = 00h is returned.

8.01-17 INT 10\AH=09h–0Ah – character display at cursor's position[edit | edit source]

Prepare : AH = 09h AL – ASCII code of the character to be displayed BH – screen page number (notes 1 and 2 to INT 10\AH=05h) BL – color byte, shown in appendix A.10-5. CX – number of times to repeat writing of the character

Note 1: All symbols are displayed, including 0Dh (CR), 0Ah (LF), 08h (BS) and other special symbols, mentioned in appendix A.02-8.

Note 2: In graphic videomodes with less than 256 colors, if the TRUE state of bit 7 in BL register is set, then specified character is written into video memory by means of XOR logical operation.

Note 3: In graphic videomodes the prescribed number of repetitions in CX register must not exceed the number of character positions in the same row to the right of current cursor's position.

Note 4: The INT 10\AH=0Ah handler displays character(s) in the same way, but ignores color byte in BL. The displayed character(s) will have the same color as all the previous screen contents.

Note 5: Cursor's position is not shifted by display operation and doesn't depend on number of repetitions, specified in CX register.

Note 6: For 256-color graphic videomodes (for example, in videomode 13h) BH register must specify background color byte, and BL register must specify foreground color byte.

8.01-18 INT 10\AH=0Bh – background or border color[edit | edit source]

For graphic videomodes this function defines background color, but for textual videomodes it defines the border color. Prepare : AH = 0Bh BX – bits 3–15: – cleared to zero – bits 2, 1, 0: – correspond to red, green and blue color

Note 1: Many modern LCD displays either can't show screen border properly or don't show it at all.

8.01-19 INT 10\AH=0Ch – painting of a dot[edit | edit source]

Prepare : AH = 0Ch AL – pixel's color byte (A.10-5) BH – screen page number (notes 1 and 2 to INT 10\AH=05h) CX – pixel's column number DX – pixel's row number

Note 1: Dot painting function is valid for graphic videomodes only.

Note 2: In graphic videomodes with less than 256 colors, if the TRUE state of bit 7 in AL register is set, then dot is written into video memory by means of XOR logical operation.

Note 3: BH contents is ignored, if active videomode supports one screen page only.

Note 4: The INT 10\AH=0Ch function is convenient for drawing lines, but it is too slow for filling screen areas. For the latter purpose more fast direct writing into video memory (8.01-39) should be preferred.

8.01-20 INT 10\AH=0Dh – read pixel's color[edit | edit source]

Prepare : AH = 0Dh BH – screen page number (notes 1 and 2 to INT 10\AH=05h) CX – pixel's column number DX – pixel's row number On return : AL – color byte (A.10-5)

Note 1: The INT 10\AH=0Dh function is valid for graphic video modes only.

Note 2: BH contents is ignored, if active videomode supports one page only.

8.01-21 INT 10\AH=0Eh – characters display in teletype manner[edit | edit source]

The INT 10\AH=0Eh function displays a character at current cursor's position and then shifts cursor to the next character cell. If there is no free space in the current row, cursor is transferred to the start of next row.

Prepare : AH = 0Eh AL – ASCII code of the character to be displayed BH – screen page number (notes 1 and 2 to INT 10\AH=05h) BL – foreground color (in graphic videomodes only)

Note 1: Special codes, listed in appendix A.02-8, including 07h (BEL) and 08h (BS), are not displayed, but are executed as commands.

Note 2: In textual videomodes the displayed character inherits the color, which has been specified for the preceding character cells.

8.01-22 INT 10\AH=0Fh – determination of current videomode[edit | edit source]

Prepare : AH = 0Fh On return : AH – number of character columns in a row or in a line AL – code of current videomode (A.10-1) BH – active screen page number (notes 1 and 2 to INT 10\AH=05h)

Note 1: If code of videomode was originally specified with its 7th bit set to TRUE state (screen not cleared), then the returned code will have its 7th bit set to TRUE state too.

Note 2: Codes of SVGA videomodes can't be determined by INT 10\AH=0Fh function properly: for textual SVGA videomodes it returns either AL=07h (monochrome videomode) or AL=03h (color videomode).

8.01-23 INT 10\AX=1003h – switching of 7th bit mission[edit | edit source]

In textual videomodes the 7th bit in color byte (A.10-5) may define either blinking or background intensity: it depends on state of control bit, which can be changed by INT 10\AX=1003h function.

Prepare : AX = 1003h BX – type of operation: = 0000h – enable background intensity control; = 0001h – enable foreground blinking control.

Note 1: The state of control bit is expressed by 5th bit in a byte at address 0040:0065h in BIOS data area (A.10-6), and also by 5th bit in a byte at offset 2Dh in data block (A.10-2), returned by INT 10\AX=1B00h function.

8.01-24 INT 10\AX=1010h – setting of color intensities[edit | edit source]

The INT 10\AX=1010h function writes into one of DAC's registers the desired partial intensities (from 00h to 3Fh) of main colors – red, green and blue. Combination of partial intensities results in that color tone, which should be defined by this particular DAC's register.

Prepare : AX = 1010h BX – target DAC's register number CH – partial intensity of green color CL – partial intensity of blue color DH – partial intensity of red color

Note 1: All DAC's registers are available for writing, but not all of them are active: it depends on current videomode. In particular, background color palette in 16-color videomodes is defined by DAC's registers 0000h–0007h.

8.01-25 INT 10\AX=1015h – reading of color intensities[edit | edit source]

The INT 10\AX=1015h function reads partial intensities of main colors — red, green and blue, stored in one of DAC's registers. Combination of these partial intensities results in that color tone, which is defined by this particular DAC's register.

Prepare : AX = 1015h BX – target DAC's register number

On return : value in AX register may be altered; CH – partial intensity of green color; CL – partial intensity of blue color; DH – partial intensity of red color.

8.01-26 INT 10\AX=1018h – setting of color mask[edit | edit source]

Prepare : AX = 1018h BL – new mask to be set

Note 1: In a mask bits 0–2 switch on blue, green and red colors of background. Bits 3–5 do the same for foreground colors. States of bits 6 and 7 are indifferent. Normal state of color mask is represented by byte FFh: all colors are switched on.

Note 2: The CLS command (3.05) doesn't reset color mask to its normal state.

8.01-27 INT 10\AX=1100h – font loading for textual videomodes[edit | edit source]

Prepare : AX = 1100h BH – number of bytes per each character pattern BL – identifier of target memory block (note 1 to 8.01-28) CX – number of character patterns to be loaded or replaced DX – offset for loading, counted from the start of target memory block ES:BP – pointer to table of patterns which is to be loaded

Note 1: It is implied that the whole font table contains FFh character patterns.

Note 2: Each byte in a character pattern represents one screen line, hence the number of bytes in a pattern (the value in BH register) is the same as number of screen lines in font's height.

Note 3: This function sets textual video mode, corresponding to the loaded font, but video buffer is not cleared.

Note 4: If several fonts are to be loaded, then the same number of character generator's memory blocks must be prepared beforehand by DISPLAY.SYS driver (5.02-02). Otherwise only one default memory block with identifier 00h will be available.

Note 5: The INT 10\AX=1110 function also loads a font for textual videomodes and accepts the same specifications, but recalculates current state of video controller. A call for INT 10\AX=1110 must be preceded by setting a textual video mode with active video page 00h.

8.01-28 INT 10\AX=1103h – switching between loaded fonts[edit | edit source]

The INT 10\AX=1103 function switches character generator to another font, which must be loaded beforehand into one of character generator's memory blocks. Character generators in EGA-compatible and in VGA-compatible videocards are able to keep active two memory blocks simultaneously, thus giving an opportunity to show characters of two fonts. Selection of a font for each character depends on bit 3 in color byte (A.10-5), which is accepted by character displaying functions, in particular, by INT 10\AH=09h and by INT 10\AH=0Eh functions, accepting color byte from BL register.

Prepare : AX = 1103h BL – identifier of selected memory block (see note 1 below)

Note 1: Identifier of character generator's memory block is a byte with two dedicated fields. One field is represented by bits 4, 1, 0. The other field is represented by bits 5, 3, 2. In each field a number of memory block (from 0 to 7) should be written. A font in this memory block must be loaded yet. If numbers of memory blocks in both fields are equal, then one font will be addressed, and then bit 3 in color byte (A.10-5) will define intensity. In particular, in EGA-compatible video cards, allowing not more than 4 fonts, their memory blocks may be addressed by identifiers 00h, 05h, 0Ah, 0Fh.

Note 2: The possibility to keep active two fonts simultaneously is indicated by the value of 9th byte in static functionality table (A.10-3). Address of that table is reported by INT 10\AX=1B00h function.

Note 3: In order to activate two fonts simultaneously, in two fields of identifier byte different memory block numbers should be stored. Those characters having bit 3 in color byte cleared will be selected from that memory block, whose number is stored in the first identifier's field (bits 4, 1, 0). Those characters having bit 3 in color byte set will be selected from that memory block, whose number is stored in the second identifier's field (bits 5, 3, 2).

8.01-29 INT 10\AX=1104h – loading of standard 8x16 font[edit | edit source]

The INT 10\AX=1104 function loads into character generator's memory block that BIOS's default 8x16 font, which represents american codepage CP437. At the same time textual videomode 03h is set, because its format (80x25) corresponds to 8x16 font.

Prepare : AX = 1104h BL – identifier of selected memory block (note 1 to 8.01-28)

Note 1: The INT 10\AX=1114 function also loads BIOS's standard 8x16 font for textual videomode 03h and accepts the same specifications, but recalculates current state of video controller. A call for INT 10\AX=1114 must be preceded by setting videomode 03h with active video page 00h.

Note 2: If several fonts are to be loaded, then the same number of character generator's memory blocks must be prepared beforehand by DISPLAY.SYS driver (5.02-02). Otherwise only one default memory block with identifier 00h will be available.

Note 3: 8x8 and 8x14 CP437 fonts also can be loaded from BIOS's read-only memory. The 8x8 font is loaded similarly by INT 10\AX=1102h and by INT 10\AX=1112h functions. Monochrome 8x14 font is loaded similarly by INT 10\AX=1101h and by INT 10\AX=1111h functions. The calls for INT 10\AX=1111h and INT 10\AX=1112h functions cause recalculation of video controller's current state and must be preceded by setting of adequate textual videomode.

8.01-30 INT 10\AX=1121h – font loading for graphic videomodes[edit | edit source]

Prepare : AX = 1121h BL – character rows number specification : = 01h – 14 rows, = 02h – 25 rows, = 03h – 43 rows, = 00h – number of rows is defined via DL register. CX – number of bytes per character pattern DL – number of rows, if BL = 00h (otherwise DL is ignored) ES:BP – pointer to table of character patterns to be loaded

Note 1: A call for INT 10\AX=1121h function must be immediately preceded by setting (or resetting) of graphic videomode.

Note 2: Fonts for graphic videomodes don't require preparation of character generator's memory blocks. Instead of that a pointer to the loaded font must be written into interrupt table at address 0000:010Ch. This pointer is sometimes referred to as vector INT 43.

Note 3: User-defined patterns for characters 80h–FFh for BIOS's 8x8 default font can be loaded similarly by INT 10\AX=1120h. As far as format of this font is known, contents of BL, CX and DL registers are ignored, and font table has a fixed length 400h. A pointer to loaded font must be written into interrupt table at address 0000:007Ch. This pointer is sometimes referred to as vector INT 1F.

8.01-31 INT 10\AX=1124h – loading of standard graphic font[edit | edit source]

The INT 10\AX=1124h function loads BIOS's standard 8x16 font, representing american codepage CP437 for graphic videomodes. A pointer to that font is written into interrupt table at address 0000:010Ch. This pointer is sometimes referred to as vector INT 43.

Prepare : AX = 1124h

Note 1: A call for INT 10\AX=1124h function must be immediately preceded by setting (or resetting) of graphic videomode.

Note 2: 8x14 font from BIOS's read-only memory can be loaded similarly by INT 10\AX=1122h function.

Note 3: Double-dot 8x8 font from BIOS's read-only memory can be loaded similarly by INT 10\AX=1123h function.

8.01-32 INT 10\AX=1130h – get information about font[edit | edit source]

Prepare : AX = 1130h BH – requested pointer to font table: = 00h – pointer to 8x8 graphic font (from 0000:007Ch) = 01h – pointer to current graphic font (from 0000:010Ch) = 02h – pointer to BIOS's 8x14 textual font (CP437) = 03h – pointer to BIOS's 8x8 font, characters 00h–7Fh = 04h – pointer to BIOS's 8x8 font, characters 80h–FFh = 05h – pointer to BIOS's alternate 9x14 font = 06h – pointer to BIOS's standard 8x16 textual font (CP437) = 07h – pointer to BIOS's alternate 9x16 font

On return : ES:BP – pointer to the first byte of requested font table CX – number of bytes per character for the current font DL – highest character row on the screen for the current font

Note 1: Data returned in CX and DL registers relate not to the requested font, but to that one which is currently displayed on the screen.

8.01-33 INT 10\AH=13h – display of a characters string[edit | edit source]

The INT 10\AX=13h function displays a string of characters, specified either as a succession of ASCII bytes or as a video memory string in textual videomodes, where each ASCII byte is followed by color byte (A.10-5). In the latter case a value in BL register is ignored.

Prepare : AH = 13h AL – bits 7–2: – cleared to zero – bit 1 set – string with alternating ASCII and color bytes – bit 0 set – shift cursor along the displayed characters BH – screen page number (notes 1 and 2 to INT 10\AH=05h) BL – color byte (A.10-5), if string consists of ASCII codes only CX – number of characters in the string to be displayed DH – character's row to start display DL – character's column to start display ES:BP – pointer to first byte of the string to be displayed

Note 1: Special codes ASCII, listed in appendix A.02-8, are not displayed, but are executed as commands.

Note 2: Some obsolete models of videocards can't execute backspace (BS) and carriage return (CR) special codes properly, if character string is directed to currently inactive screen page.

8.01-34 INT 10\AX=1B00h – get video status information.[edit | edit source]

Prepare :
  AX = 1B00h
  BX = 0000h
  ES:DI pointer to 64-byte buffer for data table
On return :
  AL = 1Bh, if this function is supported by BIOS
  ES:DI pointer to the first byte of table with video status data. Table's contents are described in appendix A.10-2.

8.01-35 INT 10\AX=4F00h – information about BIOS's VBE extensions[edit | edit source]

The INT 10\AX=4F00h function reports about available video BIOS extensions and about supported videomodes. If video BIOS extensions are not present in a particular computer, then all INT 10\AX=4Fxxh functions in this computer are not supported.

Prepare : AX = 4F00h ES:DI – pointer to a 512-byte buffer for data table

On return : AL = 4Fh – any other value signifies absence of VBE AH = 00h – successful termination, data table is written; = 01h – table writing attempt failed; = 02h – function is not supported by hardware configuration; = 03h – function is invalid in current videomode. ES:DI – pointer to the first byte of returned VBE data table (A.10-4).

8.01-36 INT 10\AX=4F01h – information about SVGA videomode[edit | edit source]

Prepare : AX = 4F01h CX – code of SVGA videomode ES:DI – pointer to a 256-byte buffer for data table

On return : AL = 4Fh – any other value signifies that function is not supported AH = 00h – successful termination = 01h – operation failed. ES:DI – pointer to returned videomode data table (A.10-7).

8.01-37 INT 10\AX=4F02h–4F03h – set/get SVGA videomode[edit | edit source]

Prepare : AX = 4F02h – set videomode anew; = 4F03h – get code of current videomode BX – for AX = 4F02h only: code of videomode (A.10-1), including bit 14 set: – enable linear frame buffer bit 15 set: – don't clear video memory

On return : AL = 4Fh – any other value signifies that function is not supported AH – termination code, as after INT 10\AX=4F01h (8.01-36) BX – code of current videomode (A.10-1), including bit 14 set: – linear frame buffer enabled bit 15 set: – contents of video memory are preserved

Note 1: Switching of videomode, coordinated with switching of mouse control parameters, can be performed by mouse driver, if it is called via interrupt INT 33\AX=0028h.

Note 2: Display devices don't necessarily support all SVGA videomodes. Before switching to any videomode you have to know, whether this particular videomode is supported by your display device.

Note 3: Videomode switching causes screen blanking (darkening) for up to 2 seconds, uncomfortable for visual perception.

8.01-38 INT 10\AX=4F04h – save/restore SVGA videomode[edit | edit source]

Prepare : AX = 4F04h CX – part of configuration saved (or to be saved): = 0001h – video hardware state (bit 0 in CX is set) = 0002h – BIOS data (bit 1 in CX is set) = 0004h – color registers and DACs (bit 2 in CX is set) = 0008h – SVGA state (bit 3 in CX is set) = 000Fh – whole video configuration (bits 0–3 are set) DL –subfunction: = 00h – determination of buffer's size for saving videomode = 01h – save current state of video controller = 02h – restore former state of video controller ES:BX – pointer to the first byte of prepared buffer (for subfunctions 01h and 02h only, for subfunction 02h it must be filled with data). On return from subfunction DL = 00h: BX – required number of 64-byte memory blocks On return from subfunction DL = 01h: ES:BX – pointer to buffer with stored videomode data

8.01-39 INT 10\AX=4F05h – control over "windows" into video memory[edit | edit source]

In obsolete computers video memory occupied a part of address space region A000:0000–B000:FFFFh. Active regions of address space for EGA-compatible and for VGA-compatible videomodes are shown in table A.10-1. But modern video cards are designed for SVGA videomodes, which require much larger memory. The whole devoted address space region is too narrow for SVGA videomodes. Therefore SVGA BIOS arranges sliding "windows", enabling access to specified areas of video card's large memory via address space A000:0000–B000:FFFFh.

Quantity, size and place of sliding "windows" in address space may depend on both video card and selected videomode. These data for particular video card and videomode can be found out in table A.10-7, returned by function INT 10\AX=4F01h (8.01-36). Most probably one or two 64-kbyte "windows" are arranged: "window A" A000:0000h–A000:FFFFh and "window B" B000:0000h–B000:FFFFh. The INT 10\AX=4F05h function reports current mapping of video memory onto specified address space "window" and enables to change it.

Prepare : AX = 4F05h BH = 00h – set start point of mapped area in video memory = 01h – get start point of mapped area in video memory BL = 00h – request for window "A" = 01h – request for window "B" DX – pointer to mapped area in video memory (for BH = 00h only)

On return : AL = 4Fh – any other value signifies that function is not supported AH – termination code, as after INT 10\AX=4F01h (8.01-36) DX – pointer to mapped area in video memory (after BH = 01h only)

Note 1: Position of mapped area in video memory is expressed in granularity units. Size of one granularity unit is not fixed, but it is given in kilobytes in a word at offset 04h in table A.10-7, returned by INT 10\AX=4F01h function (8.01-36).

Note 2: The INT 10\AX=4F05h function can also be called for by CALL FAR command (7.03-08) with address, given in double word at offset 0Ch in table A.10-7.

Note 3: Interpretation of data, sent to video memory via the "window", depends on model type, specified by byte 1Bh in table A.10-7. Besides that, some model types allow variants of interpretation. For example, graphic EGA model implements 3 interpretation modes :

mode 00h — 8 pixels per byte — for overwriting pixel values according to bit mask and color mask;
mode 01h for copying from one video memory address into another, taking into account the addresses only;
mode 02h for filling 8 successive pixels with color, defined by 4 least significant bits of the sent byte.

Some opportunities to alter model type and interpretation mode are described in notes 3 and 4 to table A.14-1.

8.01-40 INT 10\AX=4F06h – logical length of displayed line[edit | edit source]

The INT 10\AX=4F06h function enables to set logical length of displayed line equal to integer power of 2 or to its multiple. Thus some affordable loss in effective video memory capacity is exchanged for a considerable gain in simplicity and speed of coordinates calculations. This function is equally feasible in both textual and graphic videomodes.

Prepare : AX = 4F06h BL = 00h – set logical line's length in pixels = 01h – get actual length of displayed line = 02h – set logical line's length in bytes = 03h – get maximal length of displayed line CX – line's length (for BL=00h and BL=02h only) On return : AL = 4Fh – any other value signifies that function is not supported AH – termination code, as after INT 10\AX=4F01h (8.01-36) BX – logical line's length in bytes CX – logical line's length in pixels DX – maximum available number of screen lines of specified length.

Note 1: Actual line's length may exceed nominal value, but can't exceed maximum value, specific for particular videocard. If requested line length is less than nominal line length for the current videomode, then actual line length may be given the nearest acceptable value, not necessarily equal to the requested line length.

8.01-41 INT 10\AX=4F07h – control over displayed part of video memory[edit | edit source]

The INT 10\AX=4F07h function enables to implement screen scrolling and also switching to another screen page within available space of video memory. This function is equally feasible in both textual and graphic videomodes.

Prepare : AX = 4F07h BX = 0000h – set new start position of displayed part immediately = 0001h – get start position of displayed part = 0080h – set new start position during field retrace interval CX – number of the leftmost pixel in a line (not needed for BX = 0001h) DX – number of the first displayed line (not needed for BX = 0001h)

On return : AL = 4Fh – any other value signifies that function is not supported AH – termination code, as after INT 10\AX=4F01h (8.01-36) CX – number of the leftmost pixel in a line (after BX = 0001h only) DX – number of the first displayed line (after BX = 0001h only).

8.01-42 INT 11 – get equipment list[edit | edit source]

Prepare : nothing

On return : AX – equipment list word. Explanation is given in appendix A.11-1.

Note 1: While functioning in protected mode or in V86 mode, CPUs may generate calls for INT 11 handler in case of misalignment exception, that is being given operand's address not on a multiple of operand's length. Misalignment monitoring is performed at the third (the lowest) privilege level only, if bit 12h in flags register and bit 12h in control register CR0 are both set to TRUE state (note 6 to A.11-4). Programs using misalignment monitoring must intercept calls for INT 11 handler in interrupt table for protected mode.

8.01-43 INT 12 – size of conventional RAM below 1 Mb[edit | edit source]

Prepare : nothing

On return : AX – size of conventional RAM in kilobytes (notes 2 and 3)

Note 1: INT 12 handler reads size of conventional RAM from a word at address 0040:0013h in BIOS data area (A.01-1). Besides this, RAM size is stored in CMOS RAM cells 15h and 16h (note 1 to A.14-1).

Note 2: INT 12 handler doesn't inform about PC's RAM beyond 1 Mb boundary, but these data are reported by functions INT 15\AH=88h, INT15\AX=E801h and INT15\AX=E820h.

Note 3: Whole RAM size includes that memory, which is not free or is not accessible for 16-bit addressing. Size of free conventional RAM, which can be allotted by DOS to programs, is reported by INT 21\AH=48h function (note 1 to 8.02-50).

8.01-44 INT 13\AH=00h\0Dh – disk controller reset[edit | edit source]

Reset operation forces disk controller to fill its internal registers anew with data read from a table of parameters for specified disk drive (A.08-2, A.13-1). Reset operation must follow each failure of access to a HDD or to a floppy disk, and only after reset the access attempt may be repeated.

Prepare : AH = 00h – apply to floppy disk controller = 0Dh – apply to HDD controller DL – disk drive number (note 1) On return : On error CF flag is set, AH returns error code (A.06-1) Clear state of CF flag signifies successful termination.

Note 1: Numeration of floppy disk drives is zero-based: 00h – first, 01h – second, and so on. Numeration of HDDs starts from 80h : 80h – first, 81h – second, and so on. Numbers of disk drives (physical disks) have no relation with letter-names of logical disks: each physical HDD may comprise several logical disks.

Note 2: If two disk drives are connected to one controller, then reset operation causes head shift to zero track (recalibration) in both disk drives. When controller's reset is not needed, recalibration should be initiated by a call for INT 13\AH=11h function (all other specifications are the same).

8.01-45 INT 13\AH=01h – status of the last disk operation[edit | edit source]

Prepare : AX = 0100h DL – disk drive number (note 1 to 8.01-44) On return : AH – status code (A.06-1)

Note 1: Some obsolete BIOS versions return status code in AL.

8.01-46 INT 13\AH=02h – read disk sector(s) into memory[edit | edit source]

Prepare : AH = 02h AL – number of sectors to be read (note 1) CH – 8 less significant bits of cylinder (track) number CL – bits 0-5: start sector number (from 1 to 63), – bits 6-7: two most significant bits of cylinder (track) number DH – head number (note 2) DL – disk drive number (note 1 to 8.01-44) ES:BX – pointer to buffer for the data to be read On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination. AL – number of sectors which actually have been read (note 5) ES:BX – pointer to buffer filled with data read from disk.

Note 1: Number of sectors specified in AL register must not be zero. Some obsolete BIOS versions don't allow the value in AL exceeding the number of remaining sectors on the current track (more about that in article 4.22).

Note 2: Some obsolete BIOS versions accept only 4 lower bits in DH, thus allowing to specify not more than 16 heads. Modern BIOS systems, marked with signature A0h in data block A.13-1, accept transformed CHS parameters, allowing up to 256 heads. In any case the utmost parameter's values for any particular disk drive are reported by INT 13\AH=08h function (8.01-49).

Note 3: When reading from a floppy disk fails, after that reading attempts should be repeated at least twice with applying reset (8.01-44) to floppy controller before each next attempt.

Note 4: Under Windows OS direct access to disk via INT 13 functions is prohibited unless the addressed disk is locked for concurrent access by LOCK operation (note 2 to INT 21\AX=440Dh).

Note 5: Some obsolete BIOS versions don't return in AL register the number of sectors, which actually have been read. In case of reading error (error code AH = 11h) modern BIOS systems return in AL register the length of corrected data block.

Note 6: The INT 13\AH=0Ah function (all other specifications are the same) reads HDD's sector(s) along with 22-byte "tail", containing from 4 to 7 bytes of error correcting code. INT 13\AH=0Ah function doesn't correct errors and stops reading after having encountered the first damaged sector.

8.01-47 INT 13\AH=03h – write data into disk's sector(s).[edit | edit source]

Prepare : AH = 03h AL – number of sectors to be written (must be nonzero) CH, CL, DH, DL – just the same as for INT 13\AH=02h (8.01-46) ES:BX – pointer to buffer with data to be written On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination. AL – number of sectors which actually have been written

Note 1: Notes 1 – 4 to INT 13\AH=02h function (8.01-46) are equally applicable to INT 13\AH=03h function.

Note 2: Written data may be verified against buffer contents by INT 13\AH=04h function (all other specifications are the same).

Note 3: Sectors with ECC (error correcting code) can be written onto a HDD by INT 13\AH=0Bh function (all other specifications are the same).

8.01-48 INT 13\AH=05h – low-level formatting of a track[edit | edit source]

Low-level formatting may be applied to those media only, which have no intrinsic track structure. Hence INT 13\AH=05h function can be applied to floppies, but shouldn't be applied to modern HDDs: their original track structure may be damaged by low-level formatting.

The table of parameters for formatting must be prepared in PC's memory beforehand by INT 10\AH=18h function (8.01-54). For obsolete floppy types similar table is prepared by INT 10\AH=17h function. In particular, a pointer to a table with formatting parameters for floppies is stored in 0000:0078h memory cell (A.08-2).

Prepare : AH = 05h AL – number of sectors to be formatted CH – track number DH – head number DL – disk drive number (note 1 to 8.01-44) ES:BX – pointer to data buffer, containing 4 bytes for each sector in a track: first – track number, second – head number, third – sector number, fourth – sector size (00h, 01h, 02h, 03h correspond to size 128, 256, 512, 1024 bytes per sector).

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: In data block, pointed at by ES:DX, count of tracks and heads is zero-based, count of sectors is unity-based.

Note 2: The utmost values of sector number, head number and track number should be determined by INT 13\AH=08h function (8.01-49). Though physical values may be different, but the returned utmost values reflect those transformations (A.13-1), which may be applied to disk parameters by BIOS system of a particular computer.

8.01-49 INT 13\AH=08h – determination of drive's parameters[edit | edit source]

Prepare : AH = 08h DL – disk drive number (note 1 to 8.01-44)

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then : BL – drive type (for removable media drives only): = 01h – drive for 360-kb diskettes, = 02h – drive for 1.2-Mb diskettes, = 03h – drive for 720-kb diskettes, = 04h – drive for 1.44-Mb diskettes, = 06h – drive for 2.88-Mb diskettes, = 10h – drive of any other type. CH – 8 less significant bits of maximum cylinder (track) number CL – bits 0-5: maximum sector number (from 1 to 63), – bits 6-7: most significant bits of maximum cylinder number DH – maximum head number DL – number of attached drives of the same type (note 2) ES:DI – pointer to parameters table A.08-2 (returned for floppy drives only).

Note 1: Status of successful termination (AH = 00h) may be returned even if the requested drive doesn't exist. In order to be convinced in validity of the returned data, one has to check the state of CF flag and the number, returned in DL register.

Note 2: Some BIOS systems can't return in DL register a number greater than 2. Suspicion in presence of more drives should be checked separately by INT 13\AH=15h function (8.01-52).

Note 3: Signature A0h in a byte at offset 03h in table A.13-1 signifies that for HDDs the INT 13\AH=08h function returns not physical, but transformed CHS parameters. In this case just these transformed CHS parameters should be taken into account in calculations of requested values for functions INT 13\AH=02h – INT 13\AH=18h (8.01-46 – 8.01-54).

8.01-50 INT 13\AH=0Ch – move disk drive's head to desired track[edit | edit source]

Prepare : AH = 0Ch CH, CL, DH, DL – just the same as for INT 13\AH=02h (8.01-46)

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination.

8.01-51 INT 13\AH=10h – check whether HDD is ready[edit | edit source]

The status code, returned by INT 13\AH=10h function, signifies whether the requested HDD exists and whether it is ready to perform the next task.

Prepare : AH = 10h DL – drive number (80h = first HDD, 81h = second HDD, and so on) On return : AH – status byte (table A.06-1). Clear state of CF flag signifies successful termination. Set state of CF flag signifies an error.

8.01-52 INT 13\AH=15h – disk drive type check[edit | edit source]

Prepare : AH = 15h DL – disk drive number (note 1 to 8.01-44) On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then : AH – disk drive type: = 00h – requested drive doesn't exist; = 01h – floppy drive without media change line support; = 02h – any drive with removable media change line support = 03h – fixed disk drive (HDD). CX:DX – 4-byte number of 512-byte sectors (returned for HDDs only).

Note 1: HDDs with removable media may be ranked to type 01h or 02h.

Note 2: The INT 13\AH=15h function doesn't rely upon stored data, it scans controller's bus in order to get valid data anew.

8.01-53 INT 13\AH=16h – media change detection[edit | edit source]

Prepare : AH = 16h DL – disk drive number (note 1 to 8.01-44) On return : if disk has not been changed, then CF flag is cleared and AH = 00h; if CF flag is set, and AH = 06h, then disk has been changed; if CF flag is set, but AH has any other value, then this value should be interpreted as return code according to table A.06-1.

Note 1: Before sending a request to INT 13\AH=16h function about an unknown disk drive, one has to investigate with INT 13\AH=15h function whether this disk drive supports media change line.

Note 2: Media change line in most disk drive models is activated by opening (or closing) of disk slot lid, even if disk change event hasn't actually happen.

Note 3: Each media change event is reported only once: after a call for INT 13\AH=16h function media change flag is cleared to its original state.

Note 4: Extended media change function INT 13\AH=49h (with the same other specifications) may be applied to just any disk drive, including CD drives with physical number 80h and higher. BIOS support for these extended capabilities should be confirmed by INT 13\AH=41h function (8.01-55).

8.01-54 INT 13\AH=18h – set media type for formatting[edit | edit source]

Prepare : AH = 18h CH, CL, DH, DL – just the same as for INT 13\AH=02h (8.01-46)

On return : AH – status code: = 00h – requested parameters are supported; = 01h – requested function isn't available; = 0Ch – current disk type either isn't supported or is unknown; = 80h – removable media isn't present in the drive. ES:DI – pointer to floppy drive's parameters table A.08-2

Note 1: The INT 13\AH=18h function doesn't write the returned pointer to floppy drive's parameter table into memory address 0000:0078h, else known as INT 1E vector (A.12-1). INT 1E vector preparation is considered the caller's responsibility.

Note 2: Being applied to a HDD, INT 13\AH=18h function returns CF flag set and status code AH = 01h. To obsolete 5.25" floppies and to 720 kb diskettes the INT 13\AH=17h function should be applied instead.

8.01-55 INT 13\AH=41h – INT 13 extensions check[edit | edit source]

Owing to INT 13 extensions many customary features of modern computers have been implemented since 1997, in particular, possibility to boot the PC from a CD-ROM and LBA addressing to large HDDs (note 4 to A.13-6).

Prepare : AH = 41h BX = 55AAh DL – disk drive number (note 1 to 8.01-44)

On return : On error CF flag is set, AH returns error code (A.06-1). Error code 01h means that requested function is not supported. Clear state of CF flag signifies successful termination, and then : AH – INT 13 extension version: = 01h – version 1.x, = 20h – version 2.0, = 21h – version 2.1. BX = AA55h signature confirms support for INT 13 extensions CX – API subset word's bits signify support for functions: bit 0 – INT 13\AH=42h–44h,47h,48h; bit 1 – INT 13\AH=45h,46h,48h,49h, INT 15\AH=52h; bit 2 – INT 13\AH=48h,4Eh; bit 3 – extended disk address packet support (note 2)

Note 1: Data in AL and DH registers may be lost on return.

Note 2: All versions of INT 13 extensions support 10-byte packet addressing to disks with capacity up to 127 Gb. Besides that, support for 20-byte extended disk address packets enables addressing beyond 127 Gb. Structures of both 10-byte and 20-byte address packets are shown in appendix A.13-4.

8.01-56 INT 13\AH=42h – extended read disk function[edit | edit source]

Prepare : AH = 42h DL – disk drive number (note 1 to 8.01-44) DS:SI – pointer to disk address packet (A.13-4)

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: On return the number of successfully read data blocks is written into a word at offset 02h inside disk address packet.

Note 2: A pointer to buffer with read data is presented by a double word at offset 04h inside disk address packet.

Note 3: Track seek function INT 13\AH=47h, being initiated beforehand with the same other specifications, enables CPU to perform a lot of job while disk drive is moving its head to the specified track. Pertinent usage of track seek function makes actual access to a particular track much faster.

8.01-57 INT 13\AH=43h – extended write to disk function[edit | edit source]

Prepare : AH = 43h AL – flags: = 00h – skip verification procedure, = 02h – verify written data. DL – disk drive number (note 1 to 8.01-44) DS:SI – pointer to disk address packet (A.13-4)

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: A buffer with the data to be written is pointed at by a dword at offset 04h inside disk address packet.

Note 2: On return the number of data blocks successfully written (or successfully verified) is saved in a word at offset 02h inside disk address packet.

Note 3: Versions 1.x of INT 13 extensions used flag AL = 01h for verification of written data. If verification is requested, but is not supported, then INT 13\AH=43h function returns flag CF set and AH = 01h (invalid function).

Note 4: Verification may be initiated separately by INT 13\AH=44h; other specifications are the same, except that value in AL is ignored.

8.01-58 INT 13\AH=45h – lock/unlock a drive[edit | edit source]

Several disk treatment procedures, being interrupted by alien access requests, may inflict severe data loss. Typical example of such procedure is defragmentation. While such procedure lasts, alien access attempts to the subjected disk must be blocked. Having been blocked, removable disk can't be ejected from its drive. Disk blocking in multitasking environment enables to avoid concurrent interventions. Up to 255 levels of nested procedures are allowed, requiring exclusive access to a disk. Having finished its job, each such procedure must release the subjected disk with unlock operation.

Prepare : AX – subfunction: = 4500h – lock media in drive: increase lock level by 1 = 4501h – unlock the media: decrease lock level by 1 = 4502h – report media lock level DL – disk drive number (note 1 to 8.01-44)

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AL – media lock level (= 00h if unlocked)

8.01-59 INT 13\AH=46h – eject removable media[edit | edit source]

Prepare : AX = 4600h DL – disk drive number (note 1 to 8.01-44) On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: Before ejection the INT 13\AH=46h handler calls for INT 15\AH=52h function in order to be certain that specified media at the current moment is not engaged in data transfer with cache buffer or with other programs in multi-tasking environment.

8.01-60 INT 13\AH=48h – request for drive's parameters[edit | edit source]

Prepare : AH = 48h DL – disk drive number (note 1 to 8.01-44) DS:SI – pointer to buffer for data. The first word in buffer must declare its available length, not less than : 001Ah – for INT 13 extensions versions 1.x, 001Eh – for INT 13 extensions versions 2.x, 0049h – for INT 13 extensions versions 3.x.

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then : DS:SI – pointer to buffer filled with data table A.13-2.

Note 1: If actually specified length corresponds to more obsolete version, then newer versions truncate the returned table according to format of specified length.

8.01-61 INT 13\AX=4A00h – drive emulation from CD[edit | edit source]

This function arranges a virtual logical disk copied from a disk image stored in an optical CD or DVD disc. Prepare : AX = 4A00h DS:SI – pointer to boot specification packet A.15-1

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: The INT 13\AX=4C00h function accepts the same other specifications (except AX) and does the same, but then proceeds with booting the PC from the arranged virtual disk.

8.01-62 INT 13\AH=4Bh – drive emulation subfunctions[edit | edit source]

Prepare : AH = 4Bh AL – subfunction: = 00h – terminate disk emulation = 01h – get emulation status DL – emulated disk number (note 1 to 8.01-44) DS:SI – pointer to 13h-byte buffer for boot data packet

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then : DS:SI – pointer to buffer filled with boot data packet A.15-1.

Note 1: Having been given DL = 7Fh, subfunction AL = 00h terminates all current emulations.

Note 2: If emulation hasn't been performed, then clear state of CF flag is returned.

8.01-63 INT 13\AH=4Dh – read sectors of optical disc[edit | edit source]

Prepare : AX = 4D00h DS:SI – pointer to command packet (A.15-2)

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: Returned data are written into a prepared buffer. A pointer to this buffer must be specified by a dword at offset 02h inside command packet (A.15-2).

Note 2: Most often the INT 13\AH=4Dh function is used to read boot catalog of optical disc. Boot catalog structure is shown in table A.15-3.

8.01-64 INT 13\AH=4Eh – control over drive's hardware[edit | edit source]

Prepare : AH = 4Eh AL – subfunction: = 00h – enable prefetch (reading into drive's buffer) = 01h – disable prefetch = 02h – set maximum PIO data transfer mode = 03h – set PIO data transfer mode 0 = 04h – set default PIO data transfer mode = 05h – enable INT 13 DMA maximum mode = 06h – disable INT 13 DMA data transfer DL – disk drive number (note 1 to 8.01-44)

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then : AL = 00h – command affected specified drive only = 01h – other devices are affected too (note 2)

Note 1: DMA and PIO data transfer modes are mutually exclusive. Selecting DMA disables PIO, and selecting PIO disables DMA.

Note 2: Change of data transfer mode may affect other devices, connected to the same controller.

8.01-65 INT 14\AH=00h – initialize serial port[edit | edit source]

Prepare : AH = 00h AL – data transfer parameters: bits 7–5: values from 000b to 111b correspond to data rates 110, 150, 300, 600, 1200, 2400, 4800, 9600 bits per second bits 4–3: 00b or 10b – no parity check, 01b – odd parity check, 11b – even parity check. bit 2: if cleared – 1 stop bit, if set – 2 stop bits. bits 1–0: values from 00b to 11b correspond to data word lengths 5, 6, 7, 8 bits. DX – serial port number (0000h–0003h) On return : AH – line status byte (A.14-2) AL – status of modem, if it is connected to the requested port.

8.01-66 INT 14\AH=01h – send a character to serial port[edit | edit source]

Prepare : AH = 01h AL – character to be sent DX – serial port number (0000h–0003h) On return : AH – line status byte (A.14-2)

Note 1: Transmission error is marked by set state of bit 7 in returned status byte: it means that waiting time for response exceeded a preset time limit (timeout).

8.01-67 INT 14\AH=02h – read a character from serial port[edit | edit source]

Prepare : AX = 0200h DX – serial port number (0000h–0003h) On return : AH – line status byte (A.14-2) AL – received character, if bit 7 in returned line status byte is clear.

8.01-68 INT 14\AH=03h – get status of serial port[edit | edit source]

Prepare : AX = 0300h DX – serial port number (0000h–0003h) On return : AH – line status byte (A.14-2) AL – status of modem, if it is connected to the requested port.

8.01-69 INT 15\AH=52h – query whether a drive is busy[edit | edit source]

The INT 15\AH=52h function reports whether a drive is busy with data traffic at this moment. INT 15\AH=52h function is called for, in particular, by INT 13\AH=46h handler in order to prevent removable media ejection while data transfer procedure isn't finished yet.

Prepare : AH = 52h DL – disk drive number (note 1 to 8.01-44) On return : if flag CF is set, then drive is busy, and AH returns error code (A.06-1). Clear state of CF flag signifies that requested drive is not busy.

Note 1: Before applying INT 15\AH=52h function, BIOS support for this function should be checked with a call for INT 13\AH=41h.

Note 2: By default BIOS installs a dummy handler for INT 15\AH=52h, which always returns CF flag cleared. Responses will reflect real status of drive's traffic, when calls for INT 15\AH=52h function are intercepted yet by another handler, installed by disk caching driver.

8.01-70 INT 15\AX=5301h – activate APM real mode interface[edit | edit source]

When computer is switched on, its power management system (APM) stays inactive. While CPU is in real mode, APM interface activation can be initiated by a call for INT 15\AX=5301 function.

Prepare : AX = 5301h BX = 0000h (identifier of BIOS's APM extensions) On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: The INT 15\AX=5301h function forces APM system to emulate specifications of APM's version 1.0. In order to perform operations, which are not defined for APM's version 1.0, emulation of newer APM versions should be forced by INT 15\AX=530Eh function (8.01-72).

8.01-71 INT 15\AX=5307h – switching of power supply modes[edit | edit source]

Computers of ATX form factor can be switched off by a machine command, turning their power supply block into standby mode. Then power is supplied to only those blocks which enable an opportunity to switch the PC on. Naturally, standby mode of power supply block must be hardware supported by power supply block itself and by PC's motherboard.

Prepare : AX = 5307h BX = 0001h (identifier of all APM-controlled devices) CX = 0003h (code of switch off request) On return : On error CF flag is set, AH returns error code (A.06-1). On success all the rest doesn't matter.

Note 1: Switch off operation is defined by specifications of APM version 1.2. If APM system emulates version 1.0 (note 1 to 8.01-70), then an opportunity to switch the PC off should be unblocked by INT 15\AX=530Eh function (8.01-72).

Note 2: In obsolete computers of AT form factor a call for INT 15\AX=5307h function is allowed, but is ignored.

8.01-72 INT 15\AX=530Eh – APM version emulation request[edit | edit source]

In order to preserve compatibility with operating systems, specifications of newer APM versions stipulate an opportunity to emulate previous APM versions. That program or that operating system, which is to control power management, may request emulation of the desired APM version. In response APM BIOS emulates the requested or the nearest feasible APM version and returns number of that version. Further power management must be performed according to the actually emulated APM version.

Prepare : AX = 530Eh BX = 0000h (identifier of BIOS's APM extensions) CX – requested APM version emulation (note 1) On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – actually emulated APM version (note 1).

Note 1: Integer and fractional parts of APM version number must be specified in separate bytes of CX register. In particular, for version 1.2 request the CX = 0102h value should be specified. Returned in AX version number fits the same format.

Note 2: Version emulation request is defined by specifications of APM version 1.1. If version emulation request returns error code 80h or 86h, whereas function INT 15\AX=5301h (8.01-70) has terminated successfully, hence this computer implements APM version 1.0 only.

8.01-73 INT 15\AH=83h,86h – BIOS timer control[edit | edit source]

Prepare : AX – subfunction: = 8300h – initiate delay count and let the caller process to go on = 8301h – halt count session (CX, DX, ES:BX are ignored) = 8600h – initiate delay count and suspend the caller process until delay count expires (AL and ES:BX are ignored) CX – most significant 16 bits of 32-bit delay (in microseconds) DX – least significant 16 bits of 32-bit delay (in microseconds) ES:BX – pointer to marker byte: its most significant 7th bit is set when delay count expires (note 3).

On return : Clear state of CF flag signifies successful termination. CF flag is set on error or else when count session is initiated yet, and then AH register returns error code (A.06-1).

Note 1: Most probable resolution of time period is 977 microseconds.

Note 2: Some obsolete BIOS versions don't support subfunction 8301h.

Note 3: Default address of marker byte is 0040:00A0h (A.12-1). When delay count expires, some BIOS versions assign 80h value to marker byte.

Note 4: BIOS timer is inaccessible from "DOS box" under Windows OS.

8.01-74 INT 15\AH=84h – read joystick state[edit | edit source]

Prepare : AH = 84h DX – subfunction: = 0000h – read states of switches = 0001h – read signals of position sensors

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then :

  • DX=0000h subfunction returns states of switches in bits 4–7 of AL register ;
  • DX=0001h subfunction returns the following data :

AX – x-coordinate value of the 1st manipulator
BX – y-coordinate value of the 1st manipulator
CX – x-coordinate value of the 2nd manipulator
DX – y-coordinate value of the 2nd manipulator

Note 1: Typical resistance of position sensors is 250 kOhm, and typical limits for coordinate values are 0000h–01A0h.

Note 2: It is implied that the joystick is connected via a game port. If game port isn't present in a particular PC, then subfunction DX=0001h returns zero coordinate values, and subfunction DX=0000h returns AL=00h, equivalent to disconnected states of switches.

8.01-75 INT 15\AH=85h – PrintScreen key activity hook[edit | edit source]

The INT 15\AH=85h function is called for by INT09 handler in response to user's PrtScr keystroke. It is implied that a handler for INT 15\AH=85h function should be installed by videocard driver in order to implement an enhanced Print Screen procedure, based on specific resources of a particular videocard. But until this specific handler is not installed, BIOS's dummy handler just returns control to the caller as if its request were satisfied.

Prepare : AH = 85h AL = 00h – procedure initiation when PrintScreen key is pressed = 01h – procedure initiation when PrintScreen key is released CF flag must be cleared beforehand

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag and AH = 00h signify successful termination.

8.01-76 INT 15\AH=87h – copying with access to extended memory[edit | edit source]

The INT 15\AH=87h function copies a data block within 16 Mb address space. Maximum size of data block is 64 kb. Copying is performed in protected mode while external interrupts are disabled, so that there is no need to prepare interrupt table for protected mode. But GDT table is needed, and it should be prepared according to the following template :

Reserved descriptor: 00 00 00 00 00 00 00 00
Reserved descriptor: 00 00 00 00 00 00 00 00
Source segment descriptor: ss ss aa aa aa 93 00 00
Destination segment descriptor: ss ss dd dd dd 93 00 00
Reserved descriptor: 00 00 00 00 00 00 00 00
Reserved descriptor: 00 00 00 00 00 00 00 00

In the shown template letter "a" denotes linear address field for source segment, letter "d" denotes linear address field for destination segment, letter "s" denotes size field for both source and destination segments. As far as size of data block is specified in CX register by number of double-byte words to be copied, both segment sizes (in bytes) must be not less than (2*CX) –1. In size fields and in address fields the first are the least significant bytes ; most significant bytes are specified the last. Attribute byte in both source segment descriptor and destination segment descriptor must be 93h. More detailed explanation of descriptor's structure is given in appendix A.12-2.

Reserved descriptors, originally filled with zeros, will be filled with data by INT 15\AH=87h handler and will be used in protected mode. Having finished copying, the INT 15\AH=87h handler switches CPU back into real mode and restores original state for continuation of caller program's execution.

Prepare : AH = 87h CX – number of words to be copied, not more than 7FFFh ES:SI – pointer to the first byte of prepared GDT table

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: As far as external interrupts during copying are disabled, some external interrupt calls may be missed. This wouldn't happen, if copying beyond conventional memory is arranged by HIMEM.SYS driver (A.12-4).

Note 2: HIMEM.SYS driver intercepts INT 15\AH=87h calls and gives no direct access to original BIOS's handler. However, programs may be allowed to access a limited region of extended memory via INT 15\AH=87h calls, if this region is reserved by /INT15 parameter (5.04-01).

8.01-77 INT 15\AH=88h – extended memory size up to 16 Mb[edit | edit source]

Prepare : AH = 88h On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – size in kilobytes of extended memory beyond 1024 kb.

Note 1: If valid address space is intermittent, size of its continuous part from 100000h (1024 kb) up to the first interstice will be reported.

Note 2: INT 15\AH=88h handler reads extended memory size from cells 30h and 31h of BIOS's CMOS data base.

Note 3: Default BIOS handler for INT 15\AH=88h function is intercepted by HIMEM.SYS and EMM386.EXE drivers.

Note 4: Information about extended memory beyond 16 Mb can be reported by INT 15\AX=E801h\E881h (8.01-79) and by INT 15\AX=E820h (8.01-80).

8.01-78 INT 15\AH=89h – switching CPU to protected mode[edit | edit source]

The INT 15\AH=89h handler switches CPU into protected mode and performs the most urgent preparations for functioning in protected mode, which include filling of segment registers with segment selectors and reprogramming interrupt controller according to protected mode specifications.

In order to ensure continuation of the caller program after switching CPU into protected mode, interrupt table (IDT) for protected mode and global descriptor table (GDT) should be prepared beforehand. IDT is filled with 8-byte descriptors ("gates"), specifying addresses and call conditions for protected mode handlers. Size and linear address of IDT table itself must be written into IDT segment descriptor inside GDT table.

The GDT table, prepared for INT 15\AH=89h handler, includes 8 descriptors, each 8 bytes long. Arrangement of descriptors in GDT table must correspond to the following template :

Reserved descriptor: 00 00 00 00 00 00 00 00
GDT segment descriptor: 3F 00 aa aa aa 00 00 00
IDT segment descriptor: FF 03 aa aa aa F2 00 00
DS segment descriptor: ss ss aa aa aa 92 0s aa
ES segment descriptor: ss ss aa aa aa 92 0s aa
SS: segment descriptor ss ss aa aa aa 92 0s aa
CS: segment descriptor ss ss aa aa aa 9A 0s 00
Reserved descriptor: 00 00 00 00 00 00 00 00

In the shown template letter "a" denotes linear address fields for each segment, and letter "s" denotes segment size fields. Reserved descriptors must be filled with zeros. As examples the template shows particular values of attribute bytes, and also particular sizes for GDT and IDT segments. Detailed explanation of descriptor's structure is given in appendix A.12-2.

Prepare : AH = 89h BL – interrupt number for IRQ 0 (note 2) BH – interrupt number for IRQ 8 (note 2) ES:SI – pointer to the first byte of GDT table

On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AH = 00h, segment registers are filled with segment selectors, interrupt controller is reprogrammed. Former value in BP register may be altered.

Note 1: CS segment descriptor in GDT table must specify just that segment, which was defined by CS segment address in real mode. This condition ensures continuation of caller program's execution in protected mode from the command following the call for INT 15\AH=89h handler.

Note 2: Assigned numbers of interrupts in BL and BH registers must be multiples of 8 (three least significant bits must be cleared). Numbers of interrupts, following the value in BL register, will be assigned to request lines IRQ 1 – IRQ 7. Similarly, numbers of interrupts, following the value in BH register, will be assigned to request lines IRQ 9 – IRQ F. An important factor in choice of reprogrammed interrupt numbers is that interrupts 00h–1Fh may be invoked by CPU's exceptions.

Note 3: Direct calls for real mode interrupt handlers become forbidden after switching to protected mode because of changed addressing format and reprogrammed interrupt controller.

8.01-79 INT 15\AX=E801h,E881h – extended memory size[edit | edit source]

Prepare : AX = E801h or else = E881h On return : On error CF flag is set, AH returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – size (in kilobytes) of extended memory in address space region between 1 Mb and 16 Mb. BX – size (in 64-kb blocks) of extended memory in address space region beyond 16 Mb. CX – size (in kilobytes) of configurated memory in address space region between 1 Mb and 16 Mb. DX – size (in 64-kb blocks) of configurated memory in address space region beyond 16 Mb.

Note 1: If after successful termination AX = BX = 0000h, then size of extended memory should be read from registers CX and DX.

Note 2: Unlike INT 15\AX=E801h, the INT 15\AX=E881h handler is able to return values exceeding 4 Gb. Most significant digits are returned in bits 31–16 of 32-bit registers EBX and EDX. Ways of access to bits 31–16, feasible for real mode programs, are described in article 7.02-06.

Note 3: The INT 15\AX=E801h\E881h functions are not supported by obsolete BIOS versions, developed before 1995.

8.01-80 INT 15\AX=E820h – memory dedication map[edit | edit source]

Memory dedication map is represented by a succession of 20-byte descriptors, each corresponding to a separate memory region, dedicated for a certain purpose. Each descriptor starts with 8-byte address of the region's first byte, then 8-byte length of that region follows, and the last 4 bytes are that region's dedication code (note 1). One call for INT 15\AX=E820h function returns one descriptor; hence this function has to be called for several times. For the first call a zero value (00000000h) in EBX register should be prepared. After the first call a non-zero EBX value is returned, defining target descriptor for the next call. Termination of calls cycle is marked by return of either a zero value in EBX register or a set state of CF flag.

Prepare : AX = E820h EBX – pointer to target descriptor in memory dedication map ECX – size of ES:DI buffer, not less than 20 (=14h) bytes EDX = 534D4150h – the "SMAP" signature ES:DI – pointer to a buffer prepared for the descriptor

On return : On error CF flag is set, EAX value is not equal to 534D4150h, AH register returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then EAX = 534D4150h "SMAP" – the "SMAP" signature EBX – pointer to next descriptor in memory dedication map ECX – actual length of the returned descriptor in buffer ES:DI – pointer to buffer with the returned descriptor

Note 1: Dedication codes should be interpreted as follows :

01h – memory, allocated for operating system ;
02h – memory (system ROM), reserved by BIOS ;
03h – ACPI tables area (may be free after being read) ;
04h – nonvolatile memory for system purposes.

Memory areas with other dedication codes should be considered reserved by BIOS system. Intervals of address space, excluded from memory dedication map, are not supported by hardware.

Note 2: Some BIOS versions don't ignore contents of bits 31–16 in EAX register, so that calls for INT 15\AX=E820h function need these bits to be cleared (i.e. EAX = 0000E820h). Ways of access to bits 31–16, feasible for real mode programs, are described in article 7.02-06.

Note 3: Some BIOS versions ignore ECX register and return 20 bytes of data after each call for INT 15\AX=E820h function.

Note 4: If a call for INT 15\AX=E820h function is not supported by BIOS in a particular computer, then an attempt should be undertaken to call for INT 15\AX=E801h (8.01-79). If this attempt fails too, then INT 15\AH=88h function (8.01-77) should be called for.

8.01-81 INT 16\AH=03h – keyboard's rate and delay[edit | edit source]

Prepare : AX – subfunction: = 0300h – set default repeat rate and delay values = 0305h – set rate given in BL, set delay given in BH = 0306h – get current values for repeat rate and delay BL – (for AX=0305h only): repeat rate code (note 1) BH – (for AX=0305h only): delay code (note 2)

On return : BL – code of current repeat rate (note 1) BH – code of current delay (note 2) AH contents may be altered.

Note 1: Allowed repeat rate codes from 00h to 1Fh correspond to repeat rates from 30 times per second to 2 times per second.

Note 2: Allowed delay codes from 00h to 03h correspond to delays from 0.25 to 1 second.

8.01-82 INT 16\AH=05h – insert key code into keyboard buffer[edit | edit source]

Prepare : AH = 05h CH – scan code of keystroke (table A.02-1) CL – ASCII code of corresponding character (table A.02-1)

On return : AL – error code (A.06-1) AH contents may be altered.

Note 1: Obsolete BIOS versions don't support this function.

Note 2: Codes of several keys (for example, of the ENTER key), being inserted into keyboard buffer, induce execution of corresponding functions.

Note 3: The INT 16\AH=05h function can't be used to insert codes of "functional" keys (SHIFT, CTRL, ALT).

8.01-83 INT 16\AH=10h – get key code out of keyboard buffer[edit | edit source]

The INT 16\AH=10h function is adapted for the most widespread 101\108-key "enhanced" keyboards, but also responds to keystrokes on compatible keys of other keyboards. The INT 16\AH=10h handler withdraws the topmost key code out of keyboard buffer and presents this code in AX register. If keyboard buffer is empty at that moment, then INT 16\AH=10h handler starts waiting for user's keystroke.

Prepare : AH = 10h

On return : AH – scan code of keystroke (table A.02-1) AL – ASCII code of corresponding character (table A.02-1)

Note 1: The INT16\AH=20h does the same, but is able to respond to some keys, specific for 122-key keyboards.

Note 2: In obsolete computers similar mission is performed by INT16\AH=00h function. In modern computers this function is still active, but it ignores keys, which were not present in obsolete 84-key keyboards.

8.01-84 INT 16\AH=11h – copy key code from keyboard buffer[edit | edit source]

The INT 16\AH=11h function is adapted for the most widespread 101\108-key "enhanced" keyboards, but also responds to keystrokes on compatible keys of other keyboards. The topmost key code isn't withdrawn out of keyboard buffer, the INT 16\AH=11h handler just copies this code into AX register and doesn't wait for user's keystroke, if keyboard buffer at that moment is empty.

Prepare : AH = 11h

On return : If ZF flag is set to ZR state, then keyboard's buffer is empty. If ZF flag is cleared to NZ state, then : AH – scan code of keystroke (table A.02-1) AL – ASCII code of corresponding character (table A.02-1)

Note 1: The INT16\AH=21h does the same, but is able to respond to some keys, specific for 122-key keyboards.

Note 2: In obsolete computers similar mission is performed by INT16\AH=01h function. In modern computers this function is still active, but it ignores keys, which were not present in obsolete 84-key keyboards.

8.01-85 INT 16\AH=12h – get keyboard status flags[edit | edit source]

The INT 16\AH=12h function copies into AX register the keyboard status word, stored most probably at address 0040:0017h in BIOS data area (A.02-3).

Prepare : AH = 12h

On return : AX – flags: bit 0 set: Right Shift key is kept pressed bit 1 set: Left Shift key is kept pressed bit 2 set: either of CTRL keys (right or left) is kept pressed bit 3 set: either of ALT keys (right or left) is kept pressed bit 4 set: the Scroll Lock switch is turned on bit 5 set: the Num Lock switch is turned on bit 6 set: the Caps Lock switch is turned on bit 7 set: the Insert switch is turned on bit 8 set: Left CTRL key is kept pressed bit 9 set: Left ALT key is kept pressed bit 10 set: Right CTRL key is kept pressed bit 11 set: Right ALT key is kept pressed bit 12 set: the Scroll Lock key is kept pressed bit 13 set: the Num Lock key is kept pressed bit 14 set: the Caps Lock key is kept pressed bit 15 set: the SysRq (PrtScr) key is kept pressed (note 2)

Note 1: In obsolete computers with 84\86-key keyboards a similar mission is performed by INT 16\AH=02h function. It returns flag's states in bits 7–0 of AL register only. In modern computers this function is still active, but it doesn't return those flag's states which were not registered in obsolete computers.

Note 2: The pressed state of SysRq (PrtScr) key is not registered, unless either of ALT keys (left or right) is kept pressed too.

8.01-86 INT 17\AH=00h – send a character to LPT port[edit | edit source]

Prepare : AH = 00h AL – code of the character to be sent DX – LPT port number: 0000h–0002h correspond to LPT1 – LPT3

On return : AH – LPT port's and printer's status (A.14-3).

8.01-87 INT 17\AH=01h – initialize printer's port[edit | edit source]

Prepare : AH = 01h DX – LPT port number: 0000h–0002h correspond to LPT1 – LPT3

On return : AH – LPT port's and printer's status (A.14-3).

Note 1: Reported status in AH may be incorrect. More reliable data are reported after some delay by INT 17\AH=0200h function.

8.01-88 INT 17\AX=0200h – get status of LPT port[edit | edit source]

The INT 17\AX=0200h function is executed by both conventional LPT BIOS and EPP BIOS (Enhanced Parallel Port BIOS), but in different ways. EPP BIOS is not present in obsolete PCs, and then conventional LPT BIOS reports nothing more than port's status in AH (A.14-3). In modern PCs INT 17\AX=0200h calls can be directed to conventional LPT BIOS and give the same effect, if prepared value in BX register is not 5050h. But calls for INT 17\AX=0200h with BX=5050h and CH=45h are intercepted by EPP BIOS, which returns address of its entry point. A CALL FAR command (7.03-08) to this entry point invokes enhanced I/O functions, stipulated by IEEE 1284 specification (A.14-4).

Prepare : AX = 0200h BX = 5050h, if the call is addressed to EPP BIOS CH = 45h, if the call is addressed to EPP BIOS DX – LPT port number: 0000h–0002h correspond to LPT1 – LPT3

On return : AH – LPT port's and printer's status (A.14-3). Status AH = 03h and flag CF set to CY state are returned by EPP BIOS, if it doesn't support the requested LPT port. Status AH = 00h and flag CF cleared to NC state are returned by EPP BIOS, if it supports the requested LPT port, and then : CX:AL = 4550:50h – signature of EPP BIOS versions 1.x CX:AL = 5050:45h – signature of EPP BIOS versions 3.x EPP BIOS versions 1.x and 3x return ES register contents intact and DX:BX – segment: offset of EPP BIOS far entry point EPP BIOS revision 7 returns ES contents altered and DX – base address for EPP BIOS I/O operations ES:BX – segment: offset of EPP BIOS far entry point.

Note 1: If a call for INT 17\AX=0200h is not addressed to EPP BIOS, then BX and CH registers may contain any values, except 5050h and 45h.

Note 2: A change of segment address in ES register is a specific symptom of the latest 7th revision of EPP BIOS, supplemented with control functions for LPT multiplexer.

8.01-89 INT 18 – diskless boot hook[edit | edit source]

Prepare : nothing

When bootable disk can't be found, then PC's BIOS system calls for INT 18 handler. In obsolete PCs INT 18 handler launched BASIC language interpreter, stored in PC's read-only memory (ROM). Default INT 18 handler in modern computers displays a message about absence of BASIC language interpreter and then halts CPU.

However, a call for INT 18 can be intercepted by other handler, supplied in ROM memory of an extension card. In particular, interception may be performed by handlers, supplied with network cards, in order to implement diskless boot via local network.

8.01-90 INT 19 – bootstrap loader[edit | edit source]

The INT 19 handler performs an important part of PC's booting procedure: it copies boot sector from disk's boot partition into PC's memory at address 0000:7C00h and then transfers control to the copied boot sector's code. That disk is addressed first, which is specified the first in a sequence of boot alternatives, prepared by BIOS Setup program. From floppies their boot sector is copied immediately, HDD's boot partition is determined from partition table in MBR sector (A.13-5). If addressed disk is inaccessible, then an attempt is undertaken to address the next disk in prepared sequence of boot alternatives. If all attempts fail, the last default resort is a call for INT 18 handler (8.01-89).

However, the INT 19 handler doesn't clear memory and doesn't restore interrupt table. Therefore computer most probably will get hanged after a call for INT 19 handler, if appropriate preparations for this call have not been made. When necessary, reboot should be initiated not by a call for INT 19 handler, but otherwise: either by keyboard controller's FEh command (note 3 to A.11-3) or by a CALL FAR command (7.03-08) to boot program's enter point F000:FFF0h (note 4 to A.12-1), which is the same in all AT-compatible computers.

8.01-91 INT 1A\AH=00h – get system ticks count[edit | edit source]

Prepare : AH = 00h On return : AL – nonzero if midnight passed since last reading of ticks count. CX – most significant 2 bytes of ticks count, 1800B0h per 24 hours DX – least significant 2 bytes of ticks count, 18.2 ticks per second

Note 1: Tick count is reset at midnight.

Note 2: After midnight DOS must be the first to request system ticks count, otherwise it misses midnight flag and fails to advance the date.

Note 3: System time (in ticks) may be set by INT 1A\AH=01h. Number of ticks to be set must be prepared in CX and DX registers in the same way.

8.01-92 INT 1A\AH=02h – read real-time clock[edit | edit source]

Prepare : AH = 02h

On return : On error CF flag is set, returned data are invalid. Clear state of CF flag signifies successful termination, and then CH – hours CL – minutes DH – seconds DL = 00h standard time ("winter time" for northern hemisphere) = 01h daylight time ("summer time" for northern hemisphere)

Note 1: Hours, minutes and seconds are returned in packed decimal format, i.e. two decimal digits per byte.

Note 2: Real time may be set with INT 1A\AH=03h. Time data must be prepared in CH, CL, DH and DL registers in the same form.

8.01-93 INT 1A\AH=04h – read real-time date[edit | edit source]

Prepare : AH = 04h

On return : On error CF flag is set, returned data are invalid. Clear state of CF flag signifies successful termination, and then CH – century CL – year DH – month DL – day

Note 1: Day, month, year and century are returned in packed decimal format, i.e. two decimal digits per byte.

Note 2: New date may be set with INT 1A\AH=05h. The data to be set must be prepared in CH, CL, DH and DL registers in the same form.

8.01-94 INT 1A\AH=06h – preset time for daily event invocation[edit | edit source]

The INT 1A\AH=06h function specifies moments of regular calls for INT 4A handler by PC's BIOS system. The desired action (clock alarm, for example) is implied to be done by INT 4A handler, which has to be written by the user and has to be loaded yet.

Prepare : AH – 06h CH – hour CL – minutes DH – seconds

On return : On error CF flag is set: most probably time preset is active already. Clear state of CF flag signifies successful termination.

Note 1: Hour, minutes and seconds must be prepared in packed decimal format, i.e. two decimal digits per byte.

Note 2: Preset FFh discards partial count. For example, in case of CH = FFh the INT 4A handler is invoked once every hour, in case of CH = CL = FFh the INT 4A handler is invoked every minute.

Note 3: Preset time remains active until it is disabled by a call for INT 1A\AH=07h function, which needs AH = 07h only to be prepared.

8.01-95 INT 1B – keyboard's "CTRL-Break" hook[edit | edit source]

Prepare : nothing

The INT 09 handler calls for INT 1B each time when keyboard controller reports about CTRL-Break keystroke. Default INT 1B handler sets TRUE state to a flag in BIOS data area (bit 7 in byte at offset 71h in table A.02-3), and then control is returned to interrupted program. The state of this flag is checked by some MS-DOS handlers, called by the current program. If flag is found set to TRUE state, then INT 23 handler (8.02-83) is called for. The latter suspends execution of current program and is responsible for all consequent events (1.03).

Replacement of INT 1B handler's address in interrupt table by a pointer to IRET command (7.03-30) is a common trick, used in many programs in order to prevent their abortion, which otherwise may be caused by a CTRL-Break keystroke.

8.01-96 INT 1C – system timer tick hook[edit | edit source]

Prepare : nothing

INT 1C is called by INT 08 handler (8.01-09) at each system timer's tick, i.e. 18.2 times per second. The default INT 1C handler just returns control to the caller. But every resident program is allowed to replace the default handler with its own INT 1C handler, which will transfer control to program's resident module at each timer's tick. Thus computer systems are enabled to implement monitoring and control over developing processes in real time.

8.02 Interrupt handlers, loaded by MS-DOS7 (INT 20 – INT 2E)[edit | edit source]

8.02-01 INT 20 – termination of program's execution[edit | edit source]

The INT 20 handler restores former interrupt table values from program's PSP (A.07-1), releases memory, occupied by the program, restores states of segment registers and stack, and then transfers control to caller's code pointed at by INT 22 (8.02-82). However, INT 20 requires PSP segment address to be present in CS: register, and gives no opportunity to leave errorlevel code (3.15-03), characterizing circumstances of program's termination. Therefore termination of program's execution with a call for INT 21\AH=4Ch function (8.02-55) should be preferred.

Prepare : segment address in CS: register must point at PSP segment.

On return : return wouldn't happen.

Note 1: In operating environment of Debug.exe the INT 21\AH=4Ch and INT 20 handlers produce different effects: INT 20 transfers control to Debug.exe, whereas INT 21\AH=4Ch terminates debugger's session and returns control to DOS.

Note 2: INT 21\AH=00h also terminates the caller program and always leaves errorlevel code 00h, just as INT 20 does. MS-DOS7 supports INT 21\AH=00h for preserving compatibility with obsolete software.

8.02-02 INT 21\AH=01h – get a character via STDIN channel[edit | edit source]

The INT 21\AH=01h function reads character code from STDIN (standard input) channel, writes this code into AL register and sends a copy of this code into STDOUT (standard output) channel. Both STDIN and STDOUT channels may be redirected, but until this is not done, default STDIN source is keyboard, and default STDOUT destination is the screen. Therefore a call for INT 21\AH=01h function induces PC to start waiting for a keystroke, and after keystroke the corresponding character appears on the screen.

Prepare : AH = 01h

On return : AL – received character's ASCII code

Note 1: Returned ASCII code is represented by two rightmost digits of hexadecimal numbers in table A.02-1.

Note 2: INT 21\AH=01h function shouldn't be called from command files which are sent to command interpreter via redirection, because in this case INT 21\AH=01h function intercepts STDIN traffic, including those commands, which are to be received by command interpreter.

Note 3: INT 21\AH=01h function checks the state of that flag, which is set after CTRL-C and CTRL-Break keystrokes (8.01-95). If this flag is found in TRUE state, then INT 23 handler is called for.

Note 4: In the same way the INT 21\AH=03h function reads character's code from STDAUX channel, which has the COM1 port as its default source.

8.02-03 INT 21\AH=02h – send a character via STDOUT channel[edit | edit source]

The INT 21\AH=02h function sends specified ASCII code into STDOUT channel. If STDOUT channel is not redirected, its default destination is display, and therefore a character, corresponding to the sent ASCII code, will appear on the screen.

Prepare : AH = 02h DL – ASCII code of the character to be sent into STDOUT On return : AH – the sent ASCII code, except TAB code (09h), which is expanded into spaces (20h).

Note 1: If STDOUT channel is redirected into a file, then sending into STDOUT channel doesn't imply checks of media presence in a drive, of whether this media is full, write-protected, etc. But when target drive is busy with previous operation, then INT 21\AH=02h handler will wait for termination of that previous operation.

Note 2: INT 21\AH=02h function checks the state of that flag, which is set after CTRL-C and CTRL-Break keystrokes (8.01-95). If this flag is found in TRUE state, then INT 23 handler is called for.

Note 3: The INT 21\AH=06h also sends ASCII code into STDOUT channel, but doesn't check CTRL-C\CTRL-Break flag. Besides that, INT 21\AH=06h function performs quite different mission, if DL=FFh (8.02-04).

Note 4: Similarly to INT 21\AH=02h, the INT 21\AH=04h function sends ASCII code into STDAUX channel (default destination – COM1 port), and INT 21\AH=05h function sends ASCII code to STDPRN channel (default destination – LPT1 port).

8.02-04 INT 21\AH=06h – code copying from STDIN channel[edit | edit source]

Having been given the DL = FFh specification, INT 21\AH=06h function reads ASCII code from STDIN channel, almost as INT 21\AH=01h function does, but difference is that INT 21\AH=06h function

  • doesn't check the CTRL-C\CTRL-BREAK flag,
  • doesn't withdraw the copied code from its source,
  • doesn't cause waiting, when the source is empty,
  • doesn't send code's copy into STDOUT channel,
  • is able to cope with extended key codes.

The term "extended" is applied to those key codes, which differ by their scan-code part (left two digits of numbers in table A.02-1), and have their ASCII part values either 00h or E0h. If BIOS reports either of these two ASCII values, then INT 21\AH=06h function clears ZF flag and returns AL = 00h, thus indicating a keystroke with extended key code. In this case INT 21\AH=06h function has to be called once more, and then in AL register it will return scan-code, which enables to discriminate keystrokes with "extended" key codes.

Other ASCII codes (except 00h and E0h) are returned in AL register at once, and then scan-code can't be returned. After that repeated call for INT 21\AH=06h function is allowed, but it will be executed as separate, independent from the previous call.

Prepare : AH = 06h DL = FFh (for other values – note 3 to 8.02-03)

On return : ZR (set) state of ZF flag signifies that the source is empty NZ (cleared) state of ZF flag signifies presence of data, and then AL – ASCII code (or scan-code) copied via STDIN channel.

Note 1: INT 21\AH=07h function does almost the same, but withdraws the read code from STDIN source, ignores DL contents, doesn't alter the state of ZF flag, and may cause waiting for a keystroke, if STDIN source is keyboard buffer, and it is empty at that moment.

Note 2: INT 21\AH=08h function does the same as INT 21\AH=07h (see note 1 above), but besides this checks the state of that flag, which is set after CTRL-C and CTRL-Break keystrokes (8.01-95). If this flag is found in TRUE state, then INT 23 handler is called for.

Note 3: INT 21\AH=06h–08h functions shouldn't be called from command files, which are sent to command interpreter via redirection, because in this case INT 21\AH=06h–08h functions intercept STDIN traffic, including those commands which are to be received by command interpreter.

Note 4: If flag of hieroglyphic languages support (byte at offset 3Ch in table A.07-1) is set to TRUE state, then INT 21\AH=06h–08h functions are able to return partially formed double-byte codes.

8.02-05 INT 21\AH=09h – send a string to STDOUT[edit | edit source]

Prepare : AH = 09h DS:DX – pointer to start byte of a '$'-terminated string On return : AL = 24h (code of the "$" character, the last one in the string)

Note 1: Output continues until the first character "$" (24h) is encountered; the character "$" itself is not sent to STDOUT and must not be present inside the string.

Note 2: INT 21\AH=09h function checks the state of that flag, which is set after CTRL-C and CTRL-Break keystrokes (8.01-95). If this flag is found in TRUE state, then INT 23 handler is called for.

Note 3: One more function enabling to send a string is INT21\AH=40h (8.02-36).

8.02-06 INT 21\AH=0Ah – buffered input from STDIN channel[edit | edit source]

When STDIN channel isn't redirected, the INT 21\AH=0Ah function waits for keystroke(s) and after each keystroke writes its code into a prepared buffer. The buffer must not necessarily be empty: new data may be appended to previous buffer's contents. Copies of written codes are sent via STDOUT channel to display. Writing terminates after reception of the 0Dh code, produced by ENTER keystroke. When STDIN channel gets data from a file via redirection, then buffer filling goes non-stop and terminates after the first encountered 0Dh byte. In both cases writing terminates when prepared buffer becomes full.

Prepare : AH = 0Ah DS:DX – pointer to start of prepared buffer, where 2 bytes must be filled yet: at offset 00h: maximum buffer's size in bytes; at offset 01h: start offset for writing new data.

On return : DS:DX – pointer to start of filled buffer, where 2 bytes denote: at offset 00h: maximum buffer's size in bytes; at offset 01h: number of bytes actually written yet.

Note 1: INT 21\AH=0Ah function doesn't wait for a keystroke and returns control back at once, if buffer size (pointed at by DS:DX) is 00h.

Note 2: Count of bytes in prepared buffer starts from offset 02h, excluding byte 0Dh, which terminates writing session.

Note 3: INT 21\AH=0Ah function checks the state of that flag, which is set after CTRL-C and CTRL-Break keystrokes (8.01-95). If this flag is found in TRUE state, then INT 23 handler is called for.

Note 4: INT 21\AH=0Ah function shouldn't be called from command files, which are sent to command interpreter via redirection, because in this case INT 21\AH=0Ah function intercepts STDIN traffic, including those commands, which are to be received by command interpreter.

8.02-07 INT 21\AH=0Bh – get status of STDIN channel[edit | edit source]

The INT 21\AH=0Bh function is used to determine whether there are any data in STDIN channel source. When STDIN channel is not redirected, the INT 21\AH=0Bh function reports whether keyboard buffer is empty or not. If data are to be received via redirection, then INT 21\AH=0Bh function shows whether there is at least one byte pending in the source.

Prepare : AH = 0Bh

On return : AL = 00h, if STDIN channel source is empty, or else = FFh, if there is at least one byte in STDIN channel source.

Note 1: INT 21\AH=0Bh function checks the state of that flag, which is set after CTRL-C and CTRL-Break keystrokes (8.01-95). If this flag is found in TRUE state, then INT 23 handler is called for.

8.02-08 INT 21\AH=0Ch – clear keyboard buffer and read STDIN[edit | edit source]

The INT 21\AH=0Ch handler clears keyboard buffer and then calls for a selected STDIN input function, specified by its code in AL register. Allowed codes 01h, 06h, 07h, 08h, 0Ah correspond to functions INT 21\AH=01h, INT 21\AH=06h, INT 21\AH=07h, INT 21\AH=08h, INT 21\AH=0Ah. Other relevant features are defined by the chosen input function.

Prepare : AH = 0Ch AL – code of input function: 01h or 06h or 07h or 08h or 0Ah other registers – as required by the specified input function

On return : just as the specified input function returns.

Note 1: INT 21\AH=0Ch handler with allowed input function's codes shouldn't be called from command files, sent to command interpreter via redirection, because in this case input function intercepts STDIN traffic, including those commands, which are to be received by command interpreter.

Note 2: If code in AL is not one of allowed codes (01h, 06h, 07h, 08h, 0Ah), then INT 21\AH=0Ch handler clears keyboard buffer, but no STDIN input is attempted.

8.02-09 INT 21\AH=0Dh – write buffer's data to disk[edit | edit source]

Contents of disk buffers should be written back to current disk each time when current program intends to address another disk. Besides that, a call for INT 21\AH=0Dh function restores default address of DTA area (note 6 to A.07-1).

Prepare : AH = 0Dh

On return : Clear state of CF flag signifies successful termination.

Note 1: INT 21\AH=0Dh function writes disk buffers to disk, but doesn't update altered contents of directories. Directories are updated, when one of file's handles is closed by INT 21\AH=3Eh function (8.02-34).

8.02-10 INT 21\AH=0Eh – appointment of current logical disk[edit | edit source]

The INT 21\AH=0Eh function assigns "current" status to that logical disk, which should be chosen by default in order to enable execution of disk access operations without explicit disk specification.

Prepare : AH = 0Eh DL – number of the selected logical disk (note 1)

On return : AL – maximum number of letter-names, allowed by LASTDRIVE specification (4.17, 4.18)

Note 1: Numeration of logical disks follows the order of their letter-names: 00h = A:, 01h = B:, 02h = C:, and so on.

Note 2: Being called by drivers at their initiation, the INT 21\AH=0Eh function may return an invalid number in AL register, because it is read from list-of-lists (A.01-2) at offset 21h and may be not written there yet at the moment of initiation.

Note 3: Current number of default logical disk is reported by INT 21\AH=19h function (8.02-15).

8.02-11 INT 21\AH=11h – find first matching file using FCB[edit | edit source]

The INT 21\AH=11h handler uses FCB (File Control Block) – an obsolete form of data specification, unsuitable for access to files on disks formatted with FAT-32 file system. However, FCBs are suitable for matching file search inside current directory, including directories on disks with FAT-32 file system. Allowable FCB structures are shown in table A.09-5. Filename specification in FCB may be a mask with "?" wildcards (2.01-03). FCBs can be conveniently arranged by INT 21\AH=29h function (8.02-19).

Some search data, returned by INT 21\AH=11h handler, supplement data in FCB, as it is shown in table A.09-5. But main part of search results is returned in DTA – Data Transfer Area 128 bytes long. Default DTA position is inside PSP (A.07-1), starting at offset 80h, but DTA may be shifted elsewhere by INT 21\AH=1Ah function (8.02-16). Structure of returned data in DTA depends on type of original FCB – whether it was normal or extended FCB. Both variants of returned data structure are shown in table A.09-1.

Prepare : AH = 11h DS:DX – pointer to unopened FCB, normal or extended (A.09-5)

On return : AL – error code (A.06-1): = FFh – no matching files found = 00h – DTA region (A.09-1) is filled with data about first found file.

Note 1: INT 21\AH=11h function enables to obtain information about volume label. For this purpose an extended FCB with attribute byte 08h should be prepared, and current directory must be the disk's root directory.

Note 2: INT 21\AH=11h function enables to obtain information about a directory. For this purpose an extended FCB with attribute byte 10h should be prepared, and current directory must be the parent of requested directory.

Note 3: If search is to be continued with INT 21\AH=12h function (8.02-12), then all data in FCB and in DTA region, including the returned data, must be preserved unchanged.

Note 4: A search for a file without usage of FCB specification is performed by INT 21\AH=4Eh function.

8.02-12 INT 21\AH=12h – find next matching file using FCB[edit | edit source]

The INT 21\AH=12h function continues search for matching files after successful termination of preceding search iteration, performed either by INT 21\AH=11h (8.02-11) or by INT 21\AH=12h functions. Necessary condition of consistent continuation is preserving intact those data, returned in FCB and in DTA after preceding search iteration. Search results are returned just as after a call for INT 21\AH=11h (8.02-11).

Prepare : AH = 12h DS:DX – pointer to unopened FCB, normal or extended (A.09-5) DTA region (A.09-1) with data left after previous search iteration

On return : AL – error code (A.06-1): = FFh – no more matching files found = 00h – DTA region (A.09-1) is filled with data about next found file.

Note 1: All notes to INT 21\AH=11h (article 8.02-11) are equally valid for INT 21\AH=12h function.

8.02-13 INT 21\AH=13h – delete matching file(s) using FCB[edit | edit source]

The INT 21\AH=13h handler uses obsolete FCB (File Control Block) form of specification, which is nevertheless suitable for deletion of file(s) in current directory, including directories on disks formatted with FAT-32 file system. Allowable FCB structures are shown in table A.09-5. For deletion of several files FCB may specify a mask with "?" wildcards (2.01-03). FCB can be conveniently arranged by INT 21\AH=29h function (8.02-19).

Files to be deleted must be closed beforehand (8.02-34), must be free from HSR attributes (A.09-2), and disk with these files must not be write-protected.

Prepare : AH = 13h DS:DX – pointer to unopened FCB, normal or extended (A.09-5)

On return : AL – error code (A.06-1): = FFh – no matching files found = 00h – matching files have been deleted successfully.

Note 1: Owing to attribute byte in extended FCB (A.09-5) the INT 21\AH=13h function is able to delete volume labels and files with R (read-only) attribute. Deletion of subdirectories is also possible, but then files in these subdirectories are turned into lost clusters.

Note 2: Deleted file is not erased physically; rather its directory entry is made invalid: the first character of this entry becomes overwritten with invalidity mark – code E5h.

Note 3: Deletion of any file with long filename by INT 21\AH=13h function doesn't affect associated directory entries beyond the main one, whereas these entries contain continuation of long filename.

Note 4: File(s) deletion without FCB specification usage is performed by INT 21\AH=41h function (8.02-37).

8.02-14 INT 21\AH=17h – rename matching file using FCB[edit | edit source]

Prepare : AH = 17h DS:DX – pointer to unopened FCB, normal or extended (A.09-5). Current name is written in FCB at its ordinary place, proposed new name must be written 10h bytes further, just under the current name in next dump line. Particular offset values are given in table A.09-5. Both names must be written in normalized form, which is provided, for example, by INT 21\AH=29h function (8.02-19). Required buffer's length is 28 bytes for normal FCB and 35 bytes for extended FCB.

On return : AL – error code (A.06-1): = 00h – specified file has been renamed successfully. = FFh – failure: either matching file isn't found, or file is protected by HRS attributes, or a file with proposed new name exists yet.

Note 1: Filemasks in FCB are allowed, but only with "?" wildcards (2.01-03) and with the same wildcard positions in both filemasks: in that replacing the current filename and in that replacing the proposed new filename. Characters corresponding to wildcard positions will be copied from current actual filenames and inserted in the same positions in new assigned filenames.

Note 2: As far as FCB doesn't specify paths, INT 21\AH=17h function can rename files inside current directory only. Renaming outside the current directory may be performed by INT 21\AH=56h function (8.02-62), which doesn't use FCB specifications.

Note 3: Extended FCBs with attribute byte 10h enable to rename subdirectories from their parent directory, and extended FCBs with attribute byte 08h enable to rename volume label from root directory of the current disk.

8.02-15 INT 21\AH=19h – report "current" logical disk[edit | edit source]

The INT 21\AH=19h function reports which logical disk will be taken by default for disk access operations without explicit disk specifications.

Prepare : AH = 19h

On return : AL – number of "current" logical disk (note 1 to 8.02-10).

Note 1: Appointment of "current" logical disk can be changed by INT 21\AH=0Eh function (8.02-10).

8.02-16 INT 21\AH=1Ah,2Fh – set/get DTA area address[edit | edit source]

Data Transfer Area (DTA) is a buffer 128 bytes long used by file search functions (8.02-11, 8.02-12, 8.02-57, 8.02-58). Default position of DTA area is inside current program's PSP at offset 0080h (note 6 to A.07-1).

Prepare : AH – subfunction: = 1Ah – specify new position for DTA = 2Fh – report current DTA position DS:DX – pointer to new DTA position (for AH = 1Ah subfunction only)

On return : ES:BX – pointer to current DTA position (after AH = 2Fh subfunction only)

Note 1: Examples of DTA data structures are shown in table A.09-1.

Note 2: DTA is returned to its default position (PSP:0080h) after each call for INT 21\AH=0Dh function (8.02-09).

8.02-17 INT 21\AH=1Ch – get information about a disk[edit | edit source]

Prepare : AH = 1Ch DL – logical disk number (note 1) On return : AH – media identifier (ID byte): = F8h – fixed disk (HDD), = F9h – 1.2 Mb or 720 kb floppy diskette, = FAh – virtual RAM-disk, = FDh – 360 kb floppy diskette, = F0h – other media, including 1.44 Mb diskettes. CX – bytes per sector; DS:BX – pointer to the same media identifier byte in memory; DX and AL contents are not preserved.

Note 1: This function uses "shifted" numeration of logical disks: number 00h is the default ("current") logical disk, then follow 01h = A:, 02h = B:, 03h = C:, and so on.

Note 2: Being applied to an invalid or non-existing disk, INT 21\AH=1Ch doesn't indicate an error with CF flag, but rather returns values in AH, BX and DS registers unchanged.

Note 3: INT 21\AH=1Bh reports information in the same way about the default ("current") disk only, ignoring DL contents. Both INT 21\AH=1Ch and INT 21\AH=1Bh are obsolete functions, unable to identify most types of modern media.

8.02-18 INT 21\AH=25h – write a pointer into interrupt table[edit | edit source]

Prepare : AH = 25h AL – interrupt number, whose handler's address is to be written DS:DX – pointer to new interrupt handler

Note 1: This function overwrites the former handler's address. If it shouldn't be lost, you must take care about saving it in advance.

Note 2: INT 21\AH=25h handler, supplied by MS-DOS7, may be used while CPU is in real or in V86 mode, but can't be used in protected mode.

8.02-19 INT 21\AX=2901h – parse a filename into FCB[edit | edit source]

The INT 21\AX=2901h function arranges an unopened FCB (File Control Block) of normal type (A.09-5), filled with normalized form of given filename. File's name and suffix are written separately in their FCB fields, letters are translated to upper case, asterisk wildcards (2.01-03) are expanded into appropriate number of "?" wildcards. If name is less than 8 bytes long, or suffix is less than 3 bytes long, then the rest free character cells are filled with spaces (20h). Parsing is stopped at the first encountered slash, or at a space, or at 0Dh terminator byte (the 00h terminator byte is not allowed, though).

Thew filename cannot be preceded by a path, but may be preceded by disk's letter-name (for example, A:Config.sys). Disk's letter-name will be transformed into logical disk number, written into a cell in FCB just preceding the filename field. If the second character in presented line is not a colon, then disk's letter-name is considered missing, and disk number cell in FCB will be filled with 00h – number of the default ("current") disk.

Prepare : AH = 2901h DS:SI – pointer to filename string to be parsed (wildcards allowed) ES:DI – pointer to a prepared buffer 21 bytes long for FCB

On return : AL = 00h – successful parsing, no wildcards encountered = 01h – successful parsing, wildcards are present = FFh – parsing failed (invalid specification) DS:SI – pointer to the character where parsing has stopped ES:DI – pointer to a buffer filled with unopened FCB

Note 1: Buffer must be 36 bytes long, if later FCB has to be transferred into its "opened" form in order to provide access to a file.

Note 2: Parsing also can be performed by INT 21\AX=2903h function, which doesn't overwrite previous contents of disk number cell in FCB.

8.02-20 INT 21\AH=2Ah – get system date[edit | edit source]

Prepare : AH = 2Ah

On return : AL – day of the week (00h = Sunday) CX – year (range 1980 – 2099) DH – month DL – day

Note 1: All values are returned in packed decimal format, i.e. two decimal digits per byte.

Note 2: System date can be changed by INT 21\AH=2Bh function. The required values should be prepared in AL, CX, DH, DL registers just as it is shown above. If INT 21\AH=2Bh function fails, it returns AL=FFh and leaves system date unchanged.

8.02-21 INT 21\AH=2Ch – get system time[edit | edit source]

Prepare : AH = 2Ch

On return : CH – hours CL – minutes DH – seconds DL – 1/100 parts of a second

Note 1: All values are returned in packed decimal format, i.e. two decimal digits per byte.

Note 2: Some computers count DL values in steps 0.05 s, some other computers always return DL = 00h.

Note 3: System time can be changed by INT 21\AH=2Dh function. The required values should be prepared in CH, CL, DH, DL registers just as it is shown above. If INT 21\AH=2Dh function fails, it returns AL=FFh and leaves system time unchanged.

8.02-22 INT 21\AH=30h – get DOS version[edit | edit source]

Prepare : AX = 3000h – return manufacturer's (OEM) identifier in BH = 3001h – return version flag byte in BH.

On return : AL.AH – DOS version number BH – OEM identifier or version flag byte.

Note 1: OEM identifier is 00h for IBM, 66h for PhysTechSoft, EEh for DR-DOS, EFh for Novell, FDh for FreeDOS, FFh for Microsoft.

Note 2: TRUE state of bit 3 in version flag byte marks special DOS versions, designed to be stored in ROM.

Note 3: Returned version number is read from a word at offset 40h in PSP (A.07-1) of the caller program. If SETVER.EXE driver is installed, and if name of the caller program is written yet into SETVER's table, then a requested version will be substituted for true DOS version number at offset 40h in caller program's PSP.

Note 4: Certainly true DOS version number is reported by INT 21\AX=3306h function (8.02-27).

8.02-23 INT 21\AH=31h – terminate execution, leaving resident module[edit | edit source]

Prepare : AH = 31h AL – hexadecimal errorlevel value (note 3 to 8.02-55) DX – size of resident module in 16-byte paragraphs, not less then 6 paragraphs, counted from the start of PSP (A.07-1).

Note 1: INT 21\AH=31h function releases main program's memory (except its resident module), restores pointers in interrupt table, restores states of segment registers and stack, and then transfers control to caller's code pointed at by INT 22 (8.02-82). But INT 21\AH=31h function doesn't close opened files, doesn't release environment memory area and that memory, which has been allocated via INT 21\AH=48h (8.02-50). If necessary, these operations must be performed by the program itself before its termination.

Note 2: Obsolete INT 27 handler (8.02-86) does the same, but limits resident module's size to 64 kb and doesn't leave errorlevel values.

8.02-24 INT 21\AH=32h – get disk's parameters block (DPB)[edit | edit source]

Prepare : AH = 32h DL – logical disk number (note 1 to 8.02-17)

On return : AL = FFh, – requested disk is invalid or a network disk = 00h, – request is performed successfully, and then DS:BX – pointer to DPB block (A.03-1)

Note 1: A pointer in DS:BX to the default ("current") disk's DPB can also be obtained via INT 21\AH=1Fh; the latter ignores value in DL.

Note 2: Both INT 21\AH=32h and INT 21\AH=1Fh try to update the DPB by reading the requested disk. If reading fails, INT 24 handler is called for with its "Abort, Retry, Fail?" question. If disk access attempt at that moment is not desirable, the pointer to any DPB may be found via DOS's list of lists (note 1 to A.01-2).

Note 3: Both INT 21\AH=32h and INT 21\AH=1Fh can't be applied to disks formatted with FAT-32: then INT 21\AX=7302h function (8.02-79) should be used instead.

8.02-25 INT 21\AX=3300h – get BREAK flag's state[edit | edit source]

Prepare : AX = 3300h

On return : DL = 00h – BREAK flag is turned OFF = 01h – BREAK flag is turned ON

Note 1: BREAK flag is in DOS's swappable area at offset 17h (A.01-3).

Note 2: State of BREAK flag can be changed by INT 21\AX=3301 function, it accepts the state to be set from DL register in the same form.

8.02-26 INT 21\AX=3305h – get boot drive[edit | edit source]

Prepare : AX = 3305h

On return : DL – boot drive number (note 1 to 8.02-17)

Note 1: INT 21\AX=3305h function reads number of the disk, used to boot the PC, from DOS's list-of-lists (A.01-2) at offset 43h.

8.02-27 INT 21\AX=3306h – get true version of DOS[edit | edit source]

Prepare : AX = 3306h

On return : AL = FFh, if true version of DOS is less than 5.00 When any other value is returned in AL register, then : BL.BH – true version of DOS DH – flags: bit 3 – DOS is stored in ROM bit 4 – DOS is loaded into HMA area DL – DOS revision number.

Note 1: The data returned by INT 21\AX=3306h function can't be affected by SETVER.EXE driver (unlike those data returned by INT 21\AH=30h).

Note 2: INT 21\AX=3306h function is not supported by DOS versions less than 5.00. Besides AL = FFh, symptoms of obsolete DOS version may be values BL < 05h and BH > 64h.

8.02-28 INT 21\AH=34h – get address of InDOS flag[edit | edit source]

InDOS flag is a byte counter of active DOS functions nesting level: it is incremented whenever any INT 21 function is called for and is decremented when its execution terminates. States of InDOS flag and of critical error flag (note 1) should be checked before each call for a DOS function from any resident module: if either of these flags has a non-zero value, then such call is unsafe. Because of the same reason the INT 21\AH=34h function should be called once at initialization of TSR program, and the returned pointer should be saved. Later, when calls for DOS functions may be unsafe, system flag's states can be read immediately owing to the saved pointer.

Prepare : AH = 34h

On return : ES:BX – pointer to one-byte InDOS flag

Note 1: Critical error flag is a byte just preceding the InDOS flag (A.01-3). A pointer to critical error flag can be obtained via INT 21\AX=5D06h function.

8.02-29 INT 21\AH=35h – get pointer to interrupt handler[edit | edit source]

Prepare : AH = 35h AL – interrupt number

On return : ES:BX – pointer to interrupt handler.

8.02-30 INT 21\AH=36h – get disk's free space[edit | edit source]

Prepare : AH = 36h DL – logical disk's number (note 1 to 8.02-17)

On return : AX – number of sectors per cluster BX – number of free clusters CX – number of bytes per sector DX – total number of clusters on requested disk

Note 1: Free space (in bytes) can be found as product AX * BX * CX.

Note 2: Whole disk's space (in bytes) can be found as product AX * CX * DX.

Note 3: INT 21\AH=36h function reckons "lost" clusters among those used.

Note 4: After a request for an invalid or non-existing disk the AX = FFFFh value is returned. After a request for a CD\DVD-ROM the returned data are certainly invalid.

Note 5: Requests for FAT-32 disks are allowed, but actually reported space is limited to 2048 Mb. For larger disks the INT 21\AX=7303h function (8.02-80) should be used instead.

8.02-31 INT 21\AH=39h–3Ah – create/remove an empty subdirectory[edit | edit source]

Prepare : AH = 39h – create a subdirectory = 3Ah – remove an empty subdirectory DS:DX – pointer to a string with name of addressed directory. The string must end with 00h byte. Name may be preceded by a path. Maximum length of the string is 64 bytes.

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination. AX contents are not preserved.

Note 1: A directory can't be deleted, if it is the root directory, or if it is not free, or if it is marked as "current" in CDS table (A.03-3).

Note 2: Unlike ordinary directories, root directory has a limited capacity: if it is full, then new subdirectory inside this root directory can't be created.

8.02-32 INT 21\AH=3Bh – set current directory[edit | edit source]

The INT 21\AH=3Bh function rewrites default directory pathname in a CDS table entry (A.03-3) for a particular disk.

Prepare : AH = 3Bh DS:DX – pointer to a string with name of new default directory. The string must end with 00h byte. Name may be preceded by a path, optionally with disk's letter-name. Maximum length of the string is 64 bytes.

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination. AX contents are not preserved.

Note 1: If a call for INT 21\AH=3Bh specifies a disk, which is not "current" at that moment, then "current" directory is not changed at once, but the proposed default directory will become "current", when "current" status will be assigned to the specified disk.

Note 2: The INT 21\AH=47h function (8.02-49) reports current assignment of default directory.

8.02-33 INT 21\AH=3Dh – get an access handle[edit | edit source]

Handle is a hexadecimal identifier of a SFT entry (A.01-4). Each SFT entry is associated with some object: either with an existing file, or with a dedicated region of XMS memory, or with an access channel. Handle may be regarded as a numeric reference to that object. The INT 21\AH=3Dh function investigates whether there is an entry in SFT table, associated with the specified object. If associated entry exists yet, then number of registered references in this entry is incremented by 1, number of this SFT entry is written into a byte cell in JFT table (A.07-1, offset 18h), and ordinal number of that byte cell in JFT table is returned to the caller program as the requested handle. If associated SFT entry for the specified object doesn't exist, then INT 21\AH=3Dh handler creates a new SFT entry for the specified object, and after that performs just the same described sequence of operations, which finally returns a new handle to the caller program. Those files, which have got associated handles, are known as "opened" files.

Prepare : AH = 3Dh AL – access and sharing rights (A.09-4) DS:DX – pointer to object's name (ending with 00h byte)

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – handle – a numeric reference to specified object

Note 1: In order to obtain a handle for driver control channel you have to specify that name, which is stored starting at offset 0Ah inside driver's header (A.05-1). Ways to locate driver's headers are described in note 2 to appendix A.01-2, in article 8.03-12 and in introduction article to part 8.03.

Note 2: Wildcards in object's name are not allowed.

Note 3: On opening a file its access point is set at its first byte.

Note 4: A possibility to open a file doesn't depend on its attributes, but INT 21\AH=3Dh function can't associate handles with directories.

Note 5: INT 21\AH=3Dh handler may be called via server function INT 21\AX=5D00h (8.02-68), which gives an opportunity to specify in CL register an attribute mask (A.09-2) for the file, which is to be opened.

Note 6: Handles inherited from parent program inherit the same sharing and access restrictions. Access rights byte in AL register (A.09-4) also defines whether a particular handle will be inherited or not.

Note 7: If a file is stored in a logical disk formatted with FAT-32 file system, then associated handle for this file should be provided by INT 21\AX=6C00h function (8.02-78).

8.02-34 INT 21\AH=3Eh – delete an access handle[edit | edit source]

The INT 21\AH=3Eh function decrements by 1 the number of registered references to the same object in associated SFT entry (A.01-4) and removes number of that entry from a byte cell in JFT table (A.07-1) of the caller program. If object is a file, and if it has been altered, then corresponding directory record is corrected, and contents of disk buffers are written back to disk. If caller program has no duplicate handles for the same file, the latter becomes inaccessible, or "closed" for the caller program. But operating system considers a file closed only in case of zero number of references to this file, registered in associated SFT entry: only then this file can be deleted, and only then this file ceases to be a cause of blocking its removable media in the drive. A SFT entry with zero number of references is also considered closed and invalid.

Prepare : AH = 3Eh BX – handle (8.02-33) to be deleted

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination. AX contents are not preserved.

Note 1: A handle may be deleted by INT 21\AH=68h and by INT 21\AH=6Ah functions too. Other specifications for these functions (except AH) are the same.

Note 2: When a program is prepared for termination, all files, opened by this program, may be closed at once by INT 21\AX=5D01h function (8.02-69).

Note 3: Handles for areas of extended memory, opened by EMM386.EXE driver (5.04-02), should be deleted by INT 67\AH=45h function (8.03-61).

8.02-35 INT 21\AH=3Fh – read data from a source[edit | edit source]

Prepare : AH = 3Fh BX – handle (8.02-33) to source object: file, channel or device CX – number of bytes to read DS:DX – pointer to a buffer for read data

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – number of bytes actually read, DS:DX – pointer to buffer filled with data.

Note 1: Each program automatically inherits handle 0000h, which enables to read data from STDIN channel source, naturally, when STDIN channel is ready to supply these data. But if STDIN channel is not redirected, and its buffer is empty, then a request to 0000h handle initiates a buffer filling procedure with waiting for input from keyboard. Inputted characters are displayed on the screen, and their quantity is not limited by a number in CX register. Input terminates after ENTER keystroke, and then that number of characters, which is preset in CX register, is read from STDIN buffer into another buffer, defined by DS:DX pointer. The rest characters in STDIN buffer are available for reading by next calls for INT 21\AH=3Fh function.

Note 2: File data are read from current access position and on, so that access position is updated after each successful read operation.

Note 3: If requested number of bytes in CX register leads access position beyond file's end, then INT 21\AH=3Fh function terminates successfully, but number of read bytes, returned in AX register, will be less, than requested number of bytes in CX register.

8.02-36 INT 21\AH=40h – data transfer to a file or to a device[edit | edit source]

Prepare : AH = 40h BX – handle (8.02-33) to destination object: file, channel or device CX – number of bytes to transfer DS:DX – pointer to buffer with data to be transferred

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – number of bytes actually transferred.

Note 1: Each program automatically inherits 4 active handles to target channels: 0001h – to STDOUT channel, 0002h – to STDERR channel, 0003h – to STDAUX channel (port COM1), and 0004h – to STDPRN channel (port LPT1). STDOUT channel can be redirected, but its default target is display. STDERR channel can't be redirected; it always displays characters on the screen.

Note 2: Writing into a file starts at current access position, defined by access position pointer in SFT (A.01-4). After each successful writing procedure the current access position is automatically updated. If writing procedure leads current access position beyond file's end, then file's length is automatically increased. However, inflicted changes are not written to disk until file's handle isn't deleted (8.02-48).

Note 3: A call with CX = 0000h doesn't cause data transfer, but causes target file truncation (or extension) to that length, which is defined by current access position.

Note 4: On logical disks with FAT-32 file system files are allowed to grow beyond 2 Gb, if files are opened by INT 21\AX=6C00h function with TRUE state of "extended size" flag.

Note 5: If after data transfer the returned number in AX register is less then requested number in CX register, then the most probable cause of this difference is absence of free space on target disk.

8.02-37 INT 21\AH=41h – delete a closed file[edit | edit source]

Prepare : AH = 41h DS:DX – pointer to a string with filename. Name may be preceded by a path. String must end with 00h byte.

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination. AX contents are not preserved.

Note 1: Deleted file is not erased physically; rather its directory entry is made invalid: the first character of this entry becomes overwritten with invalidity mark – code E5h.

Note 2: Deletion of any file with long filename by INT 21\AH=41h function doesn't affect associated entries beyond the main one, whereas these directory entries contain continuation of long filename.

Note 3: Opened files may be deleted, but their handles will be kept active. This may cause FAT corruption and data loss. Each file, which is to be deleted, must be closed in advance (8.02-34).

Note 4: Wildcards in filename are not allowed, unless INT 21\AH=41h is called via server function INT 21\AX=5D00h. Server function also allows to specify in CL register an attribute mask (A.09-2) for the files to be deleted.

Note 5: Deletion of files from current directory can also be performed by INT 21\AH=13h function (8.02-13).

8.02-38 INT 21\AH=42h – set file's access point[edit | edit source]

File's access position is defined by a pointer in file's SFT entry (offset 15h in table A.01-4). Position of access point is counted from start of the file. INT 21\AH=42h function affects that pointer in file's SFT entry and thus shifts file access point.

Prepare : AH = 42h AL – code of origin for requested access point shift: = 00h – start of file = 01h – current access point position (note 1) = 02h – end of file (note 1) BX – file's handle (8.02-33) CX:DX – double word shift of requested access point from that origin, which is specified by code in AL register.

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then DX:AX – new access point position counted from file's start.

Note 1: Choice of origin codes 01h and 02h implies that requested shift in CX:DX is a signed double word. Operations with signed shift potentially may set an access point ahead of file's start. In such cases INT 21\AH=42h function returns CF flag cleared, but error will evince itself at an attempt of access.

Note 2: If new access point position is beyond file's end, then the nearest next writing operation (8.02-36) will automatically extend file's length up to actual access point position.

Note 3: File's size (in bytes) is returned in DX:AX registers after a call for INT 21\AH=42h function with AX=4202h and CX=DX=0000h.

Note 4: On logical disks with FAT-32 file system file access point positions beyond 2 Gb are allowed, if files are opened by INT 21\AX=6C00h function with TRUE state of "extended size" flag.

8.02-39 INT 21\AX=4300h – get file's attributes[edit | edit source]

Prepare : AX = 4300h DS:DX – pointer to a string with filename. Name may be preceded by a path. String must end with 00h byte.

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then CX – file's attributes word (A.09-2)

Note 1: INT 21\AX=4301h function enables to set attributes, prepared in CX register. AX contents may be lost on return. Other features are the same.

8.02-40 INT 21\AX=4400h – get information about a handle[edit | edit source]

Handle (8.02-33) is a hexadecimal identifier of a SFT entry (A.01-4). Each SFT entry is associated with some object: either with an existing file, or with a dedicated region of XMS memory, or with an access channel. Handle may be regarded as a numeric reference to that object. The INT 21\AH=4400h function enables to elicit some properties of both the given handle itself and the object it is associated with.

Prepare : AX = 4400h BX – handle (8.02-33)

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX contents are not preserved; DX – data word (note 1)

Note 1: Clear state of bit 7 in returned data word signifies a file handle data word, which should be interpreted according to table A.04-2. Set (TRUE) state of bit 7 in returned data word signifies attribute word of a non-file object. This attribute word should be interpreted according to table A.05-2.

Note 2: Attributes of channel's handle in attribute word (A.05-2) may be corrected by INT 21\AX=4401h function. States of bits 7–0 for attribute word should be prepared in DX register, bits 15–8 must be cleared, AX = 4401h, all other specifications are the same.

8.02-41 INT 21\AX=4402h–4403h – driver control data read/write[edit | edit source]

Main idea of I/O control (IOCTL) is that DOS allocates some memory space to driver's control data and enables programs to access this memory space in order to read and affect driver's control data. INT 21\AX=4402h–4403h handlers are charged with mission of access to driver's control data.

States of bits 6 and 7 in driver's attribute word (A.05-2) signify whether any particular driver supports programmable I/O control. If programmable I/O control is supported, then control data for this driver can be addressed by a handle, opened either by INT 21\AH=3Dh or by INT 21\AX=6C00h function (note 1 to 8.02-33).

Prepare : AX = 4402h – to read driver's control data = 4403h – to send driver's control data BX – a handle (8.02-33) referencing target driver CX – number of bytes to be transferred (buffer's length) DS:DX – pointer to buffer for data or with data to be sent

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – number of bytes actually transferred.

Note 1: Format of control data is specific for each particular driver. For example, a set of commands for CD/DVD-ROM drivers is shown in table A.15-4.

Note 2: Driver control data for disk drives (block devices) can't be addressed with a handle, but may be read by INT 21\AX=4404h and sent by INT 21\AX=4405h. Data specifications for these functions are similar to those shown above, except registers AX and BX: BL specifies disk's number (note 1 to 8.02-17), BH is ignored.

8.02-42 INT 21\AX=4406h–4407h – check of object's readiness for access[edit | edit source]

Prepare : AX = 4406h – input (reading) readiness check = 4407h – output (writing) readiness check BX – handle (8.02-33) to target object.

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AL = FFh – signifies that target object is ready for access = 00h – signifies that target object is not ready for access.

Note 1: If file's access point is set at file's end by access point shift operation INT 21\AH=42h (8.02-38), then INT 21\AX=4406h check may erroneously report file's readiness for reading (AL = FFh). This error wouldn't happen, when file's access point is set by reading or writing operations (8.02-35, 8.02-36).

Note 2: The INT 21\AX=4407h function doesn't check whether there is a media in the drive and whether this media has free space for writing.

8.02-43 INT 21\AX=4408h – check for a removable media[edit | edit source]

Prepare : AX = 4408h BL – logical disk number (note 1 to 8.02-17)

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX = 0000h – requested logical disk is removable, = 0001h – requested logical disk is fixed (HDD).

8.02-44 INT 21\AX=4409h – logical disk driver's attributes[edit | edit source]

Driver's attributes enable to determine whether the requested disk is real or virtual, whether it is local or network drive, is it accessible for BIOS functions or not. Interpretation of returned attribute word is shown in table A.05-2.

Prepare : AX = 4409h BL – logical disk number (note 1 to 8.02-17)

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX contents are not preserved; DX – driver's attributes word (A.05-2).

Note 1: Driver's attribute word reflects driver's capabilities, which don't necessarily correspond to properties of requested disk. For example, TRUE state of bit 11 in attribute word is interpreted as driver's ability to support removable media, but this gives no ground to conclude that the requested disk is a removable disk.

8.02-45 INT 21\AX=440Ah – check whether a handle implies remote access[edit | edit source]

Prepare : AX = 440Ah BX – a handle (8.02-33)

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then DX >= 8000h – signifies access via network..

8.02-46 INT 21\AX=440Dh – generic call for drive's subfunctions[edit | edit source]

The INT 21\AX=440Dh function is in fact a template for invoking a lot of IOCTL subfunctions. Type of subfunction is defined by its code in CL register. CH register contents define category code : CH = 08h corresponds to disk subfunctions, which are inherited from previous versions of DOS and can be applied to disks with FAT-12 and FAT-16 file systems. Category code CH=48h corresponds to disk subfunctions, which are introduced in MS-DOS7 and can be applied to disks with FAT-32 file system.

This article describes subfunctions with category code CH = 48h, which can be applied to disks with either of FAT-12, FAT-16, FAT-32 file systems and don't require BIOS's support for INT 13 extensions (8.01-55). It may be worth to check with INT 21\AX=4411h function (8.02-47) whether a particular IOCTL subfunction is supported in your computer.

General form of data presentation for all IOCTL subfunctions is data block pointed at by DS:DX registers. Interpretation of data in this data block for some subfunctions is shown in appendix A.04. Specific conditions for several other subfunctions are described in notes below.

Prepare : AX = 440Dh BL – logical disk number (note 1 to 8.02-17) CX – subfunction: = 4840h – set disk's parameters from a table (A.04-3) = 4841h – write a track onto logical disk (A.04-4) = 4842h – format and verify a track on a logical disk (A.04-5) = 4846h – set volume's serial number (A.04-1) = 4847h – set access flag (note 1) = 4848h – set media lock state (note 2) = 4849h – eject media from drive (no data block required) = 4860h – read disk's parameters (A.04-3) = 4861h – read a track from logical disk (A.04-4) = 4862h – verify logical disk's track (A.04-5) = 4866h – get volume's label and FAT type (A.04-1) = 4867h – get access flag (note 1) = 4868h – determine type of floppy disk (note 3) DS:DX – pointer to data block, if required for subfunction

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then DS:DX – pointer to data block, if it must be returned by subfunction.

Note 1: Subfunction CX=4847h accepts and subfunction 4867h returns in DS:DX data block nothing but an access byte at offset 01h. Any nonzero value means that access is allowed.

Note 2: Subfunction CL=4848h accepts operation code from byte at offset 00h in DS:DX data block: 00h – lock disk, 02h – unlock disk, 03h – report lock status (just as for INT 13\AH=45h, 8.01-58). Lock status – the number of pending locks on that disk – is returned in byte 01h of the same data block.

Note 3: In byte at offset 00h in DS:DX data block subfunction CX=4868h returns code 01h, if media is of default type for the requested drive, or else code 00h, if media is of any other type. Code of particular media type is returned in byte at offset 01h in the same data block: 02h – a 720 kb diskette, 07h – a 1.44 Mb diskette, 09h – a 2.88 Mb diskette.

8.02-47 INT 21\AX=4411h – check for generic call capability[edit | edit source]

The INT 21\AX=4411h function is a check whether a specified IOCTL subfunction is supported or not supported by BIOS, by hardware and by installable drivers in a particular PC.

Prepare : AX = 4411h BL – logical disk number (note 1 to 8.02-17) CX – subfunction code, just as for INT 21\AX=440Dh (8.02-46).

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX = 0000h – confirms that requested function is supported.

Note 1: Support for INT 21\AX=4411h function itself and for some other IOCTL subfunctions can be confirmed by driver's attribute word (A.05-2).

8.02-48 INT 21\AH=45h\46h – duplicate a handle[edit | edit source]

The INT 21\AH=45h function copies a SFT entry number from one byte cell in JFT table (note 3 to A.07-1) into the nearest free byte cell of the same JFT table. Ordinal numbers of both byte cells became handles, associated with the same SFT entry and with the same "opened" object. Creation of a duplicate handle may be necessary either for saving SFT entry number, or for relocation of entry numbers in JFT table, or just in order to delete a duplicate handle, because deletion of a handle initiates file's saving to disk, while presence of another handle to the same file prevents its closure.

The INT 21\AH=46h function also copies a SFT entry number from a byte cell in JFT table, but stores the copy in a prescribed byte cell, overwriting former SFT entry number in this cell. If, for example, the 0001h handle, associated with STDOUT channel, is made a duplicate of another handle, associated with a file, then output, normally sent to display, will be redirected into this file. Just in this way DOS performs redirection of input and output data traffic (2.04-02 – 2.04-05).

Prepare : AH = 45h – duplication, preserving current associations = 46h – duplication, overwriting a selected association BX – active handle (8.02-33), which is to be duplicated CX – another handle, which is to acquire association of the handle in BX (for INT 21\AH=46h function only).

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – automatically assigned duplicate handle (after a call for INT 21\AH=45h function only).

Note 1: If a handle, specified in CX register, is associated with an opened file, then after a call for INT 21\AH=46h function this file will become closed automatically.

Note 2: Shift of file access point for duplicate handle causes identical shift of file access point for the other handle, because both refer to the same SFT entry (A.01-4).

8.02-49 INT 21\AH=47h – get current directory[edit | edit source]

Prepare : AH = 47h DL – logical disk number (note 1 to 8.02-17) DS:SI – pointer to 64-byte buffer for pathname.

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX contents are not preserved; DS:SI – pointer to pathname, ending with 00h byte.

Note 1: Returned pathname doesn't include disk's letter-name and initial backslash.

Note 2: Default directory assignment may be changed with INT 21\AH=3Bh function (8.02-32).

8.02-50 INT 21\AH=48h – allot a memory block[edit | edit source]

Prepare : AH = 48h BX – requested block's size in 16-byte paragraphs

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – segment address of the allotted block BX – size in paragraphs of the largest available block.

Note 1: A request for BX=FFFFh can't be satisfied, but after this request INT 21\AH=48h function returns in BX register the whole available size of free conventional memory.

Note 2: Requests to INT 21\AH=48h function from *.COM programs may fail with error code AL=08h ("insufficient memory"), because by default DOS allots to any currently executed *.COM program the whole free space of conventional memory (details in note 5 to A.12-7). The *.COM programs must declare required amount of memory with a call for INT 21\AH=4Ah function (8.02-52), otherwise all the rest conventional memory wouldn't be considered free.

8.02-51 INT 21\AH=49h – release memory block[edit | edit source]

Prepare : AH = 49h ES – segment address of the block to be made free

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination.

8.02-52 INT 21\AH=4Ah – resize memory block[edit | edit source]

Prepare : AH = 4Ah BX – block's requested size (in 16-byte paragraphs) ES – segment address of the block to be resized

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then : BX – maximum number of paragraphs, available for specified memory block

Note 1: If there is no enough memory to expand the block as requested, the block will be made as large as possible.

8.02-53 INT 21\AH=4Bh – load a program for execution[edit | edit source]

Prepare : AH = 4Bh AL – subfunction: = 00h – loading and initiation of execution = 01h – loading without execution initiation = 03h – overlay loading (exchangeable part of code) DS:DX – pointer to a string with full specification for program call. Program's name must include suffix. The string must end with 00h byte. ES:BX – pointer to parameters block A.07-2.

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination. Contents of BX and DX registers are not preserved.

Note 1: Subfunction AL=00h creates a new PSP (A.07-1) for the loaded program and fills its environment segment with a copy of the caller's environment. Command line in new PSP ends with byte 00h (whereas in ordinary PSP it ends with byte 0Dh).

Note 2: Caller's mission comprises a check whether there is enough memory for the loaded program.

Note 3: Loading procedure is performed identically by both AL = 00h and AL = 01h subfunctions, but the latter doesn't initiate execution of the loaded program. In order to enable retarded execution initiation, inside ES:BX parameters block (A.07-2) the AL = 01h subfunction returns enter point address of the loaded program and a pointer to top of its stack.

Note 4: If an executable file starts with signature MZ or ZM, then it is loaded and executed as an *.EXE program. An executable file, which is to be executed as a *.COM program, shouldn't begin with signatures LE, LX, MP, MZ, NE, P2, P3, PE, PL, W3, W4, ZM.

Note 5: In order to execute a batch file, INT 21\AH=4Bh function has to load command interpreter COMMAND.COM (6.04) with /C parameter. Name of batch file should be specified after this parameter inside the same string, pointed at by DS:DX.

Note 6: When subfunction AL = 03h loads an overlay, it doesn't create PSP and environment, doesn't initiate execution of the loaded code, and doesn't check whether target memory area is allotted to the caller program. Subfunction AL = 03h needs other form of ES:BX parameter block: first word must be target segment address, the second word at offset 02h must be overlay relocation factor.

8.02-54 INT 21\AX=4B05h – set execution state[edit | edit source]

The INT 21\AX=4B05h function is used by programs which intercept calls for INT 21\AX=4B00h in order to prepare programs for execution, including substitution of DOS version number.

Prepare : AX = 4B05h DS:DX – pointer to execution state descriptor (A.07-3) On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX = 0000h.

Note 1: No DOS, BIOS or other software interrupts are allowed between return from INT 21\AX=4B05h call and initiation of child process.

Note 2: If DOS is running in HMA area, then A20 line is turned off on return from INT 21\AX=4B05h call.

8.02-55 INT 21\AH=4Ch – terminate execution, leaving errorlevel code[edit | edit source]

Prepare : AH = 4Ch AL – hexadecimal errorlevel code (note 3)

On return : return wouldn't happen.

Note 1: All network locks, set by executed program, should be removed before applying INT 21\AH=4Ch function.

Note 2: INT 21\AH=4Ch function closes all files, opened by executed program, and releases all its memory, unless the parent PSP pointer (at offset 16h in PSP, A.07-1) points at current PSP itself. This is a symptom of permanently loaded program, for example, of command interpreter COMMAND.COM (6.04).

Note 3: Specified errorlevel code is written into a word at offset 14h in DOS's swappable data area (A.01-3). Stored errorlevel code may be read later by INT 21\AH=4Dh function (8.02-56) or may be checked with "If errorlevel..." command (3.15-03).

Note 4: Inside operating environment of DEBUG.EXE the INT 21\AH=4Ch function closes debugger's session and transfers control to DOS. If debugger's session has to be continued, then execution of the program under test should be terminated otherwise: either by a breakpoint or by a call for INT 20 (8.02-01).

8.02-56 INT 21\AH=4Dh – read stored errorlevel code[edit | edit source]

Prepare : AH = 4Dh

On return : AH – termination type: = 00h – normal termination (8.02-01, 8.02-55) = 01h – abort caused by CTRL-C keystroke (8.01-95, 8.02-83) = 02h – abort caused by critical error (8.02-84) = 03h – termination leaving resident module (8.02-23, 8.02-86) AL – hexadecimal errorlevel code (notes 1 and 2)

Note 1: Errorlevel informs about circumstances of previous program termination, except permanently loaded programs and those executed in background mode.

Note 2: Errorlevel is stored in a word at offset 14h in DOS's swappable data area (A.01-3). Errorlevel is cleared automatically after each call for INT 21\AH=4Dh function; this is why it can't be read more than once. Multifold reading of errorlevel value can be performed from batch files (3.15-03).

Note 3: Internal commands of COMMAND.COM interpreter don't leave errorlevel code and don't affect that code, which is left after termination of preceding program.

8.02-57 INT 21\AH=4Eh – find first matching file[edit | edit source]

The INT 21\AH=4Eh function leaves returned data in DTA area. Default DTA address is in program's PSP (A.07-1) at offset 0080h, but it may be changed by INT 21\AH=1Ah function (8.02-16). A pointer to actual DTA position is reported by INT 21\AH=2Fh function (8.02-16). Format of returned data in DTA area is shown in column F4E of table A.09-1.

Prepare : AX = 4E00h CH = 00h CL – file's attribute mask (A.09-2) DS:DX – pointer to a string with name of the file to be searched for. Name may be preceded by a path. Filemask with wildcards is allowed instead of filename. String must end with 00h byte.

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then data about first found file are returned in DTA area (A.09-1).

Note 1: Bits 0 and 5 in file's attribute mask (A.09-2) are ignored. TRUE state of bits 1, 2 and 4 in file's attribute mask doesn't exclude finding of files having no corresponding attributes. TRUE state of bit 3 (volume label) excludes finding files.

Note 2: A search for requested file(s) in current directory can also be performed by INT 21\AH=11h function (8.02-11).

8.02-58 INT 21\AH=4Fh – find next matching file[edit | edit source]

Prepare : AH = 4Fh DTA area (A.09-1) with data left by previous search procedure

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then data about the next found file are returned in DTA area (A.09-1).

Note 1: For search continuation the INT 21\AH=4Fh function uses those data, which are returned by previous INT 21\AH=4Eh or INT 21\AH=4Fh call and since then are stored in DTA area (8.02-16). Until search isn't completed, one has to abstain from renaming, deleting and file moving operations, which alter directory entries and thus may invalidate the data left in DTA area.

8.02-59 INT 21\AH=52h – address of DOS's "List-of-Lists"[edit | edit source]

Prepare : AH = 52h

On return : ES:BX – pointer to DOS's "List-of-Lists " (A.01-2)

Note 1: Segment address, returned in ES: register, points at that data block, which is arranged by DOS's loader IO.SYS.

Note 2: If current program is executed not in real, but in emulated DOS environment, then INT 21\AH=52h function may return an obviously invalid address in ES:BX, for example, 0000:0000h or FFFF:FFFFh.

8.02-60 INT 21\AH=54h – get state of verify flag[edit | edit source]

Prepare : AH = 54h

On return : AL = 00h – verify flag is turned OFF, = 01h – verify flag is turned ON

Note 1: If verify flag is set ON, then each disk writing operation is followed by verification procedure (details in article 3.33). Default state of verify flag is OFF.

Note 2: State of verify flag may be changed by INT 21\AH=2Eh function. It accepts the requested state of verify flag from AL register in the same form.

8.02-61 INT 21\AH=55h – create a derived (child) PSP[edit | edit source]

The INT 21\AH=55h function arranges a new PSP (A.07-1), derived from actual PSP of the caller program. Parent segment field in new PSP is filled with segment address of caller program's PSP. Pointers to INT 22, INT 23 and INT 24 handlers are written into interrupt handler's fields in new PSP. JFT table fields for inherited handles are filled with copied numbers of corresponding SFT entries (A.01-4), and reference counters in these SFT entries are incremented by 1. Arranged new PSP can be used for execution of a *.COM program.

Prepare : AH = 55h DX – segment address for new PSP SI – value for PSP's memory size field at offset 02h.

On return : AL contents may be altered.

Note 1: Memory segment for the new PSP must be allotted by INT 21\AH=48h function (8.02-50). *.COM file, which is to be executed, should be written into this segment starting at offset 0100h. After that a control transfer procedure should follow, which includes redefinition of current process identifier by INT 21\AH=50h (note 1 to 8.02-73) and a CALL FAR command to offset 0100h in allotted segment.

8.02-62 INT 21\AH=56h – correction of directory entries[edit | edit source]

Correction of directory entries enables to rename files and subdirectories. Moving files from one directory into another within one logical disk also can be performed by moving directory entries. Since this doesn't imply file's copying, moving of directory entries is performed much faster.

Prepare : AH = 56h DS:DX – pointer to a string with a name of an existing object – file or directory (note 4). Name may be preceded by a path. String must end with byte 00h. ES:DI – pointer to a string with a new name (note 4) or with another path. String must end with byte 00h.

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: If a name, pointed at by DS:DX, belongs to an existing file, and a name, pointed at by ES:DI, belongs to an existing directory on the same logical disk, then the entry, corresponding to specified file, will be moved into target directory.

Note 2: If a name, pointed at by ES:DI, doesn't belong to an existing object, while a name, pointed at by DS:DX, belongs to an existing object – closed file or directory, then this existing object will be renamed. Renaming of opened files is not allowed.

Note 3: INT 21\AH=56h function doesn't assign the "A" attribute to files, which have been renamed or moved.

Note 4: Wildcards in names are not allowed, unless INT 21\AH=56h function is invoked via a server call INT 21\AX=5D00h (8.02-68). Besides wildcards (2.01-03), server call accepts from CL register an attribute mask (A.09-2), and marks successful renaming (or moving) of file's group by error code AL = 12h (= no more matching files).

8.02-63 INT 21\AX=5700h – date and time of file's last change[edit | edit source]

Prepare : AX = 5700h BX – file's handle (8.02-33)

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then CX – time of file's last change: bits 15–11 – hours from 00 to 23; bits 10–5 – minutes; bits 4–0 – seconds. DX – date of file's last change: bits 15–9 – year, counted from 1980; bits 8–5 – month; bits 4–0 – day.

Note 1: Date and time of file's last change may be set by INT 21\AX=5701h function: it accepts time from CX register and date from DX register in the same form.

Note 2: Date and time of file's creation similarly may be read by INT 21\AX=5706h function and set by INT 21\AX=5707h function. Both these functions use SI register for time code in .01 second units. However, date and time of file's creation are not necessarily registered under DOS.

Note 3: Date of last access to a file may be similarly read by INT 21\AX=5704h function and set by INT 21\AX=5705h function (the latter needs CX=0000h to be specified). However, registration of last access date may be prohibited by ACCDATE command (4.01).

8.02-64 INT 21\AX=5800h – memory allocation strategy[edit | edit source]

Prepare : AX = 5800h

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – current strategy code: bits 7 and 6: = 00 – use conventional memory; = 01 – use upper memory; = 10 – use conventional memory, only if upper memory is unavailable; bits 1 and 0: = 00 – allot first fit space; = 01 – allot best fit space; = 10 – allot last fit space. bits 15–8 and 5–2 must be cleared to zero.

Note 1: The INT 21\AX=5801h function accepts the same strategy code in BX register and enables to set it.

Note 2: Former memory allocation strategy must be restored before termination of each program, which has changed strategy settings.

Note 3: Proper memory allocation strategy is necessary, but not sufficient for upper memory usage: besides that, command DOS=UMB (4.08) must be present in CONFIG.SYS file.

8.02-65 INT 21\AH=59h – extended information about the last error[edit | edit source]

Prepare : AH = 59h BX = 0000h

On return : contents of CL, DX, SI, BP and DS registers are not preserved; BH – error class (A.06-2); BL – recommended action (A.06-3); CH – probable error locus (A.06-4); AX – error code (A.06-1); if AX=0022h, then ES:DI – pointer to media identifier (note 2 to A.06-1).

Note 1: Error information is read from DOS's swappable area (A.01-3).

Note 2: Error information is written into DOS' swappable area by INT 21\AX=5D0Ah function; it accepts in DS:DX registers a pointer to parameters list (A.07-4), and gets data from those words in this list, which correspond to registers AX, BX, CX, DI, DX, ES.

8.02-66 INT 21\AH=5Ah – create a temporary file[edit | edit source]

Prepare : AH = 5Ah CX – file's attributes (A.09-2) DS:DX – pointer to string with a path, ending with a backslash. After that backslash 13 bytes 00h must follow: it is a place for automatically generated filename.

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – handle (8.02-33) for created temporary file; DS:DX – pointer to string with path and appended filename.

Note 1: Created file automatically gets a unique name, excluding name conflicts.

Note 2: Capacity of root directories is limited. If disk's root directory is full, then a file in this directory can't be created.

Note 3: Each temporary file must be closed and deleted before termination of that program, which has requested creation of this temporary file.

8.02-67 INT 21\AH=5Bh – create a new file[edit | edit source]

Prepare : AH = 5Bh CX – file's attributes (A.09-2) DS:DX – pointer to string with a name for new file. Name may be preceded by a path. String must end with byte 00h.

On return : On error CF flag is set, AL returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – handle (8.02-33) for created new file.

Note 1: The INT 21\AH=5Bh function can't create new file, if a file with the same name exists yet in specified directory.

Note 2: Capacity of root directories is limited. If disk's root directory is full, then a file in this directory can't be created.

Note 3: The INT 21\AH=3Ch does the same and accepts the same specifications (except AH), but doesn't return error if a synonymous file is present in the same directory. This synonymous file will be just truncated to zero length, and a pointer to its first cluster will be lost. Therefore restoration of a truncated file is a much more complex procedure, then restoration after occasional ordinary deletion by functions INT 21\AH=13h (8.02-13) or INT 21\AH=41h (8.02-37).

8.02-68 INT 21\AX=5D00h – server function call[edit | edit source]

The INT 21\AX=5D00h function presents a template, enabling to call any other function of INT 21 handler and execute this function as a separate process with opportunities for selective and repeated execution. In particular, server call for INT 21\AH=3Dh function enables to specify an attribute mask for the target file. Besides that, server calls for INT 21\AH=56h and INT 21\AH=41h functions enable to rename and to delete files, specified by filemasks with wildcards (2.01-03).

Prepare : AX = 5D00h DS:DX – pointer to data block (A.07-4), specifying states of all registers, which should be prepared for execution of the requested function.

On return : – as should be returned by the requested function.

Note 1: Validity of initial data in data block is not checked. The computer may hang, if data block specifies invalid number of requested function for AH register.

Note 2: Filenames, required for INT 21 calls, must be prepared with full path in canonical form by INT 21\AH=60h function (8.02-72).

8.02-69 INT 21\AX=5D01h – close all files for a process[edit | edit source]

The INT 21\AH=5D01h function closes files, opened by caller process, updates all relevant directory entries and writes disk buffer's contents back to disk. If there are opened files, accessed via a network, then network service function INT 2F\AX=1107h is automatically called for.

Prepare : AX = 5D01h DS:DX – pointer to data block (A.07-4), specifying virtual machine identifier at offset 12h and process identifier at offset 14h. Contents of register's data fields in data block are ignored.

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination.

8.02-70 INT 21\AX=5D06h – address of swappable data area (SDA)[edit | edit source]

DOS functions store caller's status information: it may be needed later for these or other DOS functions, called by the same process. However, current process may be interrupted by other process – an invoked TSR program or interrupt handler. DOS functions, called by this other process, store other status information and corrupt data, related to interrupted process. Corrupted data prevent proper resumption of interrupted process. In order to avoid such conflicts relevant data should be saved and later restored. Therefore MS-DOS stores relevant data in SDA – Swappable Data Area (A.01-3). INT 21\AX=5D06h function returns address of SDA area and size of that data block, which should be saved in particular circumstances.

Prepare : AX = 5D06h

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then DS:SI – pointer to start of SDA area (A.01-3), CX – size in bytes of the whole SDA area, including status data and DOS's stacks. Whole SDA area must be saved in order to enable proper resumption of interrupted DOS function. DX – size in bytes of status data part of SDA area, which should be saved when interrupted process is not a DOS function.

Note 1: Saving of SDA's data is not needed, if interrupting process doesn't call for DOS functions.

Note 2: INT 21\AX=5D06h is also a DOS function, potentially able to damage data in SDA area, when interrupt has happened yet. Therefore INT 21\AX=5D06h function should be called beforehand, during initiation of driver or of resident program. Returned information should be stored and kept ready for future use.

8.02-71 INT 21\AX=5F08h – hide a logical disk[edit | edit source]

Prepare : AX = 5F08h DL – logical disk number (note 1 to 8.02-10)

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: INT 21\AX=5F08h function checks disk's parameters in DOS's internal tables. Having found disk's parameters invalid, the INT 21\AX=5F08h function fails.

Note 2: INT 21\AX=5F07h function accepts the same specifications (except AX), but performs reverse operation: turns a hidden disk into valid disk.

8.02-72 INT 21\AH=60h – convert filename or path into canonical form[edit | edit source]

Effect of INT 21\AH=60h function is identical to effect of TRUENAME command, described in article 3.29. Transformation of filename and path into canonical form is necessary for several DOS functions and enables to avoid errors, which otherwise may cause undesirable consequences.

Prepare : AH = 60h DS:SI – pointer to a string with a name, which may be preceded by a path. Maximum length of the string is 64 bytes. String must end with 00h byte. ES:DI – pointer to a 128-byte buffer for transformed name and path.

On return : On error CF flag is set, pointers with buffer contents are preserved, and AX register prompts possible cause of error : AX = 0002h – some component of path is invalid or absent = 0003h – wrong composition or invalid disk's letter-name. Clear state of CF flag signifies successful termination, and then ES:DI – pointer to buffer with transformed specification AX contents may be lost.

Note 1: Actual existence of specified name and path is not checked.

Note 2: INT 21\AH=60h function can't be applied to network paths.

8.02-73 INT 21\AH=62h – get current PSP address[edit | edit source]

DOS regards current PSP address as an identifier of the current process. Replacement of current process identifier with another one is the key operation in multitasking execution control. Identifier replacement implies reading the current identifier from SDA area (A.01-3) with INT 21\AH=62h function, saving the current identifier, and then writing a new identifier into SDA area. Having finished its job, program must restore the former process identifier before it returns control back. There are some other reasons to call for INT 21\AH=62h function in order to determine current PSP address (an example in 9.07-02).

Prepare : AH = 62h

On return : BX – segment address of PSP (A.07-1) for the current process.

Note 1: New process identifier may be written into SDA area with INT 21\AH=50h; the latter accepts prepared new identifier from BX register. Besides BX and AH=50h, no other data are needed.

8.02-74 INT 21\AX=6501h – country information[edit | edit source]

Prepare : AX = 6501h BX – hexadecimal codepage number, or BX=FFFFh for a request about current codepage. CX – size of prepared buffer for data, not less than 29h bytes DX – country identifier, or DX=FFFFh for current country request ES:DI – pointer to prepared buffer for data

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then ES:DI – pointer to buffer filled with data (A.02-4) CX – size (in bytes) of buffer's filled part.

Note 1: Functions INT 21\AX=6502h, 6504h, 6505h, 6506h use the same specifications (except AX), but return in ES:DI buffer only one 4-byte address at offset 01h :

  • INT 21\AX=6502h returns a pointer to uppercase table, which begins with its size (1 word), followed by 128 uppercase equivalents (in there are any) of characters from 80h to FFh.
  • INT 21\AX=6504h returns a pointer to filename uppercase table, which has the same structure, but is applied to filenames only.
  • INT 21\AX=6505h returns a pointer to filename restrictions table (A.02-5).
  • INT 21\AX=6506h returns a pointer to collating sequence table, which begins with its size (1 word), followed by 256 bytes, defining order of sorting for characters from 00h to FFh.

Note 2: Information concerning other countries and other code tables, not installed at the current moment, is not available, unless the NLSFUNC.EXE resident program (5.02-03) is installed.

Note 3: Country information in MS-DOS7 may be set with INT 21\AX=7002h function. It accepts in DS:SI a pointer to data table (A.02-4), in CX – length of that table (normally 0026h bytes). If CF is clear on return, then CX – length of actually set data. Set state of CF flag signifies an error: AX = 7000h means that function is not supported; other error codes correspond to table A.06-1.

8.02-75 INT 21\AX=6521h – country-dependent string capitalization[edit | edit source]

Prepare : AX = 6521h CX – length of string to capitalize DS:DX – pointer to the string to capitalize

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies success, submitted string is capitalized.

Note 1: The INT 21\AX=6522h function does the same, but ignores CX and requires the end of string to be marked with byte 00h.

Note 2: INT 21\AX=6520h function is used to capitalize a single character, accepted and returned in DL. CX and DS contents are ignored.

8.02-76 INT 21\AH=67h – set size of handle table[edit | edit source]

By default not more than 20 handles can be kept active simultaneously, because size of original JFT (offset 18h in A.07-1) is limited to 20 bytes. The INT 21\AH=67h function creates a new JFT table outside PSP, thus removing default restriction, caused by limited length of original JFT.

Prepare : AH = 67h BX – number of handles in new JFT table for current process

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: If current JFT is inside PSP, and new size in BX is no more than 20 bytes, then no action is undertaken.

Note 2: If current JFT outside PSP contains no more than 20 active handles, and new JFT size in BX is no more than 20 bytes, then JFT is copied back into PSP.

Note 3: If a reduced JFT size is requested, and active handles can't fit into this reduced size, then INT 21\AH=67h function fails with error code 0004h (= too many opened files).

Note 4: Number of simultaneously opened files is limited not by JFT table only, but also by SFT table (A.01-4). Length of the latter is defined by command FILES (4.12) in configuration file CONFIG.SYS.

Note 5: Irrespective of current JFT size and location, the child process can't inherit more than 20 active handles from its parent process.

8.02-77 INT 21\AX=6900h – get volume label and FAT type[edit | edit source]

The same data block A.04-1 with disk's volume specifications is returned by both INT 21\AX=440Dh\CX=4866h and INT 21\AX=6900h functions, except that the latter in case of access failure doesn't call for critical error handler INT 24 (8.02-84). All errors are reported via their code returned in AX.

Prepare : AX = 6900h BH = 00h BL – logical disk number (note 1 to 8.02-17) DS:DX – pointer to buffer 19h bytes long for data block

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then DS:DX – pointer to buffer with written data block (A.04-1) AH contents may be altered.

Note 1: Data starting at offset 02h in returned data block are copied from bytes at offsets 27h–3Dh in extended BPB block (A.03-4).

Note 2: Error code 0005h is reported if extended BPB is not found in the requested disk.

Note 3: The INT 21\AX=6900h function can't be applied to network drives. Such calls return error code 0001h.

Note 4: INT 21\AX=6901h function performs the reverse operation: it accepts data block (A.04-1), pointed at by DS:DX, and copies disk's volume data from this block into extended BPB of that disk, which is similarly specified by its number in BX register.

8.02-78 INT 21\AX=6C00h – extended get handle function[edit | edit source]

A handle for access to an object can be obtained with both INT 21\AH=3Dh (8.02-33) and INT 21\AX=6C00h functions, but the latter provides extended capabilities to define handle's properties and prescribed actions.

Prepare : AX = 6C00h BH – properties flags: bit 4 – allow file's size above 2GB (for FAT-32 only) bit 5 – return error rather than call for INT 24h bit 6 – write to disk immediately, bypass cache buffer BL – access and sharing conditions (A.09-4) CX – file's attributes (A.09-2), if file is to be created DH = 00h DL – prescribed action code: = 01h – open an existing file, fail if it doesn't exist; = 10h – open a new file, fail if a synonymous file exists; = 11h – open a file; create it anew, if it doesn't exist; = 12h – open a new file; if synonymous file exists, remove it. DS:SI – pointer to a string with filename, optionally preceded by a path. Wildcards in filename are not allowed. The string must end with byte 00h.

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then AX – returned handle to opened file CX – status code: = 0001h – file is opened; = 0002h – file has been created; = 0003h – file has been replaced.

Note 1: Prescribed action DL = 11h is not supported on remote disks.

Note 2: Operations with remote disks don't return status code in CX.

Note 3: If a file is created anew, then contents of both BH and BL are copied into a new SFT entry (A.01-4).

Note 4: On opening a file its access pointer is set to file's start.

Note 5: Opportunity to open a file doesn't depend on its attributes.

8.02-79 INT 21\AX=7302h – copying of extended DPB[edit | edit source]

The INT 21\AX=7302h function copies Disk Parameters Block (DPB) into a prepared buffer. Requested DPB (A.03-1) may belong to a disk formatted with either FAT-12, FAT-16 or FAT-32 file system.

Prepare : AX = 7302h DL – logical disk number (note 1 to 8.02-17) CX – length of prepared buffer, not less than 3Dh bytes ES:DI – pointer to prepared buffer for DPB

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies success, DPB table is copied (note 2).

Note 1: Unlike similar functions INT 21\AH=1Fh and INT 21\AH=32h (8.02-24), the INT 21\AX=7302h function is not available in previous DOS versions and fails, if PC's BIOS doesn't support INT 13 extensions (8.01-55).

Note 2: The word at offset 00h in returned data block is its length; a copy of DPB (A.03-1) starts at offset DI+02.

Note 3: Place for driver's header address at offset 13h in returned copy of DPB is filled with FFFFh.

Note 4: The INT 21\AX=7302h function attempts to read BPB on the requested disk in order to update DPB. If access fails, INT 24 handler is called for.

8.02-80 INT 21\AX=7303h – get free space table[edit | edit source]

The INT 21\AX=7303h function reports free space on disks formatted with either FAT-12, FAT-16 or FAT-32 file systems. Returned data block (A.13-7) is copied into prepared buffer. Unlike values, returned by INT 21\AH=36h function (8.02-30), values in data block A.13-7 are not limited to 2048 Mb.

Prepare : AX = 7303h CX – length of prepared buffer, not less than 34h bytes DS:DX – pointer to string, defining the requested disk (note 2) ES:DI – pointer to buffer for data block; a word at offset 02h in this buffer must be filled with 0000h beforehand.

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then ES:DI – pointer to buffer filled with data block (A.13-7), AL – size of the returned data block.

Note 1: Unlike similar function INT 21\AH=36h, the INT 21\AX=7302h function is not available in previous DOS versions and fails, if PC's BIOS doesn't support INT 13 extensions (8.01-55).

Note 2: Prepared string must define the requested disk just as it is defined in CDS table (A.03-3): for example, C:\ for local disks and \\SERVER\Share for disks, accessed via a network. Prepared string must end with byte 00h.

8.02-81 INT 21\AX=7305h – extended read/write operations[edit | edit source]

The INT 21\AX=7305h function presents 5 subfunctions for performing reading and writing operations inside logical disks, formatted with either FAT-12, FAT-16 or FAT-32 file systems. Similarly to INT 25 and INT 26 handlers (8.02-85), subfunctions of INT 21\AX=7305h ignore file structure and are addressed by sector numbers, counted separately for each logical disk from its start.

Prepare : AX = 7305h DL – logical disk number (note 1 to 8.02-17) DS:BX – pointer to disk address packet (note 2) SI – subfunction: = 0000h – reading = 0001h – writing any non-specific data = 2001h – writing FAT data = 4001h – writing directory data = 6001h – writing file data

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination.

Note 1: Unlike similar functions INT 25 and INT 26 (8.02-85), the INT 21\AX=7302h function is not available in previous DOS versions and fails, if PC's BIOS doesn't support INT 13 extensions (8.01-55).

Note 2: Disk address packet is 10 bytes long and contains at offset : 00h – double word: operation start sector number ; 04h – a word: number of sectors to be read or written ; 06h – double word: address of buffer with data or for data.

8.02-82 INT 22 – address of control return point[edit | edit source]

Address in INT 22 cell of interrupt table belongs not to a handler, but to a return point inside parent process. When current program terminates, control is to be transferred just to INT 22 address of this return point. Most often INT 22 points at command following that call for INT 21\AH=4Bh function (8.02-53), which has been used to launch current program.

Interrupt INT 22 shouldn't be called directly, because parent process can't proceed normally without restoration of many necessary conditions, including state of stack and addresses in INT 22 – INT 24 cells of interrupt table. All necessary preparations are performed by program termination handlers INT 20 (8.02-01) and INT 21\AH=4Ch (8.02-55). These handlers read INT 22 address from interrupt table, temporary save it, copy parent's control return point address from offset 0Ah in current program's PSP (A.07-1) into the same INT 22 cell, and then execute a JMP FAR command (7.03-39) to temporary saved address.

8.02-83 INT 23 – CTRL-C/CTRL-Break handler[edit | edit source]

Each time when keyboard controller reports about CTRL-C/CTRL-Break keystroke, INT 09 handler calls for INT 1B, and the latter sets TRUE state to a flag in BIOS data area (at offset 71h in table A.02-3). State of this flag is checked by some MS-DOS functions, called by current program. If flag is found set to TRUE state, then INT 23 handler is called for, which suspends execution of current program.

Code of INT 23 handler is written in presumption that its caller is a DOS function. Therefore calls for INT 23 from application programs are not allowed, except indirect calls via INT 1B (8.01-95).

Further events partially depend on circumstances, but in most cases the user has to choose: either continue or terminate execution of the suspended program. Possible user's actions in response are described in article 1.03. If termination alternative is chosen, then INT 23 handler closes all files, opened by suspended program, releases its memory, defines zero errorlevel, sets CF flag into CY state, and after that transfers control to parent process – that one, which has called current program. If user chooses continuation, then states of all registers and flags are restored, and control is transferred to that DOS function, which has called INT 23 handler. Having finished its mission, this DOS function returns control back to its caller – to the current program.

8.02-84 INT 24 – critical error handler[edit | edit source]

When inadequate responses are returned to DOS function's requests, then these DOS functions call for INT 24 – critical error handler. The INT 24 handler analyses information about each error, but most often doesn't rely upon itself, and addresses its famous question "Abort, Retry, Fail?" to the user. Having got user's decision, INT 24 handler transfers it for execution to that DOS function, which has called for INT 24.

Code of INT 24 handler is written in presumption that its caller is a DOS function. Therefore direct calls for INT 24 from application programs are not allowed.

On return states of all registers (except AL) are restored from the stack, and AL returns action code : AL = 00h – return to caller program with error code (fail); = 01h – make one more attempt of the same request (retry); = 02h – terminate execution of the caller program (abort); = 03h – admit system failure and halt the CPU.

Note 1: Automatic answer FAIL and non-stop continuation of execution can be ensured by set state of flag at offset 2Ah in SDA (A.01-3). In particular, this flag is set by command interpreter COMMAND.COM, when it is launched with undocumented parameter /f (6.04).

8.02-85 Direct disk read (INT 25) and write (INT 26)[edit | edit source]

NT 25 and INT 26 handlers enable access to logical disks, formatted with file systems FAT-12 and FAT-16. Disk access is addressed by sector numbers, counted separately within each logical disk from sector number 00000000h and on. Data buffer address and particular sector numbers are transferred inside disk address packet, described in note 2 to 8.02-81.

Prepare : AL – logical disk number (note 1 to 8.02-10) CX = FFFFh (note 3) DS:BX – pointer to disk address packet (note 2 to 8.02-81).

On return : States of BX, CX, DX, DI, SI registers are not preserved. On error CF flag is set, AL returns error code (A.06-1), AH returns error status according to table A.06-5. Clear state of CF flag signifies successful termination.

Note 1: INT 25 and INT 26 handlers leave a word of flag's states in top of stack. The caller program has either to pop this word out of stack or to restore former value in SP register.

Note 2: INT 25 and INT 26 handlers are able to provide access to logical disks with 32-bit data transfer, marked by TRUE state of bit 1 in driver's attribute word (A.05-2).

Note 3: Being applied to small logical disks without cluster structure (32 Mb or less, ID 04h in table A.13-6), INT 25 and INT 26 handlers employ different form of specification : CX – number of sectors to be read or written DX – number of start sector DS:BX – pointer to a buffer with data or for data.

Note 4: INT 25 and INT 26 handlers can't be applied to logical disks formatted with FAT-32 file system, the INT 21\AX=7305h handler (8.02-81) should be used instead.

8.02-86 INT 27 – terminate execution, leaving resident module[edit | edit source]

Prepare : CS – segment address of current program's PSP DX – size of resident module, from 60h to FFF0h bytes, counted from start of current program's PSP

Note 1: The INT 27 handler transfers control to the parent process – that one, which has launched the current program. INT 27 handler makes necessary preparations for control transfer: releases main program's memory (except its resident module), restores pointers in interrupt table. But INT 27 handler doesn't close opened files : this must be done by current program itself beforehand.

Note 2: The INT 21\AH=31h function (8.02-23) has the same mission, but doesn't limit resident module's size at 64 kb and enables to leave non-zero errorlevel values.

8.02-87 INT 28 – DOS idle hook for background execution[edit | edit source]

The INT 28 interrupt is invoked at a pace of timer's tick (18 times per second) while any of DOS's character input functions (INT 21\AH=01h–0Ch) is waiting for input from keyboard. DOS is actually idle during such waiting intervals. Default INT 28 handler is a single IRET instruction (7.03-30), which simply returns control back to the caller. Interception of INT 28 enables to activate a background program or a TSR while the foreground program is waiting for user input. Intercepting INT 28 handler gets SS:SP registers pointing at top of DOS's stack and has to restore states of all registers on return.

Note 1: A program, which intercepts INT 28, must check the state of InDOS flag (at offset 01h in A.01-3). Address of that flag must be found beforehand with a call for INT 21\AH=34h (8.02-28) function and must be stored since program's initialization. At the moment of INT 28 call the value of InDOS flag normally is 01h; if it has larger value, then all calls for DOS functions from intercepting program are prohibited.

Note 2: Programs, designed for background execution, when InDOS flag has its normal value 01h, are allowed to call for DOS functions, except INT 21\AH=01h–0Ch functions and except calls, addressed to CON device handles (normally these are handles 0000h–0002h).

8.02-88 INT 29 – non-redirectable console output[edit | edit source]

The INT 29 handler is used to display messages on the screen, when STDOUT output is (or may be) redirected elsewhere — to a file or a device, other than display (CON) device.

Prepare : AL – ASCII code of the character to be displayed On return : BX register contents may be altered.

Note 1: Default INT 29 handler sends character's code to display via BIOS's function INT 10\AH=0Eh (8.01-21).

Note 2: Bit 4 in CON device driver's attribute word (A.05-2) indicates whether the CON device driver supports INT 29.

Note 3: Non-redirectable display of a character string also can be performed via STDERR channel (handle 0002h), addressed by INT 21\AH=40h function (8.02-36). Unlike INT 29, STDERR channel is always supported by CON device driver.

8.02-89 INT 2E – transmit a command to interpreter[edit | edit source]

The INT 2E handler transfers a command line for execution to command interpreter COMMAND.COM, but doesn't load interpreter's module anew. Command line is transferred to that interpreter's resident module, which is loaded yet and which has launched the caller program.

Prepare : DS:SI – pointer to command line to be executed. Format of command line must be identical to that in PSP (A.07-1, offset 80h): first byte is line's length, then follows command line itself, terminated with byte 0Dh. Length count doesn't include terminating byte.

On return : AX – error code (A.06-1); Contents of all registers, except CS:IP, can be altered..

Note 1: Resident module of command interpreter may need to load transient portion of COMMAND.COM interpreter for execution of specified command. Caller program must ensure that DOS will be able to allocate sufficient memory for transient portion of COMMAND.COM interpreter.

Note 2: Being invoked by INT 2E, COMMAND.COM interpreter works with its original environment, which may differ from the caller's environment. Hence all changes in environment variables, if there are any, will not be accessible for the caller.

Note 3: INT 2E shouldn't be called by programs, which are launched from a batch file.

8.03 Interrupt handlers, loaded by drivers and TSR programs[edit | edit source]

When DOS starts execution of application program, then pointers to BIOS's and DOS's interrupt handlers are certainly written yet in their cells of interrupt table. Application programs don't need to check presence of these pointers in their cells. This is not true for those handlers, which are loaded by optional software — drivers and TSR programs. Corresponding cells in interrupt table may be left empty, and application programs must check, whether these cells are filled with valid pointers.

Long time ago, when drivers were not numerous, each driver used to have its own cell in interrupt table. Then validity of handler's address could be confirmed by presence of a specific signature in some vicinity of addressed point. This manner of confirmation may be applied, for example, to resident module of EMM386.EXE driver (note 1 to 8.03-62), whose ancestors are known since 1983.

As more and more drivers appeared, shortage of space in interrupt table began to cause conflicts. Besides that, it was desirable to eliminate threat of hanging, when the addressed resident module isn't loaded. As a solution of both these problems an idea of multiplex interrupt INT 2F has been suggested. Every participating driver had to intercept INT 2F calls, thus forming a link in a chain of interceptors (details in A.07-5). A call for INT 2F has to pass along this chain from one handler to the other, and each handler analyses an identifier in AH register. If a handler doesn't recognize its own identifier in AH, it leaves AX intact and lets this call to "travel" further along the chain. If specified identifier isn't recognized by all handlers, then the call for INT 2F reaches the last chain's link – a IRET command, initially set by DOS. IRET command returns control to the caller program, so that AX value is returned unchanged. A change of AX contents can be regarded as an evidence of that some handler has recognized its own identifier; hence, the requested resident module is loaded yet.

Naturally, multiplex interrupt is suitable not only for recognition. It enables to address main functions of optional resident modules without risk of hanging when required modules are not loaded. However, tracing a long chain of references takes time and makes execution slower. In order to avoid delays many drivers return addresses of their entrance points via INT 2F. Direct calls to these entrance points invoke specific functions of resident modules much faster, than via multiplex interrupt. For example, multiplex interrupt INT 2F is used by HIMEM.SYS driver (5.04-01) in order to return address of its entrance point (8.03-23).

Practice of INT 2F usage has got a limited success for some time, but it couldn't eliminate conflicts caused by inconsistent appointment of identifiers to different drivers and resident modules. In order to avoid such conflicts one more idea has been suggested — dynamic assignment of identifiers: each resident module should assign to itself the first free identifier it finds. This idea is implemented by multiplex interrupt INT 2D (details in A.07-6). Now resident DOS's software has got rid of identification conflicts owing to multiplex interrupt INT 2D.

Meanwhile many drivers with well known identifiers continue to use multiplex interrupt INT 2F. Moreover, several resident modules, which were loaded by drivers in previous DOS versions, now are integrated into DOS kernel together with their INT 2F identifiers for the sake of preserving compatibility. There is no sense in testing presence of resident modules with INT 2F identifiers AH = 05h, 08h and 12h, which actually are now DOS functions. Nevertheless such integrated functions are described below in part 8.03 among functions of optionally loaded software, because otherwise convenience of their ordinal search will be lost.

8.03-01 INT 2F\AX=0501h – convert error code into message[edit | edit source]

Prepare : AX = 0501h BX – error code to be converted (A.06-1)

On return : Contents of AX, DI, ES registers and states of flags are not preserved. Set state of CF flag means that DOS has no message for submitted code. Clear state of CF flag signifies successful termination, and then ES:DI – pointer to read-only message, ending with byte 00h; AL = 00h – message needs to be complemented with disk's letter-name; = 01h – returned message is complete.

8.03-02 INT 2F\AX=0801h – accept DDT for a logical disk[edit | edit source]

The INT 2F\AX=0801h function appends DOS's chain of disk data tables (DDT) with a prepared DDT table, and modifies disk description flags in other tables, referencing the same physical drive. Since that moment the added logical disk becomes accessible by means of block device drivers, integrated into the DOS's core.

Prepare : AX = 0801h DS:DI – pointer to the prepared DDT table (A.03-2)

On return : Contents of AX, BX, SI, ES registers are not preserved.

Note 1: The INT 2F\AX=0801h function shouldn't be applied to IFS, remote and other disks, which can't be served by native DOS's block device drivers.

Note 2: An example of DDT table can be obtained via INT 2F\AX=0803h function.

8.03-03 INT 2F\AX=0802h – send a request to block device driver[edit | edit source]

The INT 2F\AX=0802h function executes requests concerning logical disks, represented by valid disk data tables (A.03-2) and controlled by block device drivers, integrated into DOS's core. Both addressed disk number and code of the requested operation (A.05-3) should be specified inside a request data block (A.05-4).

Prepare : AX = 0802h ES:BX – pointer to request data block (A.05-4)

On return : ES:BX – pointer to request data block, updated according to the requested operation (A.05-3 – A.05-7)

Note 1: INT 2F\AX=0802h function leaves a word of flag's states in top of stack. The caller program has either to pop this word out of stack or to restore former value in SP register.

Note 2: Possible errors are announced by error codes, returned in bytes at offsets 03h and 04h in request data block (A.05-4). In any case critical error handler (INT 24) is not invoked.

8.03-04 INT 2F\AX=0803h – get address of the first DDT[edit | edit source]

Prepare : AX = 0803h

On return : DS:DI – pointer to start of the first DDT table (A.03-2)

Note 1: A chain of DDT tables can be easily traced through, since the first double word in each DDT table is a pointer to the next DDT table (A.03-2).

8.03-05 INT 2F\AX=1202h – get a pointer to interrupt handler's address[edit | edit source]

Prepare : AX = 1202h interrupt number should be in top of stack

On return : ES:BX – pointer to interrupt handler's address; contents of AX register may be altered; state of stack is returned unchanged.

Note 1: While CPU is in real mode, the INT 2F\AX=1202h function just multiplies interrupt number by 4.

8.03-06 INT 2F\AX=1212h – determine length of a string[edit | edit source]

Prepare : AX = 1212h ES:DI – pointer to ASCIIZ string, ending with 00h byte.

On return : CX – length of the string, including terminating 00h byte.

Note 1: The INT 2F\AX=1225h function does the same, but accepts the pointer from DS:SI registers pair.

8.03-07 INT 2F\AX=1213h – uppercase a character[edit | edit source]

Prepare : AX = 1213h ASCII code of the character should be in top of stack.

On return : AL – upper case ASCII code of the same character. State of stack is returned unchanged.

8.03-08 INT 2F\AX=1214h – comparison of far pointers[edit | edit source]

Prepare : AX = 1212h DS:SI – first pointer ES:DI – second pointer

On return : ZF flag set and CF flag clear if pointers are equal; ZF flag clear and CF flag set if pointers differ.

8.03-09 INT 2F\AX=1216h – get a pointer to SFT entry[edit | edit source]

The INT 2F\AX=1216h function accepts a number of SFT entry (A.01-4) and returns a pointer to that SFT entry, thus giving an opportunity of direct access to SFT.

Prepare : AX = 1216h BX – number of the requested SFT entry (note 2)

On return : AX value is not preserved. Set state of CF flag signifies mission's failure. Clear state of CF flag signifies successful termination, and then : ES:DI – pointer to requested SFT entry, BX – relative number of the same entry in a particular SFT.

Note 1: Most probable cause of error is a request for SFT entry number greater than maximum number of SFT entries, specified by FILES command (4.12) in CONFIG.SYS file.

Note 2: A pointer to number of SFT entry, related to a particular handle, is returned by INT 2F\AX=1220h function (8.03-11).

8.03-10 INT 2F\AX=121Eh – comparison of filenames[edit | edit source]

Prepare : AX = 121Eh DS:SI – pointer to the first filename, ending with 00h byte; ES:DI – pointer to the second filename, ending with 00h byte.

On return : ZF flag is set if filenames are equivalent, ZF flag is clear if filenames differ.

8.03-11 INT 2F\AX=1220h – get a pointer to JFT entry[edit | edit source]

The JFT table (note 3 to A.07-1) is filled with numbers of SFT entries (A.01-4), defining those objects, which are opened for access — channels or files. Access to these objects is performed via handles — numeric references, known to the caller program. A path from a handle to corresponding SFT entry starts with a call for INT 2F\AX=1220h function, returning a pointer to number of that corresponding SFT entry. This number is the main data item in specification of a call for INT 2F\AX=1216h function (8.03-09), which returns address of corresponding SFT entry.

Prepare : AX = 1220h BX – an active (opened) handle

On return : On error CF flag is set, AX = 06h (– invalid handle error). Clear state of CF flag signifies successful termination, and then : ES:DI – address of that byte in JFT, where the required number of SFT entry is stored.

Note 1: The FFh value of JFT byte, pointed at by address in ES:DI registers, signifies inactive (closed) state of specified handle.

8.03-12 INT 2F\AX=122Ch – enter device driver chain[edit | edit source]

The INT 2F\AX=122Ch function enables to trace the whole chain of device driver headers, because the first double word in each header is a pointer to the next header. The last header is marked with first word FFFFh.

Prepare : AX = 122Ch

On return : BX:AX – pointer to header of the second driver (the first is NUL device driver in DOS's "List-of-Lists", A.01-2).

8.03-13 INT 2F\AX=1500h – get number of CD/DVD drives[edit | edit source]

Prepare : AX = 1500h BX = 0000h

On return : AL = FFh – signature of successful termination (note 1); BX – number of CD/DVD drives; CX – drive number, assigned to the first CD/DVD drive (0002h = C:, 0003h = D:, and so on.)

Note 1: Returned initial value AL = 00h signifies that resident module of CD/DVD file system translator (5.08-03 or 5.08-04), which has to perform INT 2F\AX=1500h function, is not loaded.

Note 2: The INT 2F\AX=1500h function conflicts with GRAPHICS.COM driver's functions and, besides that, may return incorrect letter-name of the first CD/DVD drive when INTERLINK.EXE network driver is installed.

8.03-14 INT 2F\AX=1501h – get CD/DVD driver header address[edit | edit source]

Prepare : AX = 1501h ES:BX – pointer to a buffer (5 bytes per disc expected)

On return : ES:BX – pointer to buffer filled with 5-bytes blocks for each drive. In each block the first byte – disc's subunit number, related to a particular driver, the following double word – pointer to header of that driver. Whole length of data in buffer depends on number of CD/DVD drives, returned by INT 2F\AX=1500h function (8.03-13).

Note 1: The INT 2F\AX=1501h function, performed by resident module of CD/DVD file system translator (5.08-03 or 5.08-04), shouldn't be called for, unless INT 2F\AX=150Bh function (8.03-17) confirms in advance that required module is already loaded.

Note 2: Being called inside "DOS box" under WINDOWS OS, the INT 2F\AX=1501h function returns AX=0000h and invalid header's addresses.

8.03-15 INT 2F\AX=1505h – read CD/DVD's table of contents[edit | edit source]

Prepare : AX = 1505h CX – CD/DVD drive number (0002h = C:, 0003h = D:, and so on) DX – sector index (note 2) ES:BX – pointer to a prepared 2048-byte buffer.

On return : On error CF flag is set, AL – error code: AL = 15h – invalid drive number; = 21h – drive is not ready or there is no media in the drive. Clear state of CF flag signifies successful termination, and then : AL – volume descriptor type: = 01h – standard volume descriptor; = FFh – the last volume descriptor; = 00h – any other volume descriptor type. ES:BX – pointer to 2048-byte buffer with table of contents.

Note 1: The INT 2F\AX=1505h function, performed by resident module of CD/DVD file system translator (5.08-03 or 5.08-04), shouldn't be called for, unless INT 2F\AX=150Bh function (8.03-17) confirms in advance that required module is already loaded.

Note 2: A CD/DVD disc may have several volume descriptors: sector index 0000h corresponds to the first descriptor, sector index 0001h corresponds to the second descriptor, and so on.

8.03-16 INT 2F\AX=1508h–1509h – absolute CD/DVD read/write[edit | edit source]

Prepare : AX = 1508h – to read CD/DVD sectors = 1509h – to write CD/DVD sectors (note 3) CX – CD/DVD drive number (0002h = C:, 0003h = D:, and so on) DX – number of sectors to be read or written ES:BX – pointer to buffer (with data for write function) SI:DI – starting sector number

On return : On error CF flag is set, AL – error code: AL = 0Fh – invalid drive; = 15h – drive is busy or there is no media in the drive. Clear state of CF flag signifies successful termination, and then after reading operation ES:BX buffer is filled with read data.

Note 1: The INT 2F\AX=1508h–1509h functions, performed by resident module of CD/DVD file system translator (5.08-03 or 5.08-04), shouldn't be called for, unless INT 2F\AX=150Bh function (8.03-17) confirms in advance that required module is loaded yet.

Note 2: Being called inside "DOS box" under WINDOWS OS, the INT 2F\AX=1508h–1509h functions always return error code AL=15h.

Note 3: Early versions of CD/DVD file system translator programs (5.08-03 and 5.08-04) didn't support writing operation. Besides that, write function needs to be supported by CD/DVD drive's hardware.

8.03-17 INT 2F\AX=150Bh – request about a CD/DVD drive[edit | edit source]

Prepare : AX = 150Bh CX – CD/DVD drive number (0002h = C:, 0003h = D:, and so on)

On return : BX = ADADh, – a signature, confirming that CD/DVD file system translator's (5.08-03 or 5.08-04) module is loaded yet and is active. AX = 0000h – this zero value signifies that CD/DVD file system translator (5.08-03 or 5.08-04) doesn't provide control over the requested drive.

8.03-18 INT 2F\AX=150Dh – get drive numbers of CD/DVD drives[edit | edit source]

Prepare : AX = 150Dh ES:BX – pointer to buffer for drive numbers (1 byte per drive)

On return : ES:BX – pointer to buffer filled with drive numbers (02h = C:, 03h = D:, and so on). List of drive numbers ends with byte 00h.

Note 1: The INT 2F\AX=150Dh function, performed by resident module of CD/DVD file system translator (5.08-03 or 5.08-04), shouldn't be called for, unless INT 2F\AX=150Bh function (8.03-17) confirms in advance that required module is already loaded.

8.03-19 INT 2F\AX=150Fh – copy a CD/DVD directory entry[edit | edit source]

Prepare : AX = 150Fh CH = 00h – direct copy "as it is", without translation = 01h – copy and translate to canonical form (A.09-6) CL – CD/DVD drive number (02h = C:, 03h = D:, and so on) ES:BX – pointer to a pathname, ending with 00h byte SI:DI – pointer to buffer, minimum 255 bytes for direct copy

On return : On error CF flag is set, AX returns error code (A.06-1). Clear state of CF flag signifies successful termination, and then SI:DI – pointer to buffer filled with directory data AX = 0000h – if disc is of High Sierra format, = 0001h – if disc is of ISO 9660 format.

Note 1: The INT 2F\AX=150Fh function, performed by resident module of CD/DVD file system translator (5.08-03 or 5.08-04), shouldn't be called for, unless INT 2F\AX=150Bh function (8.03-17) confirms in advance that required module is already loaded.

8.03-20 INT 2F\AX=160Ah – Windows OS operating environment test[edit | edit source]

Prepare : AX = 160Ah

On return : AX = 0000h, if Windows OS responds to this test BH:BL – version of Windows OS CX – installation type (0002h = standard, 0003h = enhanced)

Note 1: Return of a non-zero value in AX register doesn't signify that the caller program is executed not under Windows OS or in its "DOS box". The reason is that among Windows's settings there is a flag named "Prevent DOS programs from detecting Windows". When this flag is set, Windows OS doesn't respond to INT 2F\AX=160Ah test.

8.03-21 INT 2F\AX=1687h – trial request to DPMI server[edit | edit source]

DPMI servers provide extended API functions to application programs, designed for execution in CPU's V86 mode. Via a request to DPMI server the INT 31 handler can be activated, which enables to install new protected mode interrupt handlers and to send requests for resources to protected mode operating system. DPMI servers for DOS (QDPMI.SYS, CWSDPMI.EXE, etc.) are not popular now, because Windows OS provides its own DPMI server, and it is always available. Being sent from Window's "DOS box", trial request to DPMI server always gets positive response, even when Windows OS doesn't reveal itself legally (note 1 to 8.03-20). Besides that, positive response to trial request is a sufficient evidence of CPU's V86 mode. Because of these reasons the INT 2F\AX=1687h function may be needed, despite that MS-DOS7 doesn't include DPMI server, and DPMI functions usage is not described in this book.

Prepare : AX = 1687h

On return : AX = 0000h – this zero value signifies that DPMI server is loaded yet; BX – set state of bit 0 signifies support for 32-bit programs; CL – CPU type (02h – 80286, 03h – 80386, 04h – 80486,…); DH:DL – DPMI server version; SI – size of DPMI server's data block (in 16-byte paragraphs); ES:DI – address of enter point for INT 31 handler activation.

Note 1: Difference between DOS's DPMI server's environment and Windows "DOS box" is that the latter gives no access to BIOS timer (8.01-73) and to VCPI functions (8.03-71 – 8.03-73).

Note 2: In "Caldera Open DOS" operating system a DPMI server is integrated into EMM386.EXE driver.

8.03-22 INT 2F\AX=4300h – XMS driver's activity test[edit | edit source]

Prepare : AX = 4300h

On return : AL = 80h – this value confirms that XMS driver HIMEM.SYS (5.04-01) is loaded and is active. Any other returned AL value signifies that XMS functions are unavailable.

8.03-23 INT 2F\AX=4310h – get XMS driver's entrance point[edit | edit source]

The INT 2F\AX=4310h function returns address of HIMEM.SYS (5.04-01) driver's entrance point. Various XMS functions, listed in table A.12-3, can be invoked by a CALL FAR command (7.03-08), addressed to this entrance point.

Prepare : AX = 4310h

On return : ES:BX – address of XMS driver's entrance point (5.04-01).

Note 1: The INT 2F\AX=4310h function, performed by resident module of HIMEM.SYS driver (5.04-01), shouldn't be called for, unless INT 2F\AX=4300h function (8.03-22) confirms in advance that required module is loaded yet.

Note 2: Calls for XMS functions, including INT 2F\AX=4310h and calls via CALL FAR command, require at least 256 bytes of free stack's space.

8.03-24 INT 2F\AX=4B52h – KEYRUS.COM driver's functions (5.02-05)[edit | edit source]

Prepare : AX = 4B52h (= 'KR') BL – subfunction: = 00h – installation check; = 4Ch – switch to US keyboard layout; = 90h – switch to national (russian) keyboard layout

On return : If KEYRUS.COM driver (5.02-05) is loaded, then AL = 82h – signature, confirming driver's active state; BH:BL – KEYRUS.COM driver's version number; ES value is not preserved.

8.03-25 INT 2F\AX=AD00h – DISPLAY.SYS driver's installation check[edit | edit source]

Prepare : AX = AD00h

On return : AL = FFh – signature, confirming installation of DISPLAY.SYS driver (5.02-02) and availability of its functions. BX register contents may be altered.

8.03-26 INT 2F\AX=AD01h–AD02h – set/get active codepage[edit | edit source]

The INT 2F\AX=AD01h–AD02h functions are performed by resident module of DISPLAY.SYS driver (5.02-02). Before sending a call for either of these functions you have to check with INT 2F\AX=AD00h function (8.03-25) whether the required resident module is installed.

Prepare : AX = AD01h – replace active codepage with another one = AD02h – get number of active codepage (A.02-2) BX – hexadecimal number of new codepage (for AX = AD01h only)

On return : On error CF flag is set, contents of AX and BX are not preserved. Clear state of CF flag signifies success, and then after AX=AD02h call only BX – hexadecimal number of current codepage.

8.03-27 INT 2F\AX=AD03h – get codepage information[edit | edit source]

The INT 2F\AX=AD03h function is performed by resident module of DISPLAY.SYS driver (5.02-02). Before sending a call for this function you have to check with INT 2F\AX=AD00h function (8.03-25) whether the required resident module is installed.

Prepare : AX = AD03h ES:DI – pointer to buffer for codepage information CX – size of buffer in bytes (A.02-6)

On return : On error CF flag is set. Probable cause: prepared buffer is too small. Clear state of CF flag signifies successful termination, and then ES:DI – pointer to buffer filled with data block (A.02-6).

8.03-28 INT 2F\AX=AD80h – KEYB.COM driver's installation check[edit | edit source]

Prepare : AX = AD80h

On return : AL = FFh – signature, confirming installation of KEYB.COM driver (5.02-04) and availability of its functions.; BH:BL – version number of KEYB.COM driver; ES:DI – pointer to KEYB.COM driver's data block; Contents of AH register may be altered.

8.03-29 INT 2F\AX=AD81h – set codepage for keyboard[edit | edit source]

The INT 2F\AX=AD81h function is performed by resident module of KEYB.COM driver (5.02-04). Before sending a call for this function you have to check with INT 2F\AX=AD80h function (8.03-28) whether the required resident module is installed.

Prepare : AX = AD81h BX – hexadecimal number of proposed codepage (A.02-2)

On return : On error CF flag is set, and then AX = 0001h value signifies that proposed codepage isn't available. Clear state of CF flag signifies successful termination.

8.03-30 INT 2F\AX=AD82h–AD83h – set/get keyboard's layout[edit | edit source]

The INT 2F\AX=AD82h–AD83h functions are performed by resident module of KEYB.COM driver (5.02-04). Before sending a call for either of these functions you have to check with INT 2F\AX=AD80h function (8.03-28) whether the required resident module is installed.

Prepare : AX = AD82h – set keyboard's layout = AD83h – get current keyboard's layout BL – subfunction (for AX = AD82h function only): = 00h – switch to american layout (just as can be switched by CTRL-ALT-F1 keystroke) = FFh – switch to national layout (just as can be switched by CTRL-ALT-F2 keystroke)

On return : On error CF flag is set. Probable cause: invalid BL value. Clear state of CF flag signifies success, and then after AX=AD83h call only BL = 00h – american layout; = FFh – national layout.

8.03-31 INT 33\AX=0000h – mouse driver status and reset[edit | edit source]

Reset operation brings mouse driver to its default state: movement and wheel counters are reset to zeros, mouse cursor is made invisible and is placed in the center of screen page 0 (function INT 33\AX=0001h should be called for in order to make cursor visible). Besides reset, the INT 33\AX=0000h function enables to find out whether mouse driver is installed and which mouse pointing device is available.

Prepare : AX = 0000h

On return : AX = 0000h value signifies that mouse driver isn't loaded (note 2). = FFFFh value signifies that mouse driver is loaded, and then CX = 0000h – number of mouse's buttons is other then two; = 0002h (and FFFFh too) – a 2-button mouse is used; = 0003h – Mouse Systems/Logitech 3-button mouse is used.

Note 1: If video mode has been changed, then flag of video mode change should be cleared before applying reset to mouse driver (note 2 to INT 33\AX=0028h, 8.03-52).

Note 2: MS-DOS7 fills free cells in interrupt table (up to INT 3F) with references to a IRET command (7.03-30). When mouse driver is not loaded, this IRET command just returns initial AX value intact. If reset operation is not desirable, then status of mouse driver should be reported by INT 33\AX=0021h function (8.03-49).

8.03-32 INT 33\AX=0001h–0002h – show/hide mouse cursor[edit | edit source]

Prepare : AX = 0001h – show mouse cursor = 0002h – hide mouse cursor

Note 1: If a program has called for INT 33\AX=0001h function to show mouse cursor, then this program before its termination must hide mouse cursor, thus restoring original state. Besides that, mouse cursor should be hidden each time before image on the screen is redrawn, but in the latter case it's better to hide cursor locally with INT 33\AX=0010h function (8.03-42).

Note 2: Multiple calls to hide mouse cursor will require multiple calls to unhide it. Exact number of pending bans on showing mouse cursor is reported by INT 33\AX=002Ah function (8.03-53).

8.03-33 INT 33\AX=0003h – button status, cursor and wheel positions[edit | edit source]

Prepare : AX = 0003h

On return : BH – 8-bit signed wheel movement since last call (note 1 to 8.03-33) BL – mouse's buttons status byte (note 2 to 8.03-33) CX – cursor's horizontal X-coordinate (note 1 to 8.03-53) DX – cursor's vertical Y-coordinate (note 1 to 8.03-53)

Note 1: Wheel movement is reported, if wheel is present in mouse device and is supported by mouse driver. Both these conditions should be checked by a call for INT 33\AX=0011h function (8.03-43). Positive movement values correspond to downward wheel movement. Wheel movement counter is reset by a call for INT 33\AX=0003h function, and also by requests to this counter, sent via INT 33\AX=0005h or by INT 33\AX=0006h functions (8.03-35).

Note 2: Buttons status byte reports states of those buttons, which are currently not released yet. Set states of bits 0 and 1 in buttons status byte correspond to pressed states of left and right mouse's buttons. Set state of bit 2 corresponds to pressed state of middle button, if it is present in mouse device and is supported by mouse driver.

Note 3: In textual videomodes coordinates are reported as multiples of character cell size.

8.03-34 INT 33\AX=0004h – set location of mouse cursor[edit | edit source]

Prepare : AX = 0004h CX – cursor's X-coordinate (0000h–0280h in videomode 3) DX – cursor's Y-coordinate (0000h–00C0h in videomode 3)

Note 1: Maximum coordinate values for any current videomode are reported by INT 33\AX=0026h function (8.03-51) and also by INT 33\AX=0031h function (8.03-54).

Note 2: In textual videomodes coordinate values are automatically rounded to the nearest lower multiple of character cell size.

8.03-35 INT 33\AX=0005h–0006h – button's and wheel's state events[edit | edit source]

Prepare : AX = 0005h – request about button press or wheel events = 0006h – request about button release or wheel events BX = 0000h – request about left button's events = 0001h – request about right button's events = 0002h – request about middle button's events = FFFFh – request about wheel movement events.

On return : AH – 8-bit signed wheel movement since last call (note 1 to 8.03-33) AL – buttons status byte (note 2 to 8.03-33) BX – after requests for button events: number of button's events (presses or releases) since last call for the same function; – after requests for wheel movement events: 16-bit signed wheel movement since last call (note 1 to 8.03-33) CX – mouse cursor's horizontal X-coordinate at the moment of last requested event (press or release or wheel rotation); DX – mouse cursor's vertical Y-coordinate at the moment of last requested event (press or release or wheel rotation).

Note 1: If no one requested event has happened to the requested button since last call for these functions, then zero values in BX, CX and DX registers are returned.

8.03-36 INT 33\AX=0007h–0008h – define mouse cursor's range[edit | edit source]

Prepare : AX = 0007h – define cursor's horizontal range = 0008h – define cursor's vertical range CX – lower limit of coordinate value (note 2 to 8.03-34) DX – upper limit of coordinate value (note 2 to 8.03-34)

Note 1: If mouse cursor is beyond desired range, then INT 33\AX=0007h–0008h functions shift cursor's position to the nearest border within permissible range.

8.03-37 INT 33\AX=0009h – mouse cursor in graphic videomodes[edit | edit source]

Prepare : AX = 0009h BX – horizontal shift of cursor's hot spot (from –16 to +16) CX – vertical shift of cursor's hot spot (from –16 to +16) ES:DX – pointer to a block of bitmap masks (note 1).

Note 1: Block of bitmap masks includes screen mask and cursor mask, each 16 words long. Screen mask starts at offset 00h, cursor mask starts at offset 20h. Each word in a mask defines sixteen pixels along a screen line. Least significant bit in each word corresponds to the rightmost pixel. Screen mask is superimposed over video memory contents with logical AND operation, and then cursor mask is superimposed over the result with logical XOR operation.

Note 2: Current cursor's hot spot position is returned by INT 33\AX=002Ah function (8.03-53).

8.03-38 INT 33\AX=000Ah – mouse cursor in textual videomodes[edit | edit source]

Prepare : AX = 000Ah BX = 0000h – software defined cursor (note 1) = 0001h – hardware defined cursor (note 2) CX – screen mask (if BX=0000h), or start scan line (if BX=0001h) DX – cursor mask (if BX=0000h), or last scan line (if BX=0001h)

Note 1: If software definition is selected, the character/color contents of video memory at cursor's position are subjected to logical AND bit-to-bit operation with screen mask and then the result is subjected to logical XOR bit-to-bit operation with cursor mask. Mask's bytes from CH and DH registers are superimposed over color byte (A.10-5) in video memory. For example, if CX=0000h, then cursor acquires form of character, defined by its ASCII code in DL; its color is defined by bytes 0–3 in DH according to table A.10-5. Bytes 4–6 in DH define background color, the 7th byte controls blinking. Nonzero values in bits 4–6 of CH register make colors dependent on original video memory contents so that cursor becomes more noticeable against any background image.

Note 2: If hardware definition is chosen, then cursor is a blinking bar or a blinking rectangle. For example, values CX=0002h DX=0003h define mouse cursor as a bar above character's row; values CX=0003h DX=0004h define mouse cursor as an underscore.

8.03-39 INT 33\AX=000Bh – read mouse motion counters[edit | edit source]

Prepare : AX = 000Bh

On return : CX – horizontal shift since last call for INT 33\AX=000Bh DX – vertical shift since last call for INT 33\AX=000Bh

Note 1: Mouse cursor's shifts are counted in steps ("mickeys"), which are the smallest position increments the mouse can sense. Microsoft's drivers assign positive shift values to downward motion and to rightward motion. Correspondence between pixels and mouse steps ("mickeys") can be set by INT 33\AX=000Fh function (8.03-41).

Note 2: The INT 33\AX=0027h function also accepts AX value only, and returns the same shifts in CX and DX, but, besides that, according to software or hardware cursor definitions (8.03-38) returns: in register AX – screen mask or cursor's start scan line, in register BX – cursor mask or cursor's last scan line.

8.03-40 INT 33\AX=000Ch – mouse driver's call for resident subroutine[edit | edit source]

Prepare : AX = 000Ch CX – mask for subroutine call conditions: bit 0 set: – call if mouse moves bit 1 set: – call if left button is pressed bit 2 set: – call if left button is released bit 3 set: – call if right button is pressed bit 4 set: – call if right button is released bit 5 set: – call if middle button is pressed bit 6 set: – call if middle button is released bit 7 set: – call if wheel is rotated (note 1 to 8.03-33) ES:DX – pointer to subroutine entrance for CALL FAR command. (7.03-08)

Note 1: In CX register several conditions can be specified, and then subroutine will be called by mouse driver when either of specified conditions is met. States of bits 15–8 in CX register are ignored. States of bits 7–5 in CX register are taken into account by those drivers only, which support corresponding mouse's capabilities.

Note 2: Resident subroutine is called with following register states :

AX – call conditions (the same bit assignments as in CX mask)
BH – signed wheel movement since last call (note 1 to 8.03-33)
BL – buttons status byte (note 2 to 8.03-33)
CX – cursor's horizontal coordinate (note 2 to 8.03-34)
DX – cursor's vertical coordinate (note 2 to 8.03-34)
SI – horizontal cursor's shift (note 1 to 8.03-39)
DI – vertical cursor's shift (note 1 to 8.03-39).

Note 3: The INT 33\AX=0014h function enables to replace both call mask and address of subroutine's entrance point with new ones, specified similarly in CX and ES:DX registers ; on return CX and ES:DX registers contain corresponding replaced former values.

Note 4: If a program has specified mouse call for resident subroutine, then this mouse call must be disabled before program terminates. For this purpose INT 33\AX=000Ch function should be called once more with 0000h mask in CX register.

Note 5: Microsoft's mouse drivers are able to call up to four different resident subroutines. The first subroutine must be specified by INT 33\AX=000Ch function, and the rest three subroutines may be specified by INT 33\AX=0018h function (8.03-45).

8.03-41 INT 33\AX=000Fh – sensitivity of mouse shift registration[edit | edit source]

Prepare : AX = 000Fh CX – number of horizontal steps per 8 pixels (default is 8) DX – number of vertical steps per 8 pixels (default is 16).

8.03-42 INT 33\AX=0010h – local ban on cursor's display[edit | edit source]

While mouse's cursor moves on the screen, mouse's driver restores former screen image in each place where mouse's cursor has been moved from. Restoration of former image contents by mouse driver may interfere with screen image updating procedures, performed by foreground program. Such interference can be avoided, if mouse cursor is hidden in the updated part of screen image. Unlike mouse cursor's hiding in the whole screen by INT 33\AX=0002h function (8.03-32), local ban on cursor's display enables to make cursor's blinking almost unnoticeable. When local image updating procedure expires, mouse cursor should be made visible by a call for INT 33\AX=0001h function (8.03-32).

Prepare : AX = 0010h CX – horizontal X-coordinate of ban area upper left corner DX – vertical Y-coordinate of ban area upper left corner SI – horizontal X-coordinate of ban area lower right corner DI – vertical Y-coordinate of ban area lower right corner.

8.03-43 INT 33\AX=0011h – pointing device wheel support check[edit | edit source]

Prepare : AX = 0011h

On return : AX = 574Dh – signature confirming driver's support for wheel (note 1) CX – bit 0 set signifies that mouse pointing device has a wheel. BX contents may be altered.

Note 1: GMOUSE.COM driver (5.03-01) versions 9.06+ respond to calls for INT 33\AX=0011h function with AX = FFFFh signature. It means that driver doesn't support pointing device wheel, but returns number of mouse's active buttons in BX register.

8.03-44 INT 33\AX=0016h–0017h – save/restore mouse driver's state[edit | edit source]

Prepare : AX = 0016h – write driver's state record into prepared buffer = 0017h – restore mouse driver's state from data in buffer BX – size of buffer (note 2) ES:DX – pointer to a buffer (for AX=0017h it must be filled)

On return : ES:DX – pointer to a buffer with mouse driver state record.

Note 1: Restoration of mouse driver's state must be performed in just that videomode, which was active when driver's state record has been written into buffer.

Note 2: Size of buffer needed to store driver's state record should be determined beforehand with INT 33\AX=0015h function: required size (in bytes) will be returned in BX register.

8.03-45 INT 33\AX=0018h – mouse driver's call for resident subroutines[edit | edit source]

Microsoft's mouse drivers are able to call up to four different resident subroutines. The first subroutine must be specified by INT 33\AX=000Ch function (8.03-40), and the rest three subroutines may be specified by INT 33\AX=0018h function.

Prepare : AX = 0018h CX – mask for subroutine call conditions:

bit 0 set: – call if mouse moves
bit 1 set: – call if left button is pressed
bit 2 set: – call if left button is released
bit 3 set: – call if right button is pressed
bit 4 set: – call if right button is released
bit 5 set: – call during pressed state of SHIFT key (note 1)
bit 6 set: – call during pressed state of CTRL key (note 1)
bit 7 set: – call during pressed state of ALT key (note 1)

ES:DX – pointer to subroutine entrance for CALL FAR command. (7.03-08)

On return : AX = 0018h – signature of successful termination; AX = FFFFh – signature of a failure.

Note 1: Subroutines, registered by INT 33\AX=0018h function, are called if either of "functional" keys (SHIFT, CTRL, ALT) is pressed, therefore at least one of bits 7–5 in CX mask must be set. States of bits 15–8 in CX register are ignored. States of bits 4–0 in CX mask are taken into account according to logical OR function: subroutine will be called when either of these conditions is met, if at the same time the specified "functional" key is kept pressed.

Note 2: When mouse driver calls for subroutine, it leaves in registers those values listed in note 2 to article 8.03-40.

Note 3: In order to cease calls for a certain subroutine, the INT 33\AX=0018h function should be called once more with the same mask word in CX register, but with 0000:0000h entrance point address in ES:DX registers.

Note 4: The INT 33\AX=0018h function is supported by Microsoft's mouse drivers since version 6.0, but isn't necessarily supported by mouse drivers from other vendors.

8.03-46 INT 33\AX=0019h – subroutine entrance point address[edit | edit source]

In response to a call for INT 33\AX=0019h function Microsoft's mouse drivers return entrance point address of that TSR subroutine, which has been registered yet by INT 33\AX=0018h function (8.03-45) with specified mask for call conditions in CX register. Returned data may be used later by any foreground program in order to restore activity of a particular subroutine.

Prepare : AX = 0019h CX – mask for call conditions (8.03-45)

On return : CX = 0000h – error: TSR with submitted mask hasn't been found. Any other outcome signifies success, and then BX:DX – entrance point address for the found TSR subroutine; CX – actual mask for subroutine's call conditions (8.03-45).

8.03-47 INT 33\AX=001Dh–001Eh – screen page number for mouse cursor[edit | edit source]

Prepare : AX = 001Dh – define screen page number for mouse cursor = 001Eh – report current cursor's screen page number BX – screen page number to be accessed (for INT 33\AX=001Dh only)

On return : BX – current screen page number (after INT 33\AX=001Eh only)

8.03-48 INT 33\AX=001Fh–0020h – disable/re-enable mouse driver[edit | edit source]

Prepare : AX = 001Fh – disable mouse driver = 0020h – re-enable mouse driver

On return : AX = FFFFh – signature of a failure. On success the AX value is returned unchanged.

Note 1: The INT 33\AX=001Fh function restores addresses in interrupt table of INT 10 and INT 74 handlers, which have been there before mouse driver was loaded.

Note 2: If interrupt handler's addresses, set by mouse driver, were removed from interrupt table by INT 33\AX=001Fh function, then INT 33\AX=0020h function is able to write these addresses back into interrupt table.

Note 3: After successful termination the INT 33\AX=001Fh function returns in ES:BX registers that address of INT 33 handler, which has been in interrupt table before mouse driver was installed. If foreground program writes this address back into interrupt table, then possibility to call mouse driver via interrupts will be completely eliminated.

8.03-49 INT 33\AX=0021h – mouse driver installation test[edit | edit source]

Prepare : AX = 0021h

On return : When mouse driver is not installed, then most probably AX = 0021h. AX= FFFFh value confirms that the mouse driver is installed, and then BX – number of mouse's buttons (note 2).

Note 1: MS-DOS7 fills free cells in interrupt table (up to INT 3F) with references to a IRET command (7.03-30). When mouse driver is not loaded, this IRET command just returns initial AX value intact. Status of mouse driver is similarly reported by INT 33\AX=0000h function (8.03-31), which also returns driver to initial state. The INT 33\AX=0021h function doesn't return mouse driver to initial state, but nevertheless resets wheel movement counter.

Note 2: Having identified a 2-button mouse, some mouse drivers return BX = FFFFh.

8.03-50 INT 33\AX=0024h – mouse type and IRQ setting[edit | edit source]

Prepare : AX = 0024h

On return : AX = FFFFh – signature of mouse device identification failure. Any other value in AX signifies success, and then BH.BL – mouse driver version CH – mouse pointing device type and connection: = 00h – mouse pointing device isn't connected; = 01h – mouse is connected via expansion card; = 02h – mouse is connected to serial port; = 04h – mouse is connected to PS/2 port; = 05h – special Hewlett-Packard's mouse. CL – hexadecimal IRQ number (except CL=00h for PS/2 port).

8.03-51 INT 33\AX=0026h – cursor's maximum coordinate values[edit | edit source]

Prepare : AX = 0026h

On return : Non-zero value in BX register signifies an error. BX = 0000h – signature of successful termination, and then CX – maximum horizontal X-coordinate for current videomode DX – maximum vertical Y-coordinate for current videomode.

Note 1: The INT 33\AX=0026h function reports cursor coordinate values for the whole screen. If cursor's area is confined within certain ranges (8.03-36), then allowable minimum and maximum coordinate values should be determined with INT 33\AX=0031 function (8.03-54).

Note 2: The INT 33\AX=0026h function shouldn't be called for, unless mouse driver's support for this function is confirmed by INT 33\AX=0032h (8.03-55).

8.03-52 INT 33\AX=0028h – consistent change of videomode[edit | edit source]

As far as mouse cursor is drawn by means of direct access to video memory, mouse driver's interventions must conform to current format of data in video memory. However, different videomodes define different data formats. Hence each change of videomode must be coordinated with change of video data format, used by mouse driver. The INT 33\AX=0028h function provides an opportunity of consistent videomode change for both video memory and mouse driver, so that appearance and movement of mouse cursor wouldn't be disturbed.

Prepare : AX = 0028h CX – code of proposed video mode (A.10-1) DH – vertical size of character cell (note 1) DL – horizontal size of character cell (note 1)

On return : Non-zero value in CL register signifies a failure. CL = 00h – signature of successful termination.

Note 1: Zero values DH = DL = 00h specify default character cell size for any videomode. If proposed videomode doesn't support character cell size control, then any values in DH and DL registers are ignored.

Note 2: If CX = 0000h on call, then videomode is not set, but an internal videomode change flag is cleared. This flag must be cleared before each call for mouse driver's reset function (8.03-31).

Note 3: The INT 33\AX=0028h function shouldn't be called for, unless mouse driver's support for this function is confirmed by INT 33\AX=0032h (8.03-55).

Note 4: A list of videomode codes, supported by mouse driver, can be returned by several sequential calls for INT 33\AX=0029h function. The first call accepts CX = 0000h and returns in CX a code of first supported videomode. The next call, performed with this code in CX intact, returns in CX code of next supported videomode, and so on. Some mouse drivers return in DS:DX a pointer to a string with description of videomode; some other mouse drivers may leave zero value in DS:DX. End of calls cycle is marked by return of zero value CX = 0000h.

8.03-53 INT 33\AX=002Ah – mouse cursor's parameters[edit | edit source]

Prepare : AX = 002Ah

On return : AX – number of pending bans on showing mouse cursor (8.03-32) BX – horizontal X-shift of cursor's hot spot (note 1) CX – vertical Y-shift of cursor's hot spot (note 1) DX – mouse type, as CH returned by INT 33\AX=0024h (8.03-50).

Note 1: Cursor's coordinates are counted relative to upper left corner of cursor's block, but cursor points at its hot spot. Shift of hot spot from the upper left corner of cursor's block may range from –128 to +127 for both coordinates.

Note 2: The INT 33\AX=002Ah function shouldn't be called for, unless mouse driver's support for this function is confirmed by INT 33\AX=0032h (8.03-55).

8.03-54 INT 33\AX=0031h – get current coordinate range[edit | edit source]

The INT 33\AX=0031h function reports current values of range limits, when available mouse cursor's area is confined within a virtual window set by INT 33\AX=0007h–0008h (8.03-36).

Prepare : AX = 0031h

On return : AX – minimum value of horizontal X-coordinate BX – minimum value of vertical Y-coordinate CX – maximum value of horizontal X-coordinate DX – maximum value of vertical Y-coordinate

Note 1: When available cursor's area is not confined within a window, then coordinate ranges should be reported by INT 33\AX=0026h function (8.03-51).

Note 2: The INT 33\AX=0031h function shouldn't be called for, unless mouse driver's support for this function is confirmed by INT 33\AX=0032h (8.03-55).

8.03-55 INT 33\AX=0032h – supported functions of mouse driver[edit | edit source]

Prepare : AX = 0032h

On return : AX – a word of flags, where each bit signifies support for mouse driver's functions from INT 33\AX=0034h to INT 33\AX=0025h :

bit 3 set: – INT 33\AX=0031h is supported ;
bit 10 set: – INT 33\AX=002Ah is supported ;
bit 11 set: – INT 33\AX=0029h is supported ;
bit 12 set: – INT 33\AX=0028h is supported ;
bit 14 set: – INT 33\AX=0026h is supported.

Contents of BX, CX, DX registers are not preserved.

8.03-56 INT 4A – alarm handler hook[edit | edit source]

Default INT 4A handler just returns control back to the caller program. Role of the caller program belongs to BIOS's real-time clock alarm, if it is set to a certain time by INT 1A\AH=06h function (8.01-94). Application programs are suggested to load an intercepting INT 4A handler, which will be called at a predetermined time in order to perform a desired action.

Note 1: The INT 4A interrupt is called from within a hardware interrupt handler. Therefore all necessary precautions against reentering DOS must be taken (8.02-70, 8.02-87).

8.03-57 INT 67\AH=41h – get page frame segment[edit | edit source]

By default the EMM386.EXE driver (5.04-02) arranges in upper memory (below 1024 kb) 4 "physical" pages, grouped into one 64-kb frame. Access to extended memory is implemented by dynamic mapping of extended memory "logical" pages (beyond 1088 kb) onto these 16-kb "physical" pages inside a page frame. Most often page frame starts at segment address E000h.

Prepare : AH = 41h

On return : AH – error code (A.06-1); if AH = 00h, then BX – segment address of page frame (4 "physical" pages).

Note 1: The INT 67\AH=41h function shouldn't be called for, unless EMM386.EXE (5.04-02) driver's active state is confirmed by INT 67\AH=46h (note 1 to 8.03-62).

8.03-58 INT 67\AH=42h – get number of EMS pages[edit | edit source]

According to EMS specification the EMM386.EXE driver provides access to selected "logical" 16-kb pages arranged in extended memory from 1088 to 32768 kb, except area reserved by /L parameter (5.04-02) for access arranged by XMS-driver (5.04-01). The INT 67\AH=42h function reports statistics of "logical" EMS pages in extended memory, available for EMM386.EXE driver.

Prepare : AH = 42h

On return : AH – error code (A.06-1); if AH = 00h, then BX – number of unallocated (free) "logical" EMS-pages DX – total number of "logical" EMS-pages.

Note 1: The INT 67\AH=42h function shouldn't be called for, unless EMM386.EXE (5.04-02) driver's active state is confirmed by INT 67\AH=46h (note 1 to 8.03-62).

8.03-59 INT 67\AH=43h – allot a handle and extended memory[edit | edit source]

Unlike INT 21\AH=3Dh function (8.02-33), the EMM386.EXE driver (5.04-02) allots only those handles, which refer to areas of extended memory beyond 1088 kb boundary. Each area may comprise an integer number of "logical" 16-kb pages. Specification of any particular "logical" page includes its number in allocated area and the handle, assigned to that allocated area.

Prepare : AH = 43h BX – requested non-zero number of "logical" pages, 16 kb each. On return : AH – error code (A.06-1); if AH = 00h, then DX – handle for area, comprising requested number of pages.

Note 1: The INT 67\AH=43h function shouldn't be called for, unless EMM386.EXE (5.04-02) driver's active state is confirmed by INT 67\AH=46h (note 1 to 8.03-62).

Note 2: By default the EMM386.EXE driver may keep active up to 64 handles simultaneously, but the "h" parameter (5.04-02) enables to increase number of active handles to 255.

Note 3: Version 4.0 of LIM EMS specification stipulates INT 67\AX=5A00h function with the same mission. The only difference is permission to request zero number of "logical" pages in BX register.

8.03-60 INT 67\AH=44h – map "logical" page to a "physical" page[edit | edit source]

Here the term "mapping" implies that appeals addressed to a particular "physical" 16-kb page below 1024 kb will be automatically diverted by CPU to specified "logical" 16-kb page, physically present in extended memory beyond 1088 kb boundary.

Prepare : AH = 44h AL – number of a selected "physical" 16-kb page; BX – number of a requested "logical" 16-kb page, or else = FFFFh – in order to make specified "physical" page free; DX – handle of memory area, comprising requested "logical" page.

On return : AH – error code (A.06-1); AH = 00h signifies successful termination.

Note 1: The INT 67\AH=44h function shouldn't be called for, unless EMM386.EXE (5.04-02) driver's active state is confirmed by INT 67\AH=46h (note 1 to 8.03-62).

Note 2: Count of memory pages, both "physical" and "logical", starts from zero number.

Note 3: "physical" pages 00h–03h constitute page frame. Address of page frame is reported by INT 67\AH=41h function (8.03-57). Location of "physical" pages 04h–1Bh, if these exist, can be reported by INT 67\AX=5800h function (8.03-70). If a "physical" page is located in conventional memory (below 640 kb), then memory space, occupied by this memory page, must be allotted by operating system to that program, which intends to use this "physical" page.

8.03-61 INT 67\AH=45h – release a handle and memory area[edit | edit source]

When a part of extended memory, associated with a handle, is no more needed, then handle owner program must inform EMM386.EXE driver (5.04-02) about that. After a call for INT 67\AH=45h function this part of extended memory will be considered free, and associated handle will become disabled.

Prepare : AH = 45h DX – handle of that memory area, which is to be released

On return : AH – error code (A.06-1); AH = 00h signifies successful termination.

Note 1: The INT 67\AH=45h function should be used to disable those handles only, which have been assigned by EMM386.EXE driver (5.04-02) after calls for INT 67\AX=5A00h or for INT 67\AH=43h functions (8.03-59). Other handles should be disabled by INT 21\AH=68h, INT 21\AH=6Ah or INT 21\AH=3Eh functions (8.02-34).

Note 2: Repeated request for a handle can't restore access to those pages of extended memory, which were associated with a disabled handle.

8.03-62 INT 67\AH=46h – get version of EMM386.EXE driver[edit | edit source]

Prepare : AH = 46h

On return : AH – error code (A.06-1); if AH = 00h, then AL – version number of EMM386.EXE driver (5.04-02).

Note 1: Address of INT 67 handler, stored in cell 0000:019Eh of interrupt table, points at start of handler's header. At offset 0Ah relative to start of handler's header a signature EMMXXXX0 is written by EMM386.EXE driver. If this signature can't be found, then neither function of INT 67 handler can be called, because INT 67 cell in interrupt table is not filled by default and may contain an invalid pointer (for example, 0000:0000h). Presence of EMMXXXX0 signature in its proper place confirms that EMM386.EXE driver is loaded yet, and then INT 67\AH=46h function should be called for. The AH = 00h value, returned by INT 67\AH=46h function, signifies active state of EMM386.EXE driver and its readiness to perform other INT 67 functions.

Note 2: When it is known for certain that EMM386.EXE driver is loaded, then any non-zero error code, returned by INT 67\AH=46h function, signifies inactive state of EMM386.EXE driver. In this case the INT 67\AX=FFA5h function (8.03-74) may help: it returns address of EMM386.EXE driver's API entrance point. With a CALL FAR command (7.03-08), addressed to this entrance point, the EMM386.EXE driver may be turned into active state.

8.03-63 INT 67\AH=4Bh – get number of EMM handles[edit | edit source]

Prepare : AH = 4Bh

On return : AH – error code (A.06-1); if AH = 00h, then BX – number of active handles, assigned by EMM386.EXE driver.

Note 1: The INT 67\AH=4Bh function shouldn't be called for, unless EMM386.EXE (5.04-02) driver's active state is confirmed by INT 67\AH=46h (note 1 to 8.03-62).

Note 2: By default the EMM386.EXE driver may keep active up to 64 handles simultaneously, but the "h" parameter (5.04-02) enables to increase number of active handles to 255.

8.03-64 INT 67\AH=4Ch – get pages associated with a handle[edit | edit source]

Prepare : AH = 4Ch DX – an active handle, assigned to some extended memory area

On return : AH – error code (A.06-1); if AH = 00h, then BX – number of "logical" pages, associated with specified handle.

Note 1: The INT 67\AH=4Ch function accepts those active handles only, which have been allotted by INT 67\AH=43h function (8.03-59) of EMM386.EXE driver (5.04-02). The INT 67\AH=4Ch function shouldn't be called for, unless EMM386.EXE driver's active state is confirmed by INT 67\AH=46h (note 1 to 8.03-62).

8.03-65 INT 67\AH=4Eh – save/restore extended memory mapping[edit | edit source]

If a resident module intends to use EMS access to extended memory, then it should be taken into account that any foreground program, interrupted by invoked resident module, also could use EMS access to extended memory. Execution of this foreground program can't be resumed, unless interrupting resident module, having finished its mission, restores original mapping of extended memory. For this purpose INT 67\AH=4Eh presents 4 subfunctions, enabling to save current extended memory mapping and later to restore it.

Prepare : AH = 4Eh AL – subfunction: = 00h – save current mapping into a data block; = 01h – restore mapping from data block; = 02h – consecutive execution of subfunctions 00h and 01h; = 03h – determine required buffer size for data block. ES:DI – pointer to empty buffer (for subfunctions 00h and 02h) DS:SI – pointer to data block (for subfunctions 01h and 02h)

On return : AH – error code (A.06-1); if AH = 00h, then AL – required buffer size in bytes (after subfunction 03h only).

Note 1: The INT 67\AH=4Eh function is executed by EMM386.EXE driver's versions 4.00 and higher (5.04-02). Therefore INT 67\AH=4Eh function shouldn't be called for, unless EMM386.EXE driver's proper version and active state are confirmed by INT 67\AH=46h (note 1 to 8.03-62).

Note 2: Starting from EMM386.EXE driver's version 3.00, saving and restoration of extended memory mapping state may be performed by functions INT 67\AH=47h and INT 67\AH=48h correspondingly. These functions restore state of 64-kb page frame only, don't need explicit data block(s), but require in DX register a handle, allotted by EMM386.EXE driver to the caller module.

8.03-66 INT 67\AX=5000h – change handle's mapping list[edit | edit source]

Mapping list is a table of correspondence between "physical" and "logical" memory pages, associated with one handle. The INT 67\AX=5000h function enables to replace current mapping list with a new one. Single call for INT 67\AX=5000h function is equivalent to several consecutive calls for INT 67\AH=44h mapping function (8.03-60).

Prepare : AX = 5000h CX – number of entries in mapping list, 4 bytes per entry (note 3) DX – an active handle, assigned to some extended memory area DS:SI – pointer to start of proposed (new) mapping list On return : AH – error code (A.06-1); AH = 00h signifies successful termination.

Note 1: Function INT 67\AX=5000h operates with those handles only, which are allotted by EMM386.EXE driver's functions INT 67\AH=43h or INT 67\AX=5A00h (8.03-59). The INT 67\AX=5000h function shouldn't be called for, unless EMM386.EXE (5.04-02) driver's active state is confirmed by INT 67\AH=46h (note 1 to 8.03-62).

Note 2: If a "physical" page is located in conventional memory (below 640 kb), then memory space, occupied by this memory page, must be allocated by operating system to that program, which intends to use this "physical" page.

Note 3: Each entry in mapping list is 4 bytes long and consists of two words. The second word in each entry is a "physical" page number (most often 0000h–0003h). For mapping operation the first word in an entry must be "logical" page number. For opposite unmapping operation the first word in an entry must be FFFFh value : it forces to cancel current association of corresponding "physical" page.

Note 4: The INT 67\AX=5001h function is charged with the same mission and accepts the same specifications (except AX), but operates with other data in mapping list : the second word in each entry must be segment address of corresponding "physical" page.

8.03-67 INT 67\AH=51h – reallocate "logical" pages[edit | edit source]

Prepare : AH = 51h BX – requested number of "logical" pages for the handle DX – an active handle, assigned to some extended memory area

On return : AH – error code (A.06-1); if AH = 00h, then BX – actual number of pages associated with specified handle.

Note 1: The INT 67\AX=51h function operates with those handles only, which are allotted by EMM386.EXE driver's functions INT 67\AH=43h or INT 67\AX=5A00h (8.03-59). The INT 67\AX=51h function shouldn't be called for, unless EMM386.EXE (5.04-02) driver's active state is confirmed by INT 67\AH=46h (note 1 to 8.03-62).

Note 2: If INT 67\AH=51h function is called in order to increase number of associated "logical" pages, then ordinal numbers of new pages will follow ordinal numbers of currently available "logical" pages. If INT 67\AH=51h function is called in order to decrease number of associated "logical" pages, then pages with largest ordinal numbers will be lost first.

8.03-68 INT 67\AH=55h–56h – jump and subroutine call in EMS-memory[edit | edit source]

When a code is executed in extended memory, then target "logical" page for control transfer operations JMP FAR and CALL FAR should be made accessible in advance. For this purpose the EMM386.EXE driver provides two functions, combining control transfer with replacement of mapping list for specified handle. The INT 67\AH=55h function replaces mapping list and performs JMP FAR operation (7.03-39), the INT 67\AH=56h function replaces mapping list and performs CALL FAR operation (7.03-08). Both these functions accept most part of required parameters from a prepared data block. Structure of this data block is shown in table A.12-6.

Prepare : AX = 5500h – for JMP FAR operation = 5600h – for CALL FAR operation DX – an active handle, assigned to some extended memory area DS:SI – pointer to start of data block (A.12-6).

On return : AH – error code (A.06-1); AH = 00h signifies successful termination.

Note 1: The INT 67\AH=55h–56h functions should be used by those programs only, which are designed for execution in extended memory.

Note 2: The INT 67\AX=5501h and INT 67\AX=5601h functions are charged with the same missions and accept the same specifications (except AX), but operate with other data in mapping lists: the second word in each entry must be segment address of corresponding "physical" page.

Note 3: The INT 67\AX=5602h function doesn't need other initial data, except AX value, and returns in BX register number of bytes for return addresses, which are saved in stack by INT 67\AX=5600-5601h functions.

8.03-69 INT 67\AX=5700h–5701h – data copying or exchange[edit | edit source]

The INT 67\AX=5700h–5701h functions enable to copy data or exchange data between memory areas, either accessed via different handles or belonging to conventional memory. Addressing parameters are specified in a descriptor, shown in table A.12-5.

Prepare : AX = 5700h – to copy data from one memory area to another = 5701h – to exchange data between memory areas DS:SI – pointer to parameters descriptor (A.12-5)

On return : AH – error code (A.06-1); AH = 00h signifies successful termination.

Note 1: Functions INT 67\AX=5700h–5701h operate with those handles only, which are allotted by EMM386.EXE driver's functions INT 67\AH=43h or INT 67\AX=5A00h (8.03-59). The INT 67\AX=5700h–5701h functions shouldn't be called for, unless EMM386.EXE (5.04-02) driver's active state is confirmed by a call for INT 67\AH=46h (note 1 to 8.03-62).

8.03-70 INT 67\AX=5800h – segment addresses of physical pages[edit | edit source]

Prepare : AX = 5800h ES:DI – pointer to a buffer to be filled

On return : AH – error code (A.06-1); if AH = 00h, then CX – number of entries in the buffer (4 bytes each entry); ES:DI – pointer to buffer filled with entries (note 2)

Note 1: The INT 67\AH=5800h function shouldn't be called for, unless EMM386.EXE (5.04-02) driver's active state is confirmed by a call for INT 67\AH=46h (note 1 to 8.03-62).

Note 2: Each entry in the buffer is 4 byte long and consists of 2 words: the first is physical page segment, the second is corresponding physical page number.

Note 3: Number of physical pages (and, hence, length of the buffer) may be obtained in advance with INT 67\AX=5801h function, which similarly returns number of entries in CX register, but doesn't fill the buffer and ignores contents of ES:DI registers.

8.03-71 INT 67\AX=DE06h – physical address of a 4-kb page[edit | edit source]

The INT 67\AX=DE06h function is performed by VCPI servers. It helps to perceive the concept of USB address space transformation, performed by CPU switched into V86 mode. As far as in MS-DOS7 the EMM386.EXE driver (5.04-02) is charged with mission of VCPI server, the INT 67\AH=DE06h function shouldn't be called for, when EMM386.EXE driver's active state is not confirmed yet by a call for INT 67\AH=46h (note 1 to 8.03-62) and also when VCPI functions are disabled by /noVCPI parameter (note 2 to 5.04-02).

Prepare : AX = DE06h CX – number of 4-kb a page below 1024 kb boundary (note 1)

On return : AH – error code (A.06-1); AH = 8Bh signifies invalid page number. AH = 00h value signifies success, and then EDX – physical address of the requested page (note 2).

Note 1: Unlike LIM EMS functions, VCPI functions operate with 4-kb pages, processed by TLB address translation mechanism in 32-bit CPUs. Number of a 4-kb page is obtained by shifting its linear address 12 bit rightward. For example, memory cell D400:1ABCh has linear address D5ABCh, so its page number is CX = 00D5h.

Note 2: For DOS programs a way of access to EDX and to other 32-bit registers is shown in article 7.02-06.

8.03-72 INT 67\AX=DE07h – read state of control register CR0[edit | edit source]

Unlike operation of reading CR0 register's state by MOV command (note 1 to 7.03-58), which requires CPU's real mode or the highest privilege level, the INT 67\AX=DE07h function of VCPI servers is available in CPU's V86 mode at the third (the lowest) privilege level. As far as in MS-DOS7 the EMM386.EXE driver (5.04-02) is charged with mission of VCPI server, the INT 67\AH=DE07h function shouldn't be called for, when EMM386.EXE driver's active state is not confirmed yet by a call for INT 67\AH=46h (note 1 to 8.03-62) and also when VCPI functions are disabled by /noVCPI parameter (note 2 to 5.04-02).

Prepare : AX = DE07h

On return : AH – error code (A.06-1); if AH = 00h, then EBX – current state of control register CR0 (note 1).

Note 1: For DOS programs a way of access to EBX and to other 32-bit registers is shown in article 7.02-06.

8.03-73 INT 67\AX=DE08h–DE09h – access to registers DR0–DR7[edit | edit source]

Unlike access to CPU's registers DR0–DR7 with MOV commands (note 1 to 7.03-58), which require CPU's real mode or the highest privilege level, the INT 67\AX=DE08h–DE09h functions of VCPI servers are available in CPU's V86 mode at the third (the lowest) privilege level. As far as in MS-DOS7 the EMM386.EXE driver (5.04-02) is charged with mission of VCPI server, the INT 67\AH=DE08h–DE09h functions shouldn't be called for, when EMM386.EXE driver's active state is not confirmed yet by a call for INT 67\AH=46h (note 1 to 8.03-62) and also when VCPI functions are disabled by /noVCPI parameter (note 2 to 5.04-02).

Prepare : AX = DE08h – reading from DR0–DR7 registers into a buffer = DE09h – writing from buffer into DR0–DR7 registers ES:DI – pointer to buffer with data or for data (note 1)

On return : AH – error code (A.06-1); AH = 00h signifies successful termination.

Note 1: Buffer is 32 bytes long and is filled with 4 data bytes per register from DR0 to DR7. Data, corresponding to DR4 and DR5 registers, are not read and are ignored by writing operation. Role of DR registers is described in appendix A.11-5.

8.03-74 INT 67\AX=FFA5h – EMM386.EXE driver's API entrance point[edit | edit source]

The INT 67\AX=FFA5h function, stipulated by LIM EMS specification since version 4.2, differs from other INT 67 functions in that it is executed even when EMM386.EXE driver is inactive and ignores all other requests. However, this feature doesn't exclude necessity to check whether the EMM386.EXE driver is loaded (note 1 to 8.03-62) before INT 67\AX=FFA5h function is called for.

Prepare : AX = FFA5h

On return : AH = 84h – signature of successful termination, and then BX:CX – address of EMM386.EXE API entrance point.

Note 1: A CALL FAR command (7.03-08) addressed to BX:CX entrance point forces EMM386.EXE to perform operation, defined by value in AX register :

if AX = 0100h – to switch itself ON to active state;
if AX = 0101h – to switch itself OFF to inactive state;
if AX = 0500h – to display a message about current state.

When UMB blocks and EMS pages are used yet, then a request for switching OFF to inactive state wouldn't be executed.

8.03-75 INT 70 – INT 77: interrupt requests IRQ 8 – IRQ 15[edit | edit source]

While CPU is in real mode, the INT 70 – INT 77 group of interrupt handlers responds to requests, sent via IRQ 8 – IRQ 15 lines from various devices to the second interrupt controller, which, in its turn, sends its output to CPU via IRQ 2 line of the first interrupt controller (INT 0A, 8.01-09). Each of IRQ 8 – IRQ 15 input lines may be disabled (masked) by sending a bit, specified in the third column of the following table, to second interrupt controller via port A1h. Some IRQ lines have dedicated hardware sources, listed in the fourth column of the following table, but some other IRQ lines are free to receive a request from any device, which is tuned to send requests via one of these lines and is supported by a driver, loading a handler for the corresponding interrupt.

Interrupt Line Mask Source of requests Comments
INT 70 IRQ 8 bit 0 Real-time clock note *1
INT 71 IRQ 9 bit 1
INT 72 IRQ 10 bit 2
INT 73 IRQ 11 bit 3
INT 74 IRQ 12 bit 4 note *2
INT 75 IRQ 13 bit 5 Arithmetic coprocessor
INT 76 IRQ 14 bit 6 1st IDE controller
INT 77 IRQ 15 bit 7 note *3

Note 1: The INT 70 handler is called 1024 times per second. There are BIOS systems, which call for INT 70 handler in event waiting intervals only (INT 15\AH=83h, 8.01-73).

Note 2: Preferable source for IRQ 12 line is PS2 mouse, if it is used.

Note 3: Preferable sources for IRQ 15 line are either second IDE controller or SCSI bus controller, if these are present in a particular PC.