home *** CD-ROM | disk | FTP | other *** search
/ For Beginners & Professional Hackers / cd.iso / docum / advdos.doc / s2 < prev    next >
Encoding:
Text File  |  1992-04-21  |  318.5 KB  |  9,378 lines

  1. ────────────────────────────────────────────────────────────────────────────
  2. SECTION 2  MS-DOS FUNCTIONS REFERENCE
  3. ────────────────────────────────────────────────────────────────────────────
  4.  
  5.  
  6. Notes to the Reader
  7.  
  8.   This section documents the services that the MS-DOS kernel provides to
  9.   application programs via software interrupts 20H─2FH. Each MS-DOS function
  10.   is described in the same format:
  11.  
  12.   ■ A heading containing the function's name, software interrupt and
  13.     function number, and an icon indicating the MS-DOS version in which the
  14.     function was first supported. You can assume that the function is
  15.     available in all subsequent MS-DOS versions unless explicitly noted
  16.     otherwise.
  17.  
  18.   ■ A synopsis of the actions performed by the function and the
  19.     circumstances under which it would be used.
  20.  
  21.   ■ A summary of the function's arguments.
  22.  
  23.   ■ The results and/or error indicators returned by the function. A
  24.     comprehensive list of error codes can be found in the entry for Int 21H
  25.     Function 59H.
  26.  
  27.   ■ Notes describing special uses or dependencies of the function.
  28.  
  29.   ■ A skeleton example of the function's use, written in assembly language.
  30.  
  31.   Version icons used in the synopsis, arguments, results, or Notes sections
  32.   refer to specific minor or major versions, unless they include a + sign to
  33.   indicate a version and all subsequent versions.
  34.  
  35.   For purposes of clarity, the examples may include instructions that would
  36.   not be necessary if the code were inserted into a working program. For
  37.   example, most of the examples explicitly set the segment registers when
  38.   passing the address of a filename or buffer to MS-DOS; in real
  39.   applications, the segment registers are usually initialized once at entry
  40.   to the program and left alone thereafter.
  41.  
  42.  
  43. Int 21H Function Summary by Number
  44.  
  45.  
  46.   Hex      Dec     Function name                           Vers    F/H
  47. Specifies whether file functions are FCB- or handle-related.
  48.  
  49.   ──────────────────────────────────────────────────────────────────────────
  50.   00H        0    Terminate Process                       1.0+
  51.   01H        1    Character Input with Echo               1.0+
  52.   02H        2    Character Output                        1.0+
  53.   03H        3    Auxiliary Input                         1.0+
  54.   04H        4    Auxiliary Output                        1.0+
  55.   05H        5    Printer Output                          1.0+
  56.   06H        6    Direct Console I/O                      1.0+
  57.   07H        7    Unfiltered Character Input Without Echo 1.0+
  58.   08H        8    Character Input Without Echo            1.0+
  59.   09H        9    Display String                          1.0+
  60.   0AH       10    Buffered Keyboard Input                 1.0+
  61.   0BH       11    Check Input Status                      1.0+
  62.   0CH       12    Flush Input Buffer and Then Input       1.0+
  63.   0DH       13    Disk Reset                              1.0+
  64.   0EH       14    Select Disk                             1.0+
  65.   0FH       15    Open File                               1.0+    F
  66.   10H       16    Close File                              1.0+    F
  67.   11H       17    Find First File                         1.0+    F
  68.   12H       18    Find Next File                          1.0+    F
  69.   13H       19    Delete File                             1.0+    F
  70.   14H       20    Sequential Read                         1.0+    F
  71.   15H       21    Sequential Write                        1.0+    F
  72.   16H       22    Create File                             1.0+    F
  73.   17H       23    Rename File                             1.0+    F
  74.   18H        24    Reserved
  75.   19H       25    Get Current Disk                        1.0+
  76.   1AH       26    Set DTA Address                         1.0+
  77.   1BH       27    Get Default Drive Data                  1.0+
  78.   1CH       28    Get Drive Data                          2.0+
  79.   1DH        29    Reserved
  80.   1EH        30    Reserved
  81.   1FH        31    Reserved
  82.   20H        32    Reserved
  83.   21H       33    Random Read                             1.0+    F
  84.   22H       34    Random Write                            1.0+    F
  85.   23H       35    Get File Size                           1.0+    F
  86.   24H       36    Set Relative Record Number              1.0+    F
  87.   25H       37    Set Interrupt Vector                    1.0+
  88.   26H       38    Create New PSP                          1.0+
  89.   27H       39    Random Block Read                       1.0+    F
  90.   28H       40    Random Block Write                      1.0+    F
  91.   29H       41    Parse Filename                          1.0+
  92.   2AH       42    Get Date                                1.0+
  93.   2BH       43    Set Date                                1.0+
  94.   2CH       44    Get Time                                1.0+
  95.   2DH       45    Set Time                                1.0+
  96.   2EH       46    Set Verify Flag                         1.0+
  97.   2FH       47    Get DTA Address                         2.0+
  98.   30H       48    Get MS-DOS Version Number               2.0+
  99.   31H       49    Terminate and Stay Resident             2.0+
  100.   32H        50    Reserved
  101.   33H       51    Get or Set Break Flag, Get Boot Drive   2.0+
  102.   34H        52    Reserved
  103.   35H       53    Get Interrupt Vector                    2.0+
  104.   36H       54    Get Drive Allocation Information        2.0+
  105.   37H        55    Reserved
  106.   38H       56    Get or Set Country Information          2.0+
  107.   39H       57    Create Directory                        2.0+
  108.   3AH       58    Delete Directory                        2.0+
  109.   3BH       59    Set Current Directory                   2.0+
  110.   3CH       60    Create File                             2.0+    H
  111.   3DH       61    Open File                               2.0+    H
  112.   3EH       62    Close File                              2.0+    H
  113.   3FH       63    Read File or Device                     2.0+    H
  114.   40H       64    Write File or Device                    2.0+    H
  115.   41H       65    Delete File                             2.0+    H
  116.   42H       66    Set File Pointer                        2.0+    H
  117.   43H       67    Get or Set File Attributes              2.0+
  118.   44H       68    IOCTL (I/O Control)                     2.0+
  119.   45H       69    Duplicate Handle                        2.0+
  120.   46H       70    Redirect Handle                         2.0+
  121.   47H       71    Get Current Directory                   2.0+
  122.   48H       72    Allocate Memory Block                   2.0+
  123.   49H       73    Release Memory Block                    2.0+
  124.   4AH       74    Resize Memory Block                     2.0+
  125.   4BH       75    Execute Program (EXEC)                  2.0+
  126.   4CH       76    Terminate Process with Return Code      2.0+
  127.   4DH       77    Get Return Code                         2.0+
  128.   4EH       78    Find First File                         2.0+    H
  129.   4FH       79    Find Next File                          2.0+    H
  130.   50H        80    Reserved
  131.   51H        81    Reserved
  132.   52H        82    Reserved
  133.   53H        83    Reserved
  134.   54H       84    Get Verify Flag                         2.0+
  135.   55H        85    Reserved
  136.   56H       86    Rename File                             2.0+
  137.   57H       87    Get or Set File Date and Time           2.0+    H
  138.   58H       88    Get or Set Allocation Strategy          3.0+
  139.   59H       89    Get Extended Error Information          3.0+
  140.   5AH       90    Create Temporary File                   3.0+    H
  141.   5BH       91    Create New File                         3.0+    H
  142.   5CH       92    Lock or Unlock File Region              3.0+    H
  143.   5DH        93    Reserved
  144.   5EH       94    Get Machine Name, Get or Set Printer    3.1+
  145.                    Setup
  146.   5FH       95    Device Redirection                      3.1+
  147.   60H        96    Reserved
  148.   61H        97    Reserved
  149.   62H       98    Get PSP Address                         3.0+
  150.   63H       99    Get DBCS Lead Byte Table                2.25
  151.                                                            only
  152.   64H       100    Reserved
  153.   65H      101    Get Extended Country Information        3.3+
  154.   66H      102    Get or Set Code Page                    3.3+
  155.   67H      103    Set Handle Count                        3.3+
  156.   68H      104    Commit File                             3.3+    H
  157.   69H       105    Reserved
  158.   6AH       106    Reserved
  159.   6BH       107    Reserved
  160.   6CH      108    Extended Open File                      4.0+    H
  161.   ──────────────────────────────────────────────────────────────────────────
  162.  
  163.  
  164.  
  165. Int 21H Function Summary by Category
  166.  
  167.  
  168.   Hex      Dec     Function name                           Vers    F/H
  169.   ──────────────────────────────────────────────────────────────────────────
  170.   Character I/O
  171.   01H        1    Character Input with Echo               1.0+
  172.   02H        2    Character Output                        1.0+
  173.   03H        3    Auxiliary Input                         1.0+
  174.   04H        4    Auxiliary Output                        1.0+
  175.   05H        5    Printer Output                          1.0+
  176.   06H        6    Direct Console I/O                      1.0+
  177.   07H        7    Unfiltered Character Input Without Echo 1.0+
  178.   08H        8    Character Input Without Echo            1.0+
  179.   09H        9    Display String                          1.0+
  180.   0AH       10    Buffered Keyboard Input                 1.0+
  181.   0BH       11    Check Input Status                      1.0+
  182.   0CH       12    Flush Input Buffer and Then Input       1.0+
  183.  
  184.   File Operations
  185.   0FH       15    Open File                               1.0+    F
  186.   10H       16    Close File                              1.0+    F
  187.   11H       17    Find First File                         1.0+    F
  188.   12H       18    Find Next File                          1.0+    F
  189.   13H       19    Delete File                             1.0+    F
  190.   16H       22    Create File                             1.0+    F
  191.   17H       23    Rename File                             1.0+    F
  192.   23H       35    Get File Size                           1.0+    F
  193.   29H       41    Parse Filename                          1.0+    F
  194.   3CH       60    Create File                             2.0+    H
  195.   3DH       61    Open File                               2.0+    H
  196.   3EH       62    Close File                              2.0+    H
  197.   41H       65    Delete File                             2.0+    H
  198.   43H       67    Get or Set File Attributes              2.0+
  199.   45H       69    Duplicate Handle                        2.0+
  200.   46H       70    Redirect Handle                         2.0+
  201.   4EH       78    Find First File                         2.0+    H
  202.   4FH       79    Find Next File                          2.0+    H
  203.   56H       86    Rename File                             2.0+
  204.   57H       87    Get or Set File Date and Time           2.0+    H
  205.   5AH       90    Create Temporary File                   3.0+    H
  206.   5BH       91    Create New File                         3.0+    H
  207.   67H      103    Set Handle Count                        3.3+
  208.   68H      104    Commit File                             3.3+    H
  209.   6CH      108    Extended Open File                      4.0+    H
  210.  
  211.   Record Operations
  212.   14H       20    Sequential Read                         1.0+    F
  213.   15H       21    Sequential Write                        1.0+    F
  214.   1AH       26    Set DTA Address                         1.0+
  215.   21H       33    Random Read                             1.0+    F
  216.   22H       34    Random Write                            1.0+    F
  217.   24H       36    Set Relative Record Number              1.0+    F
  218.   27H       39    Random Block Read                       1.0+    F
  219.   28H       40    Random Block Write                      1.0+    F
  220.   2FH       47    Get DTA Address                         2.0+
  221.   3FH       63    Read File or Device                     2.0+    H
  222.   40H       64    Write File or Device                    2.0+    H
  223.   42H       66    Set File Pointer                        2.0+    H
  224.   5CH       92    Lock or Unlock File Region              3.0+    H
  225.  
  226.   Directory Operations
  227.   39H       57    Create Directory                        2.0+
  228.   3AH       58    Delete Directory                        2.0+
  229.   3BH       59    Set Current Directory                   2.0+
  230.   47H       71    Get Current Directory                   2.0+
  231.  
  232.   Disk Management
  233.   0DH       13    Disk Reset                              1.0+
  234.   0EH       14    Select Disk                             1.0+
  235.   19H       25    Get Current Disk                        1.0+
  236.   1BH       27    Get Default Drive Data                  1.0+
  237.   1CH       28    Get Drive Data                          2.0+
  238.   2EH       46    Set Verify Flag                         1.0+
  239.   36H       54    Get Drive Allocation Information        2.0+
  240.   54H       84    Get Verify Flag                         2.0+
  241.  
  242.   Process Management
  243.   00H        0    Terminate Process                       1.0+
  244.   26H       38    Create New PSP                          1.0+
  245.   31H       49    Terminate and Stay Resident             2.0+
  246.   4BH       75    Execute Program (EXEC)                  2.0+
  247.   4CH       76    Terminate Process with Return Code      2.0+
  248.   4DH       77    Get Return Code                         2.0+
  249.   62H       98    Get PSP Address                         3.0+
  250.  
  251.   Memory Management
  252.   48H       72    Allocate Memory Block                   2.0+
  253.   49H       73    Release Memory Block                    2.0+
  254.   4AH       74    Resize Memory Block                     2.0+
  255.   58H       88    Get or Set Allocation Strategy          3.0+
  256.  
  257.   Network Functions
  258.   5EH       94    Get Machine Name, Get or Set Printer    3.1+
  259.                    Setup
  260.   5FH       95    Device Redirection                      3.1+
  261.  
  262.   Time and Date
  263.   2AH       42    Get Date                                1.0+
  264.   2BH       43    Set Date                                1.0+
  265.   2CH       44    Get Time                                1.0+
  266.   2DH       45    Set Time                                1.0+
  267.  
  268.   Miscellaneous System Functions
  269.   25H       37    Set Interrupt Vector                    1.0+
  270.   30H       48    Get MS-DOS Version Number               2.0+
  271.   33H       51    Get or Set Break Flag, Get Boot Drive   2.0+
  272.   35H       53    Get Interrupt Vector                    2.0+
  273.   38H       56    Get or Set Country Information          2.0+
  274.   44H       68    IOCTL (I/O Control)                     2.0+
  275.   59H       89    Get Extended Error Information          3.0+
  276.   63H       99    Get Lead Byte Table                     2.25
  277.                                                            only
  278.   65H      101    Get Extended Country Information        3.3+
  279.   66H      102    Get or Set Code Page                    3.3+
  280.  
  281.   Reserved Functions
  282.   18H        24    Reserved
  283.   1DH        29    Reserved
  284.   1EH        30    Reserved
  285.   1FH        31    Reserved
  286.   20H        32    Reserved
  287.   32H        50    Reserved
  288.   34H        52    Reserved
  289.   37H        55    Reserved
  290.   50H        80    Reserved
  291.   51H        81    Reserved
  292.   52H        82    Reserved
  293.   53H        83    Reserved
  294.   55H        85    Reserved
  295.   5DH        93    Reserved
  296.   60H        96    Reserved
  297.   61H        97    Reserved
  298.   64H       100    Reserved
  299.   69H       105    Reserved
  300.   6AH       106    Reserved
  301.   6BH       107    Reserved
  302.   ──────────────────────────────────────────────────────────────────────────
  303.  
  304.  
  305.  
  306. ────────────────────────────────────────────────────────────────────────────
  307. Int 20H                                                                [1.0]
  308. Terminate process
  309. ────────────────────────────────────────────────────────────────────────────
  310.  
  311.   Terminates the current process. This is one of several methods that a
  312.   program can use to perform a final exit. MS-DOS then takes the following
  313.   actions:
  314.  
  315.   ■ All memory belonging to the process is released.
  316.  
  317.   ■ File buffers are flushed and any open handles for files or devices owned
  318.     by the process are closed.
  319.  
  320.   ■ The termination handler vector (Int 22H) is restored from PSP:000AH.
  321.  
  322.   ■ The Ctrl-C handler vector (Int 23H) is restored from PSP:000EH.
  323.  
  324.   ■ [2.0+] The critical-error handler vector (Int 24H) is restored from
  325.     PSP:0012H.
  326.  
  327.   ■ Control is transferred to the termination handler.
  328.  
  329.   If the program is returning to COMMAND.COM, control transfers to the
  330.   resident portion, and the transient portion is reloaded if necessary. If a
  331.   batch file is in progress, the next line of the file is fetched and
  332.   interpreted; otherwise, a prompt is issued for the next user command.
  333.  
  334. Call with:
  335.  
  336.   CS            = segment address of program segment prefix
  337.  
  338. Returns:
  339.  
  340.   Nothing
  341.  
  342. Notes:
  343.  
  344.   ■ Any files that have been written to using FCBs should be closed before
  345.     performing this exit call; otherwise, data may be lost.
  346.  
  347.   ■ Other methods of performing a final exit are:
  348.  
  349.     ∙ Int 21H Function 00H
  350.  
  351.     ∙ Int 21H Function 31H
  352.  
  353.     ∙ Int 21H Function 4CH
  354.  
  355.     ∙ Int 27H
  356.  
  357.   ■ [2.0+] Int 21H Functions 31H and 4CH are the preferred methods for
  358.     termination, since they allow a return code to be passed to the parent
  359.     process.
  360.  
  361.   ■ [3.0+] If the program is running on a network, it should remove all
  362.     locks it has placed on file regions before terminating.
  363.  
  364. Example:
  365.  
  366.   Terminate the current program, returning control to the program's parent.
  367.  
  368.           .
  369.           .
  370.           .
  371.           int     20h             ; transfer to MS-DOS
  372.  
  373.  
  374. ────────────────────────────────────────────────────────────────────────────
  375. Int 21H                                                                [1.0]
  376. Function 00H
  377. Terminate process
  378. ────────────────────────────────────────────────────────────────────────────
  379.  
  380.   Terminates the current process. This is one of several methods that a
  381.   program can use to perform a final exit. MS-DOS then takes the following
  382.   actions:
  383.  
  384.   ■ All memory belonging to the process is released.
  385.  
  386.   ■ File buffers are flushed and any open handles for files or devices owned
  387.     by the process are closed.
  388.  
  389.   ■ The termination handler vector (Int 22H) is restored from PSP:000AH.
  390.  
  391.   ■ The Ctrl-C handler vector (Int 23H) is restored from PSP:000EH.
  392.  
  393.   ■ [2.0+] The critical-error handler vector (Int 24H) is restored from
  394.     PSP:0012H.
  395.  
  396.   ■ Control is transferred to the termination handler.
  397.  
  398.   If the program is returning to COMMAND.COM, control transfers to the
  399.   resident portion, and the transient portion is reloaded if necessary. If a
  400.   batch file is in progress, the next line of the file is fetched and
  401.   interpreted; otherwise, a prompt is issued for the next user command.
  402.  
  403. Call with:
  404.  
  405.   AH            = 00H
  406.   CS            = segment address of program segment prefix
  407.  
  408. Returns:
  409.  
  410.   Nothing
  411.  
  412. Notes:
  413.  
  414.   ■ Any files that have been written to using FCBs should be closed before
  415.     performing this exit call; otherwise, data may be lost.
  416.  
  417.   ■ Other methods of performing a final exit are:
  418.  
  419.     ∙ Int 20H
  420.  
  421.     ∙ Int 21H Function 31H
  422.  
  423.     ∙ Int 21H Function 4CH<21H4CH>
  424.  
  425.     ∙ Int 27H
  426.  
  427.   ■ [2.0+] Int 21H Functions 31H and 4CH are the preferred methods for
  428.     termination, since they allow a return code to be passed to the parent
  429.     process.
  430.  
  431.   ■ [3.0+] If the program is running on a network, it should remove all
  432.     locks it has placed on file regions before terminating.
  433.  
  434. Example:
  435.  
  436.   Terminate the current program, returning control to the program's parent.
  437.  
  438.           .
  439.           .
  440.           .
  441.           mov     ah,0            ; function number
  442.           int     21h             ; transfer to MS-DOS
  443.  
  444.  
  445. ────────────────────────────────────────────────────────────────────────────
  446. Int 21H                                                                [1.0]
  447. Function 01H
  448. Character input with echo
  449. ────────────────────────────────────────────────────────────────────────────
  450.  
  451.   [1] Inputs a character from the keyboard, then echoes it to the display.
  452.   If no character is ready, waits until one is available.
  453.  
  454.   [2.0+] Reads a character from the standard input device and echoes it to
  455.   the standard output device. If no character is ready, waits until one is
  456.   available. Input can be redirected. (If input has been redirected, there
  457.   is no way to detect EOF.)
  458.  
  459. Call with:
  460.  
  461.   AH            = 01H
  462.  
  463. Returns:
  464.  
  465.   AL            = 8-bit input data
  466.  
  467. Notes:
  468.  
  469.   ■ If the standard input is not redirected, and the character read is a
  470.     Ctrl-C, an Int 23H is executed. If the standard input is redirected, a
  471.     Ctrl-C is detected at the console, and BREAK is ON, an Int 23H is
  472.     executed.
  473.  
  474.   ■ To read extended ASCII codes (such as the special function keys F1 to
  475.     F10) on the IBM PC and compatibles, you must call this function twice.
  476.     The first call returns the value 00H to signal the presence of an
  477.     extended code.
  478.  
  479.   ■ See also Int 21H Functions 06H, 07H, and 08H, which provide character
  480.     input with various combinations of echo and/or Ctrl-C sensing.
  481.  
  482.   ■ [2.0+] You can also read the keyboard by issuing a read (Int 21H
  483.     Function 3FH) using the predefined handle for the standard input
  484.     (0000H), if input has not been redirected, or a handle obtained by
  485.     opening the logical device CON.
  486.  
  487. Example:
  488.  
  489.   Read one character from the keyboard into register AL, echo it to the
  490.   display, and store it in the variable char.
  491.  
  492.   char    db      0               ; input character
  493.           .
  494.           .
  495.           .
  496.           mov     ah,1            ; function number
  497.           int     21h             ; transfer to MS-DOS
  498.           mov     char,al         ; save character
  499.           .
  500.           .
  501.           .
  502.  
  503.  
  504. ────────────────────────────────────────────────────────────────────────────
  505. Int 21H                                                                [1.0]
  506. Function 02H
  507. Character output
  508. ────────────────────────────────────────────────────────────────────────────
  509.  
  510.   [1] Outputs a character to the currently active video display.
  511.  
  512.   [2.0+] Outputs a character to the standard output device. Output can be
  513.   redirected. (If output is redirected, there is no way to detect disk
  514.   full.)
  515.  
  516. Call with:
  517.  
  518.   AH            = 02H
  519.   DL            = 8-bit data for output
  520.  
  521. Returns:
  522.  
  523.   Nothing
  524.  
  525. Notes:
  526.  
  527.   ■ If a Ctrl-C is detected at the keyboard after the requested character is
  528.     output, an Int 23H is executed.
  529.  
  530.   ■ If the standard output has not been redirected, a backspace code (08H)
  531.     causes the cursor to move left one position. If output has been
  532.     redirected, the backspace code does not receive any special treatment.
  533.  
  534.   ■ [2.0+] You can also send strings to the display by performing a write
  535.     (Int 21H Function 40H) using the predefined handle for the standard
  536.     output (0001H), if output has not been redirected, or a handle obtained
  537.     by opening the logical device CON.
  538.  
  539. Example:
  540.  
  541.   Send the character "*" to the standard output device.
  542.  
  543.           .
  544.           .
  545.           .
  546.           mov     ah,2            ; function number
  547.           mov     dl,'*'          ; character to output
  548.           int     21h             ; transfer to MS-DOS
  549.           .
  550.           .
  551.           .
  552.  
  553.  
  554. ────────────────────────────────────────────────────────────────────────────
  555. Int 21H                                                                [1.0]
  556. Function 03H
  557. Auxiliary input
  558. ────────────────────────────────────────────────────────────────────────────
  559.  
  560.   [1] Reads a character from the first serial port.
  561.  
  562.   [2.0+] Reads a character from the standard auxiliary device. The default
  563.   is the first serial port (COM1).
  564.  
  565. Call with:
  566.  
  567.   AH            = 03H
  568.  
  569. Returns:
  570.  
  571.   AL            = 8-bit input data
  572.  
  573. Notes:
  574.  
  575.   ■ In most MS-DOS systems, the serial device is unbuffered and is not
  576.     interrupt-driven. If the auxiliary device sends data faster than your
  577.     program can process it, characters may be lost.
  578.  
  579.   ■ At startup on the IBM PC, PC-DOS initializes the first serial port to
  580.     2400 baud, no parity, 1 stop bit, and 8 data bits. Other implementations
  581.     of MS-DOS may initialize the serial device differently.
  582.  
  583.   ■ There is no way for a user program to read the status of the auxiliary
  584.     device or to detect I/O errors (such as lost characters) through this
  585.     function call. On the IBM PC, more precise control can be obtained by
  586.     calling ROM BIOS Int 14H or by driving the communications controller
  587.     directly.
  588.  
  589.   ■ If a Ctrl-C is detected at the keyboard, an Int 23H is executed.
  590.  
  591.   ■ [2.0+] You can also input from the auxiliary device by requesting a read
  592.     (Int 21H Function 3FH) using the predefined handle for the standard
  593.     auxiliary device (0003H) or using a handle obtained by opening the
  594.     logical device AUX.
  595.  
  596. Example:
  597.  
  598.   Read a character from the standard auxiliary input and store it in the
  599.   variable char.
  600.  
  601.   char    db      0               ; input character
  602.           .
  603.           .
  604.           .
  605.           mov     ah,3            ; function number
  606.           int     21h             ; transfer to MS-DOS
  607.           mov     char,al         ; save character
  608.           .
  609.           .
  610.           .
  611.  
  612.  
  613. ────────────────────────────────────────────────────────────────────────────
  614. Int 21H                                                                [1.0]
  615. Function 04H
  616. Auxiliary output
  617. ────────────────────────────────────────────────────────────────────────────
  618.  
  619.   [1] Outputs a character to the first serial port.
  620.  
  621.   [2.0+] Outputs a character to the standard auxiliary device. The default
  622.   is the first serial port (COM1).
  623.  
  624. Call with:
  625.  
  626.   AH            = 04H
  627.   DL            = 8-bit data for output
  628.  
  629. Returns:
  630.  
  631.   Nothing
  632.  
  633. Notes:
  634.  
  635.   ■ If the output device is busy, this function waits until the device is
  636.     ready to accept a character.
  637.  
  638.   ■ There is no way to poll the status of the auxiliary device using this
  639.     function. On the IBM PC, more precise control can be obtained by calling
  640.     ROM BIOS Int 14H or by driving the communications controller directly.
  641.  
  642.   ■ If a Ctrl-C is detected at the keyboard, an Int 23H is executed.
  643.  
  644.   ■ [2.0+] You can also send strings to the auxiliary device by performing a
  645.     write (Int 21H Function 40H) using the predefined handle for the
  646.     standard auxiliary device (0003H) or using a handle obtained by opening
  647.     the logical device AUX.
  648.  
  649. Example:
  650.  
  651.   Output a "*'' character to the auxiliary device.
  652.  
  653.           .
  654.           .
  655.           .
  656.           mov     ah,4            ; function number
  657.           mov     dl,'*'          ; character to output
  658.           int     21h             ; transfer to MS-DOS
  659.           .
  660.           .
  661.           .
  662.  
  663.  
  664. ────────────────────────────────────────────────────────────────────────────
  665. Int 21H                                                                [1.0]
  666. Function 05H
  667. Printer output
  668. ────────────────────────────────────────────────────────────────────────────
  669.  
  670.   [1] Sends a character to the first list device (PRN or LPT1).
  671.  
  672.   [2.0+] Sends a character to the standard list device. The default device
  673.   is the printer on the first parallel port (LPT1), unless explicitly
  674.   redirected by the user with the MODE command.
  675.  
  676. Call with:
  677.  
  678.   AH            = 05H
  679.   DL            = 8-bit data for output
  680.  
  681. Returns:
  682.  
  683.   Nothing
  684.  
  685. Notes:
  686.  
  687.   ■ If the printer is busy, this function waits until the printer is ready
  688.     to accept the character.
  689.  
  690.   ■ There is no standardized way to poll the status of the printer under
  691.     MS-DOS.
  692.  
  693.   ■ If a Ctrl-C is detected at the keyboard, an Int 23H is executed.
  694.  
  695.   ■ [2.0+] You can also send strings to the printer by performing a write
  696.     (Int 21H Function 40H) using the predefined handle for the standard
  697.     printer device (0004H) or using a handle obtained by opening the logical
  698.     device PRN or LPT1.
  699.  
  700. Example:
  701.  
  702.   Output the character "*'' to the list device.
  703.  
  704.           .
  705.           .
  706.           .
  707.           mov     ah,5            ; function number
  708.           mov     dl,'*'          ; character to output
  709.           int     21h             ; transfer to MS-DOS
  710.           .
  711.           .
  712.           .
  713.  
  714.  
  715. ────────────────────────────────────────────────────────────────────────────
  716. Int 21H                                                                [1.0]
  717. Function 06H
  718. Direct console I/O
  719. ────────────────────────────────────────────────────────────────────────────
  720.  
  721.   Used by programs that need to read and write all possible characters and
  722.   control codes without any interference from the operating system.
  723.  
  724.   [1] Reads a character from the keyboard or writes a character to the
  725.   display.
  726.  
  727.   [2.0+] Reads a character from the standard input device or writes a
  728.   character to the standard output device. I/O may be redirected. (If I/O
  729.   has been redirected, there is no way to detect EOF or disk full.)
  730.  
  731. Call with:
  732.  
  733.   AH            = 06H
  734.   DL            = function requested
  735.  
  736.                   00H─FEH   if output request
  737.                   0FFH      if input request
  738.  
  739. Returns:
  740.  
  741.   If called with DL = 00H─0FEH
  742.  
  743.   Nothing
  744.  
  745.   If called with DL = FFH and a character is ready
  746.  
  747.   Zero flag     = clear
  748.   AL            = 8-bit input data
  749.  
  750.   If called with DL = FFH and no character is ready
  751.  
  752.   Zero flag     = set
  753.  
  754. Notes:
  755.  
  756.   ■ No special action is taken upon entry of a Ctrl-C when this service is
  757.     used.
  758.  
  759.   ■ To read extended ASCII codes (such as the special function keys F1 to
  760.     F10) on the IBM PC and compatibles, you must call this function twice.
  761.     The first call returns the value 00H to signal the presence of an
  762.     extended code.
  763.  
  764.   ■ See also Int 21H Functions 01H, 07H, and 08H, which provide character
  765.     input with various combinations of echo and/or Ctrl-C sensing, and
  766.     Functions 02H and 09H, which may be used to write characters to the
  767.     standard output.
  768.  
  769.   ■ [2.0+] You can also read the keyboard by issuing a read (Int 21H
  770.     Function 3FH) using the predefined handle for the standard input
  771.     (0000H), if input has not been redirected, or a handle obtained by
  772.     opening the logical device CON.
  773.  
  774.   ■ [2.0+] You can also send characters to the display by issuing a write
  775.     (Int 21H Function 40H) using the predefined handle for the standard
  776.     output (0001H), if output has not been redirected, or a handle obtained
  777.     by opening the logical device CON.
  778.  
  779. Examples:
  780.  
  781.   Send the character "*" to the standard output device.
  782.  
  783.           .
  784.           .
  785.           .
  786.           mov     ah,6            ; function number
  787.           mov     dl,'*'          ; character to output
  788.           int     21h             ; transfer to MS-DOS
  789.           .
  790.           .
  791.           .
  792.  
  793.   Read a character from the standard input device and save it in the
  794.   variable char. If no character is ready, wait until one is available.
  795.  
  796.   char    db      0               ; input character
  797.           .
  798.           .
  799.           .
  800.   wait:   mov     ah,6            ; function number
  801.           mov     dl,0ffh         ; parameter for read
  802.           int     21h             ; transfer to MS-DOS
  803.           jz      wait            ; wait until char ready
  804.           mov     char,al         ; save the character
  805.           .
  806.           .
  807.           .
  808.  
  809.  
  810. ────────────────────────────────────────────────────────────────────────────
  811. Int 21H                                                                [1.0]
  812. Function 07H
  813. Unfiltered character input without echo
  814. ────────────────────────────────────────────────────────────────────────────
  815.  
  816.   [1] Reads a character from the keyboard without echoing it to the display.
  817.   If no character is ready, waits until one is available.
  818.  
  819.   [2.0+] Reads a character from the standard input device without echoing it
  820.   to the standard output device. If no character is ready, waits until one
  821.   is available. Input may be redirected. (If input has been redirected,
  822.   there is no way to detect EOF.)
  823.  
  824. Call with:
  825.  
  826.   AH            = 07H
  827.  
  828. Returns:
  829.  
  830.   AL            = 8-bit input data
  831.  
  832. Notes:
  833.  
  834.   ■ No special action is taken upon entry of a Ctrl-C when this function is
  835.     used. If Ctrl-C checking is required, use Int 21H Function 08H instead.
  836.  
  837.   ■ To read extended ASCII codes (such as the special function keys F1 to
  838.     F10) on the IBM PC and compatibles, you must call this function twice.
  839.     The first call returns the value 00H to signal the presence of an
  840.     extended code.
  841.  
  842.   ■ See also Int 21H Functions 01H, 06H, and 08H, which provide character
  843.     input with various combinations of echo and/or Ctrl-C sensing.
  844.  
  845.   ■ [2.0+] You can also read the keyboard by issuing a read (Int 21H
  846.     Function 3FH) using the predefined handle for the standard input
  847.     (0000H), if input has not been redirected, or a handle obtained by
  848.     opening the logical device CON.
  849.  
  850. Example:
  851.  
  852.   Read a character from the standard input without echoing it to the
  853.   display, and store it in the variable char.
  854.  
  855.   char    db      0               ; input character
  856.           .
  857.           .
  858.           .
  859.           mov     ah,7            ; function number
  860.           int     21h             ; transfer to MS-DOS
  861.           mov     char,al         ; save character
  862.           .
  863.           .
  864.           .
  865.  
  866.  
  867. ────────────────────────────────────────────────────────────────────────────
  868. Int 21H                                                                [1.0]
  869. Function 08H
  870. Character input without echo
  871. ────────────────────────────────────────────────────────────────────────────
  872.  
  873.   [1] Reads a character from the keyboard without echoing it to the display.
  874.   If no character is ready, waits until one is available.
  875.  
  876.   [2.0+] Reads a character from the standard input device without echoing it
  877.   to the standard output device. If no character is ready, waits until one
  878.   is available. Input may be redirected. (If input has been redirected,
  879.   there is no way to detect EOF.)
  880.  
  881. Call with:
  882.  
  883.   AH            = 08H
  884.  
  885. Returns:
  886.  
  887.   AL            = 8-bit input data
  888.  
  889. Notes:
  890.  
  891.   ■ If the standard input is not redirected, and the character read is a
  892.     Ctrl-C, an Int 23H is executed. If the standard input is redirected, a
  893.     Ctrl-C is detected at the console, and BREAK is ON, an Int 23H is
  894.     executed. To avoid possible interruption by a Ctrl-C, use Int 21H
  895.     Function 07H instead.
  896.  
  897.   ■ To read extended ASCII codes (such as the special function keys F1 to
  898.     F10) on the IBM PC and compatibles, you must call this function twice.
  899.     The first call returns the value 00H to signal the presence of an
  900.     extended code.
  901.  
  902.   ■ See also Int 21H Functions 01H, 06H, and 07H, which provide character
  903.     input with various combinations of echo and/or Ctrl-C sensing.
  904.  
  905.   ■ [2.0+] You can also read the keyboard by issuing a read (Int 21H
  906.     Function 3FH) using the predefined handle for the standard input
  907.     (0000H), if input has not been redirected, or a handle obtained by
  908.     opening the logical device CON.
  909.  
  910. Example:
  911.  
  912.   Read a character from the standard input without echoing it to the
  913.   display, allowing possible detection of Ctrl-C, and store the character in
  914.   the variable char.
  915.  
  916.   char    db      0
  917.           .
  918.           .
  919.           .
  920.           mov     ah,8            ; function number
  921.           int     21h             ; transfer to MS-DOS
  922.           mov     char,al         ; save character
  923.           .
  924.           .
  925.           .
  926.  
  927.  
  928. ────────────────────────────────────────────────────────────────────────────
  929. Int 21H                                                                [1.0]
  930. Function 09H
  931. Display string
  932. ────────────────────────────────────────────────────────────────────────────
  933.  
  934.   [1] Sends a string of characters to the display.
  935.  
  936.   [2.0+] Sends a string of characters to the standard output device. Output
  937.   may be redirected. (If output has been redirected, there is no way to
  938.   detect disk full.)
  939.  
  940. Call with:
  941.  
  942.   AH            = 09H
  943.   DS:DX         = segment:offset of string
  944.  
  945. Returns:
  946.  
  947.   Nothing
  948.  
  949. Notes:
  950.  
  951.   ■ The string must be terminated with the character $ (24H), which is not
  952.     transmitted. Any other ASCII codes, including control codes, can be
  953.     embedded in the string.
  954.  
  955.   ■ See Int 21H Functions 02H and 06H for single-character output to the
  956.     video display or standard output device.
  957.  
  958.   ■ If a Ctrl-C is detected at the keyboard, an Int 23H is executed.
  959.  
  960.   ■ [2.0+] You can also send strings to the display by performing a write
  961.     (Int 21H Function 40H) using the predefined handle for the standard
  962.     output (0001H), if it has not been redirected, or a handle obtained by
  963.     opening the logical device CON.
  964.  
  965. Example:
  966.  
  967.   Send the string Hello World, followed by a carriage return and line feed,
  968.   to the standard output device.
  969.  
  970.   cr      equ     0dh
  971.   lf      equ     0ah
  972.  
  973.   msg     db      'Hello World',cr,lf,'$'
  974.           .
  975.           .
  976.           .
  977.           mov     ah,9            ; function number
  978.           mov     dx,seg msg      ; address of string
  979.           mov     ds,dx
  980.           mov     dx,offset msg
  981.           int     21h             ; transfer to MS-DOS
  982.           .
  983.           .
  984.           .
  985.  
  986.  
  987. ────────────────────────────────────────────────────────────────────────────
  988. Int 21H                                                                [1.0]
  989. Function 0AH (10)
  990. Buffered keyboard input
  991. ────────────────────────────────────────────────────────────────────────────
  992.  
  993.   [1] Reads a line from the keyboard and places it in a user-designated
  994.   buffer. The characters are echoed to the display.
  995.  
  996.   [2.0+] Reads a string of bytes from the standard input device, up to and
  997.   including an ASCII carriage return (0DH), and places them in a
  998.   user-designated buffer. The characters are echoed to the standard output
  999.   device. Input may be redirected. (If input has been redirected, there is
  1000.   no way to detect EOF.)
  1001.  
  1002. Call with:
  1003.  
  1004.   AH            = 0AH
  1005.   DS:DX         = segment:offset of buffer
  1006.  
  1007. Returns:
  1008.  
  1009.   Nothing (data placed in buffer)
  1010.  
  1011. Notes:
  1012.  
  1013.   ■ The buffer used by this function has the following format:
  1014.  
  1015.     Byte          Contents
  1016.     ────────────────────────────────────────────────────────────────────────
  1017.     0             maximum number of characters to read, set by program
  1018.     1             number of characters actually read (excluding carriage
  1019.                   return), set
  1020.                   by MS-DOS
  1021.     2+            string read from keyboard or standard input, terminated by
  1022.                   a carriage return (0DH)
  1023.     ────────────────────────────────────────────────────────────────────────
  1024.  
  1025.   ■ If the buffer fills to one fewer than the maximum number of characters
  1026.     it can hold, subsequent input is ignored and the bell is sounded until a
  1027.     carriage return is detected.
  1028.  
  1029.   ■ This input function is buffered with type-ahead capability, and all of
  1030.     the standard keyboard editing commands are active.
  1031.  
  1032.   ■ If the standard input is not redirected, and a Ctrl-C is detected at the
  1033.     console, an Int 23H is executed. If the standard input is redirected, a
  1034.     Ctrl-C is detected at the console, and BREAK is ON, an Int 23H is
  1035.     executed.
  1036.  
  1037.   ■ See Int 21H Functions 01H, 06H, 07H, and 08H for single-character input
  1038.     from the keyboard or standard input device.
  1039.  
  1040.   ■ [2.0+] You can also read strings from the keyboard by performing a read
  1041.     (Int 21H Function 3FH) using the predefined handle for the standard
  1042.     input (0000H), if it has not been redirected, or a handle obtained by
  1043.     opening the logical device CON.
  1044.  
  1045. Example:
  1046.  
  1047.   Read a string that is a maximum of 80 characters long from the standard
  1048.   input device, placing it in the buffer named buff.
  1049.  
  1050.   buff    db      81              ; maximum length of input
  1051.           db      0               ; actual length of input
  1052.           db      81 dup (0)      ; actual input placed here
  1053.           .
  1054.           .
  1055.           .
  1056.           mov     ah,0ah          ; function number
  1057.           mov     dx,seg buff     ; input buffer address
  1058.           mov     ds,dx
  1059.           mov     dx,offset buff
  1060.           int     21h             ; transfer to MS-DOS
  1061.           .
  1062.           .
  1063.           .
  1064.  
  1065.  
  1066. ────────────────────────────────────────────────────────────────────────────
  1067. Int 21H                                                                [1.0]
  1068. Function 0BH (11)
  1069. Check input status
  1070. ────────────────────────────────────────────────────────────────────────────
  1071.  
  1072.   [1] Checks whether a character is available from the keyboard.
  1073.  
  1074.   [2.0+] Checks whether a character is available from the standard input
  1075.   device. Input can be redirected.
  1076.  
  1077. Call with:
  1078.  
  1079.   AH            = 0BH
  1080.  
  1081. Returns:
  1082.  
  1083.   AL            = 00H if no character is available
  1084.                   FFH if at least one character is available
  1085.  
  1086. Notes:
  1087.  
  1088.   ■ [1] If a Ctrl-C is detected, an Int 23H is executed.
  1089.  
  1090.   ■ [2.0+] If the standard input is not redirected, and a Ctrl-C is detected
  1091.     at the console, an Int 23H is executed. If the standard input is
  1092.     redirected, a Ctrl-C is detected at the console, and BREAK is ON, an Int
  1093.     23H is executed.
  1094.  
  1095.   ■ If a character is waiting, this function will continue to return a true
  1096.     flag until the character is consumed with a call to Int 21H Function
  1097.     01H, 06H, 07H, 08H, 0AH, or 3FH.
  1098.  
  1099.   ■ This function is equivalent to IOCTL Int 21H Function 44H Subfunction
  1100.     06H.
  1101.  
  1102. Example:
  1103.  
  1104.   Test whether a character is available from the standard input.
  1105.  
  1106.           .
  1107.           .
  1108.           .
  1109.           mov     ah,0bh          ; function number
  1110.           int     21h             ; transfer to MS-DOS
  1111.           or      al,al           ; character waiting?
  1112.           jnz     ready           ; jump if char ready
  1113.           .
  1114.           .
  1115.           .
  1116.  
  1117.  
  1118. ────────────────────────────────────────────────────────────────────────────
  1119. Int 21H                                                                [1.0]
  1120. Function 0CH (12)
  1121. Flush input buffer and then input
  1122. ────────────────────────────────────────────────────────────────────────────
  1123.  
  1124.   [1] Clears the type-ahead buffer and then invokes one of the keyboard
  1125.   input functions.
  1126.  
  1127.   [2.0+] Clears the standard input buffer and then invokes one of the
  1128.   character input functions. Input can be redirected.
  1129.  
  1130. Call with:
  1131.  
  1132.   AH            = 0CH
  1133.   AL            = number of input function to be invoked after resetting
  1134.                   buffer (must be 01H, 06H, 07H, 08H, or 0AH)
  1135.  
  1136.   (if AL = 0AH)
  1137.  
  1138.   DS:DX         = segment:offset of input buffer
  1139.  
  1140. Returns:
  1141.  
  1142.   (if called with AL = 01H, 06H, 07H, or 08H)
  1143.  
  1144.   AL            = 8-bit input data
  1145.  
  1146.   (if called with AL = 0AH)
  1147.  
  1148.   Nothing (data placed in buffer)
  1149.  
  1150. Notes:
  1151.  
  1152.   ■ The function exists to allow a program to defeat MS-DOS's type-ahead
  1153.     feature. It discards any characters that are waiting in MS-DOS's
  1154.     internal type-ahead buffer, forcing the specified input function to wait
  1155.     for a character (usually a keyboard entry) that is truly entered after
  1156.     the program's request.
  1157.  
  1158.   ■ The presence or absence of Ctrl-C checking during execution of this
  1159.     function depends on the function number placed in register AL.
  1160.  
  1161.   ■ A function number in AL other than 01H, 06H, 07H, 08H, or 0AH simply
  1162.     flushes the input buffer and returns control to the calling program.
  1163.  
  1164. Example:
  1165.  
  1166.   Clear the type-ahead buffer, then wait for a character to be entered,
  1167.   echoing it and then returning it in AL. Store the character in the
  1168.   variable char.
  1169.  
  1170.   char    db      0
  1171.           .
  1172.           .
  1173.           .
  1174.           mov     ah,0ch          ; function number
  1175.           mov     al,1            ; subfunction = input char
  1176.           int     21h             ; transfer to MS-DOS
  1177.           mov     char,al         ; save character
  1178.           .
  1179.           .
  1180.           .
  1181.  
  1182.  
  1183. ────────────────────────────────────────────────────────────────────────────
  1184. Int 21H                                                                [1.0]
  1185. Function 0DH (13)
  1186. Disk reset
  1187. ────────────────────────────────────────────────────────────────────────────
  1188.  
  1189.   Flushes all file buffers. All data that has been logically written by user
  1190.   programs, but has been temporarily buffered within MS-DOS, is physically
  1191.   written to the disk.
  1192.  
  1193. Call with:
  1194.  
  1195.   AH            = 0DH
  1196.  
  1197. Returns:
  1198.  
  1199.   Nothing
  1200.  
  1201. Notes:
  1202.  
  1203.   ■ This function does not update the disk directory for any files that are
  1204.     still open. If your program fails to properly close all files before the
  1205.     disk is removed, and files have changed size, the data forced out to the
  1206.     disk by this function may still be inaccessible because the directory
  1207.     entries will not be correct.
  1208.  
  1209.   ■ [3.3+] Int 21H Function 68H (Commit File) should be used in preference
  1210.     to this function, since it also updates the disk directory.
  1211.  
  1212. Example:
  1213.  
  1214.   Flush all MS-DOS internal disk buffers.
  1215.  
  1216.           .
  1217.           .
  1218.           .
  1219.           mov     ah,0dh          ; function number
  1220.           int     21h             ; transfer to MS-DOS
  1221.           .
  1222.           .
  1223.           .
  1224.  
  1225.  
  1226. ────────────────────────────────────────────────────────────────────────────
  1227. Int 21H                                                                [1.0]
  1228. Function 0EH (14)
  1229. Select disk
  1230. ────────────────────────────────────────────────────────────────────────────
  1231.  
  1232.   Selects the specified drive to be the current, or default, disk drive and
  1233.   returns the total number of logical drives in the system.
  1234.  
  1235. Call with:
  1236.  
  1237.   AH            = 0EH
  1238.   DL            = drive code (0 = A, 1 = B, etc.)
  1239.  
  1240. Returns:
  1241.  
  1242.   AL            = number of logical drives in system
  1243.  
  1244. Notes:
  1245.  
  1246.   ■ [1] 16 drive designators (0 through 0FH) are available.
  1247.  
  1248.   ■ [2] 63 drive designators (0 through 3FH) are available.
  1249.  
  1250.   ■ [3.0+] 26 drive designators (0 through 19H
  1251.  are available.
  1252.  
  1253.   ■ To preserve upward compatibility, new applications should limit
  1254.     themselves to the drive letters A─Z (0 = A, 1 = B, etc.).
  1255.  
  1256.   ■ Logical drives means the total number of block devices: floppy disks,
  1257.     simulated disk drives (RAMdisks), and hard-disk drives. A single
  1258.     physical hard-disk drive is frequently partitioned into two or more
  1259.     logical drives.
  1260.  
  1261.   ■ [1] [2] In single-drive IBM PC─compatible systems, the value 2 is
  1262.     returned in AL, because PC-DOS supports two logical drives (A: and B:)
  1263.     on the single physical floppy-disk drive. The actual number of physical
  1264.     drives in the system can be determined with ROM BIOS Int 11H.
  1265.  
  1266.   ■ [3.0+] The value returned in AL is either 5 or the drive code
  1267.     corresponding to the LASTDRIVE entry (if any) in CONFIG.SYS, whichever
  1268.     is greater.
  1269.  
  1270. Example:
  1271.  
  1272.   Make drive B the current (default) disk drive. Save the total number of
  1273.   logical drives in the system in the variable drives.
  1274.  
  1275.   drives  db      0
  1276.           .
  1277.           .
  1278.           .
  1279.           mov     ah,0eh          ; function number
  1280.           mov     dl,1            ; drive 1 = B
  1281.           int     21h             ; transfer to MS-DOS
  1282.           mov     drives,al       ; save total drives
  1283.           .
  1284.           .
  1285.           .
  1286.  
  1287.  
  1288. ────────────────────────────────────────────────────────────────────────────
  1289. Int 21H                                                                [1.0]
  1290. Function 0FH (15)
  1291. Open file
  1292. ────────────────────────────────────────────────────────────────────────────
  1293.  
  1294.   Opens a file and makes it available for subsequent read/write operations.
  1295.  
  1296. Call with:
  1297.  
  1298.   AH            = 0FH
  1299.   DS:DX         = segment:offset of file control block
  1300.  
  1301. Returns:
  1302.  
  1303.   If function successful (file found)
  1304.  
  1305.   AL            = 00H
  1306.  
  1307.   and FCB filled in by MS-DOS as follows:
  1308.  
  1309.   drive field (offset 00H)              = 1 for drive A, 2 for drive B, etc.
  1310.   current block field (offset 0CH)      = 00H
  1311.   record size field (offset 0EH)        = 0080H
  1312.   [2.0+] size field (offset 10H)        = file size from directory
  1313.   [2.0+] date field (offset 14H)        = date stamp from directory
  1314.   [2.0+] time field (offset 16H)        = time stamp from directory
  1315.  
  1316.   If function unsuccessful (file not found)
  1317.  
  1318.   AL            = 0FFH
  1319.  
  1320. Notes:
  1321.  
  1322.   ■ If your program is going to use a record size other than 128 bytes, it
  1323.     should set the record-size field at FCB offset 0EH after the file is
  1324.     successfully opened and before any other disk operation.
  1325.  
  1326.   ■ If random access is to be performed, the calling program must also set
  1327.     the FCB relative-record field (offset 21H) after successfully opening
  1328.     the file.
  1329.  
  1330.   ■ For format of directory time and date, see Int 21H Function 57H.
  1331.  
  1332.   ■ [2.0+] Int 21H Function 3DH, which allows full access to the
  1333.     hierarchical directory structure, should be used in preference to this
  1334.     function.
  1335.  
  1336.   ■ [3.0+] If the program is running on a network, the file is opened for
  1337.     read/write access in compatibility sharing mode.
  1338.  
  1339. Example:
  1340.  
  1341.   Attempt to open the file named QUACK.DAT on the default disk drive.
  1342.  
  1343.   myfcb   db      0               ; drive = default
  1344.           db      'QUACK   '      ; filename, 8 characters
  1345.           db      'DAT'           ; extension, 3 characters
  1346.           db      25 dup (0)      ; remainder of FCB
  1347.           .
  1348.           .
  1349.           .
  1350.           mov     ah,0fh          ; function number
  1351.           mov     dx,seg myfcb    ; address of FCB
  1352.           mov     ds,dx
  1353.           mov     dx,offset myfcb
  1354.           int     21h             ; transfer to MS-DOS
  1355.           or      al,al           ; check status
  1356.           jnz     error           ; jump if open failed
  1357.           .
  1358.           .
  1359.           .
  1360.  
  1361.  
  1362. ────────────────────────────────────────────────────────────────────────────
  1363. Int 21H                                                                [1.0]
  1364. Function 10H (16)
  1365. Close file
  1366. ────────────────────────────────────────────────────────────────────────────
  1367.  
  1368.   Closes a file, flushes all MS-DOS internal disk buffers associated with
  1369.   the file to disk, and updates the disk directory if the file has been
  1370.   modified or extended.
  1371.  
  1372. Call with:
  1373.  
  1374.   AH            = 10H
  1375.   DS:DX         = segment:offset of file control block
  1376.  
  1377. Returns:
  1378.  
  1379.   If function successful (directory update successful)
  1380.  
  1381.   AL            = 00H
  1382.  
  1383.   If function unsuccessful (file not found in directory)
  1384.  
  1385.   AL            = FFH
  1386.  
  1387. Notes:
  1388.  
  1389.   ■ [1] [2] MS-DOS versions 1 and 2 do not reliably detect a floppy-disk
  1390.     change, and an error can occur if the user changes disks while a file is
  1391.     still open on that drive. In the worst case, the directory and file
  1392.     allocation table of the newly inserted disk can be damaged or destroyed.
  1393.  
  1394.   ■ [2.0+] Int 21H Function 3EH should be used in preference to this
  1395.     function.
  1396.  
  1397. Example:
  1398.  
  1399.   Close the file that was previously opened using the file control block
  1400.   named myfcb.
  1401.  
  1402.   myfcb   db      0               ; drive = default
  1403.           db      'QUACK   '      ; filename, 8 characters
  1404.           db      'DAT'           ; extension, 3 characters
  1405.           db      25 dup (0)      ; remainder of FCB
  1406.           .
  1407.           .
  1408.           .
  1409.           mov     ah,10h          ; function number
  1410.           mov     dx,seg myfcb    ; address of FCB
  1411.           mov     ds,dx
  1412.           mov     dx,offset myfcb
  1413.           int     21h             ; transfer to MS-DOS
  1414.           or      al,al           ; check status
  1415.           jnz     error           ; jump if close failed
  1416.           .
  1417.           .
  1418.           .
  1419.  
  1420.  
  1421. ────────────────────────────────────────────────────────────────────────────
  1422. Int 21H                                                                [1.0]
  1423. Function 11H (17)
  1424. Find first file
  1425. ────────────────────────────────────────────────────────────────────────────
  1426.  
  1427.   Searches the current directory on the designated drive for a matching
  1428.   filename.
  1429.  
  1430. Call with:
  1431.  
  1432.   AH            = 11H
  1433.   DS:DX         = segment:offset of file control block
  1434.  
  1435. Returns:
  1436.  
  1437.   If function successful (matching filename found)
  1438.  
  1439.   AL            = 00H
  1440.  
  1441.   and buffer at current disk transfer area (DTA) address filled in as an
  1442.   unopened normal FCB or extended FCB, depending on which type of FCB was
  1443.   input to function
  1444.  
  1445.   If function unsuccessful (no matching filename found)
  1446.  
  1447.   AL            = FFH
  1448.  
  1449. Notes:
  1450.  
  1451.   ■ Use Int 21H Function 1AH to set the DTA to point to a buffer of
  1452.     adequate size before calling this function.
  1453.  
  1454.   ■ The wildcard character ? is allowed in the filename in all versions of
  1455.     MS-DOS. In versions 3.0 and later, the wildcard character * may also be
  1456.     used in a filename. If ? or * is used, this function returns the first
  1457.     matching filename.
  1458.  
  1459.   ■ An extended FCB must be used to search for files that have the system,
  1460.     hidden, read-only, directory, or volume-label attributes.
  1461.  
  1462.   ■ If an extended FCB is used, its attribute byte determines the type of
  1463.     search that will be performed. If the attribute byte contains 00H, only
  1464.     ordinary files are found. If the volume-label attribute bit is set, only
  1465.     volume labels will be returned (if any are present). If any other
  1466.     attribute or combination of attributes is set (such as hidden, system,
  1467.     or read-only), those files and all ordinary files will be matched.
  1468.  
  1469.   ■ [2.0+] Int 21H Function 4EH, which allows full access to the
  1470.     hierarchical directory structure, should be used in preference to this
  1471.     function.
  1472.  
  1473. Example:
  1474.  
  1475.   Search for the first file with the extension .COM in the current
  1476.   directory.
  1477.  
  1478.   buff    db      37 dup (0)      ; receives search result
  1479.  
  1480.   myfcb   db      0               ; drive = default
  1481.           db      '????????'      ; wildcard filename
  1482.           db      'COM'           ; extension = COM
  1483.           db      25 dup (0)      ; remainder of FCB
  1484.           .
  1485.           .
  1486.           .
  1487.                                   ; set DTA address
  1488.           mov     ah,1ah          ; function number
  1489.           mov     dx,seg buff     ; buffer address
  1490.           mov     ds,dx
  1491.           mov     dx,offset buff
  1492.           int     21h             ; transfer to MS-DOS
  1493.  
  1494.                                   ; search for first match
  1495.           mov     ah,11h          ; function number
  1496.           mov     dx,seg myfcb    ; address of FCB
  1497.           mov     ds,dx
  1498.           mov     dx,offset myfcb
  1499.           int     21h             ; transfer to MS-DOS
  1500.           or      al,al           ; check status
  1501.           jnz     error           ; jump if no match
  1502.           .
  1503.           .
  1504.           .
  1505.  
  1506.  
  1507. ────────────────────────────────────────────────────────────────────────────
  1508. Int 21H                                                                [1.0]
  1509. Function 12H (18)
  1510. Find next file
  1511. ────────────────────────────────────────────────────────────────────────────
  1512.  
  1513.   Given that a previous call to Int 21H Function 11H has been successful,
  1514.   returns the next matching filename (if any).
  1515.  
  1516. Call with:
  1517.  
  1518.   AH            = 12H
  1519.   DS:DX         = segment:offset of file control block
  1520.  
  1521. Returns:
  1522.  
  1523.   If function successful (matching filename found)
  1524.  
  1525.   AL            = 00H
  1526.  
  1527.   and buffer at current disk transfer area (DTA) address set up as an
  1528.   unopened normal FCB or extended FCB, depending on which type of FCB was
  1529.   originally input to Int 21H Function 11H
  1530.  
  1531.   If function unsuccessful (no more matching filenames found)
  1532.  
  1533.   AL            = FFH
  1534.  
  1535. Notes:
  1536.  
  1537.   ■ This function assumes that the FCB used as input has been properly
  1538.     initialized by a previous call to Int 21H Function 11H (and possible
  1539.     subsequent calls to Int 21H Function 12H) and that the filename or
  1540.     extension being searched for contained at least one wildcard character.
  1541.  
  1542.   ■ As with Int 21H Function 11H, it is important to use Int 21H Function
  1543.     1AH to set the DTA to a buffer of adequate size before calling this
  1544.     function.
  1545.  
  1546.   ■ [2.0+] Int 21H Functions 4EH and 4FH, which allow full access to the
  1547.     hierarchical directory structure, should be used in preference to this
  1548.     function.
  1549.  
  1550. Example:
  1551.  
  1552.   Assuming a previous successful call to function 11H, search for the next
  1553.   file with the extension .COM in the current directory. If the DTA has not
  1554.   been changed since the previous search, another call to Function 1AH is
  1555.   not necessary.
  1556.  
  1557.   buff    db      37 dup (0)      ; receives search result
  1558.  
  1559.   my_fcb  db      0               ; drive = default
  1560.           db      '????????'      ; wildcard filename
  1561.           db      'COM'           ; extension = COM
  1562.           db      25 dup (0)      ; remainder of FCB
  1563.           .
  1564.           .
  1565.           .
  1566.                                   ; set DTA address
  1567.           mov     ah,1ah          ; function number
  1568.           mov     dx,seg buff     ; buffer address
  1569.           mov     ds,dx
  1570.           mov     dx,offset buff
  1571.           int     21h             ; transfer to MS-DOS
  1572.  
  1573.                                   ; search for next match
  1574.           mov     ah,12h          ; function number
  1575.           mov     dx,seg myfcb    ; address of FCB
  1576.           mov     ds,dx
  1577.           mov     dx,offset myfcb
  1578.           int     21h             ; transfer to MS-DOS
  1579.           or      al,al           ; check status
  1580.           jnz     error           ; jump if no match
  1581.           .
  1582.           .
  1583.           .
  1584.  
  1585.  
  1586. ────────────────────────────────────────────────────────────────────────────
  1587. Int 21H                                                                [1.0]
  1588. Function 13H (19)
  1589. Delete file
  1590. ────────────────────────────────────────────────────────────────────────────
  1591.  
  1592.   Deletes all matching files from the current directory on the default or
  1593.   specified disk drive.
  1594.  
  1595. Call with:
  1596.  
  1597.   AH            = 13H
  1598.   DS:DX         = segment:offset of file control block
  1599.  
  1600. Returns:
  1601.  
  1602.   If function successful (file or files deleted)
  1603.  
  1604.   AL            = 00H
  1605.  
  1606.   If function unsuccessful (no matching files were found, or at least one
  1607.   matching file was read-only)
  1608.  
  1609.   AL            = FFH
  1610.  
  1611. Notes:
  1612.  
  1613.   ■ The wildcard character ? is allowed in the filename; if ? is present and
  1614.     there is more than one matching filename, all matching files will be
  1615.     deleted.
  1616.  
  1617.   ■ [2.0+] Int 21H Function 41H, which allows full access to the
  1618.     hierarchical directory structure, should be used in preference to this
  1619.     function.
  1620.  
  1621.   ■ [3.0+] If the program is running on a network, the user must have Create
  1622.     rights to the directory containing the file to be deleted.
  1623.  
  1624. Example:
  1625.  
  1626.   Delete the file MYFILE.DAT from the current disk drive and directory.
  1627.  
  1628.   myfcb   db      0               ; drive = default
  1629.           db      'MYFILE  '      ; filename, 8 chars
  1630.           db      'DAT'           ; extension, 3 chars
  1631.           db      25 dup (0)      ; remainder of FCB
  1632.           .
  1633.           .
  1634.           .
  1635.           mov     ah,13h          ; function number
  1636.           mov     dx,seg myfcb    ; address of FCB
  1637.           mov     ds,dx
  1638.           mov     dx,offset myfcb
  1639.           int     21h             ; transfer to MS-DOS
  1640.           or      al,al           ; check status
  1641.           jnz     error           ; jump, delete failed
  1642.           .
  1643.           .
  1644.           .
  1645.  
  1646.  
  1647. ────────────────────────────────────────────────────────────────────────────
  1648. Int 21H                                                                [1.0]
  1649. Function 14H (20)
  1650. Sequential read
  1651. ────────────────────────────────────────────────────────────────────────────
  1652.  
  1653.   Reads the next sequential block of data from a file, then increments the
  1654.   file pointer appropriately.
  1655.  
  1656. Call with:
  1657.  
  1658.   AH            = 14H
  1659.   DS:DX         = segment:offset of previously opened file control block
  1660.  
  1661. Returns:
  1662.  
  1663.   AL            = 00H       if read successful
  1664.                   01H       if end of file
  1665.                   02H       if segment wrap
  1666.                   03H       if partial record read at end of file
  1667.  
  1668. Notes:
  1669.  
  1670.   ■ The record is read into memory at the current disk transfer area (DTA)
  1671.     address, specified by the most recent call to Int 21H Function 1AH. If
  1672.     the size of the record and the location of the buffer are such that a
  1673.     segment overflow or wraparound would occur, the function fails with a
  1674.     return code of 02H.
  1675.  
  1676.   ■ The number of bytes of data to be read is specified by the record-size
  1677.     field (offset 0EH) of the file control block (FCB).
  1678.  
  1679.   ■ The file location of the data that will be read is specified by the
  1680.     combination of the current block field (offset 0CH) and current record
  1681.     field (offset 20H) of the file control block (FCB). These fields are
  1682.     also automatically incremented by this function.
  1683.  
  1684.   ■ If a partial record is read at the end of file, it is padded to the
  1685.     requested record length with zeros.
  1686.  
  1687.   ■ [3.0+] If the program is running on a network, the user must have Read
  1688.     access rights to the directory containing the file to be read.
  1689.  
  1690. Example:
  1691.  
  1692.   Read 1024 bytes of data from the file specified by the previously opened
  1693.   file control block myfcb.
  1694.  
  1695.   myfcb   db      0               ; drive = default
  1696.           db      'QUACK   '      ; filename, 8 chars
  1697.           db      'DAT'           ; extension, 3 chars
  1698.           db      25 dup (0)      ; remainder of FCB
  1699.           .
  1700.           .
  1701.           .
  1702.           mov     ah,14h          ; function number
  1703.           mov     dx,seg myfcb    ; address of FCB
  1704.           mov     ds,dx
  1705.           mov     dx,offset myfcb
  1706.                                   ; set record size
  1707.           mov     word ptr myfcb+0eH,1024
  1708.           int     21h             ; transfer to MS-DOS
  1709.           or      al,al           ; check status
  1710.           jnz     error           ; jump if read failed
  1711.           .
  1712.           .
  1713.           .
  1714.  
  1715.  
  1716. ────────────────────────────────────────────────────────────────────────────
  1717. Int 21H                                                                [1.0]
  1718. Function 15H (21)
  1719. Sequential write
  1720. ────────────────────────────────────────────────────────────────────────────
  1721.  
  1722.   Writes the next sequential block of data into a file, then increments the
  1723.   file pointer appropriately.
  1724.  
  1725. Call with:
  1726.  
  1727.   AH            = 15H
  1728.   DS:DX         = segment:offset of previously opened file control block
  1729.  
  1730. Returns:
  1731.  
  1732.   AL            = 00H       if write successful
  1733.                   01H       if disk is full
  1734.                   02H       if segment wrap
  1735.  
  1736. Notes:
  1737.  
  1738.   ■ The record is written (logically, not necessarily physically) to the
  1739.     disk from memory at the current disk transfer area (DTA) address,
  1740.     specified by the most recent call to Int 21H Function 1AH. If the size
  1741.     of the record and the location of the buffer are such that a segment
  1742.     overflow or wraparound would occur, the function fails with a return
  1743.     code of 02H.
  1744.  
  1745.   ■ The number of bytes of data to be written is specified by the
  1746.     record-size field (offset 0EH) of the file control block (FCB).
  1747.  
  1748.   ■ The file location of the data that will be written is specified by the
  1749.     combination of the current block field (offset 0CH) and current record
  1750.     field (offset 20H) of the file control block (FCB). These fields are
  1751.     also automatically incremented by this function.
  1752.  
  1753.   ■ [3.0+] If the program is running on a network, the user must have Write
  1754.     access rights to the directory containing the file to be written.
  1755.  
  1756. Example:
  1757.  
  1758.   Write 1024 bytes of data to the file specified by the previously opened
  1759.   file control block myfcb.
  1760.  
  1761.   myfcb   db      0               ; drive = default
  1762.           db      'QUACK   '      ; filename, 8 chars
  1763.           db      'DAT'           ; extension, 3 chars
  1764.           db      25 dup (0)      ; remainder of FCB
  1765.           .
  1766.           .
  1767.           .
  1768.           mov     ah,15h          ; function number
  1769.           mov     dx,seg myfcb    ; address of FCB
  1770.           mov     ds,dx
  1771.           mov     dx,offset myfcb
  1772.                                   ; set record size
  1773.           mov     word ptr myfcb+0eh,1024
  1774.           int     21h             ; transfer to MS-DOS
  1775.           or      al,al           ; check status
  1776.           jnz     error           ; jump if write failed
  1777.           .
  1778.           .
  1779.           .
  1780.  
  1781.  
  1782. ────────────────────────────────────────────────────────────────────────────
  1783. Int 21H                                                                [1.0]
  1784. Function 16H (22)
  1785. Create file
  1786. ────────────────────────────────────────────────────────────────────────────
  1787.  
  1788.   Creates a new directory entry in the current directory or truncates any
  1789.   existing file with the same name to zero length. Opens the file for
  1790.   subsequent read/write operations.
  1791.  
  1792. Call with:
  1793.  
  1794.   AH            = 16H
  1795.   DS:DX         = segment:offset of unopened file control block
  1796.  
  1797. Returns:
  1798.  
  1799.   If function successful (file was created or truncated)
  1800.  
  1801.   AL            = 00H
  1802.  
  1803.   and FCB filled in by MS-DOS as follows:
  1804.  
  1805.   drive field (offset 00H)              = 1 for drive A, 2 for drive B, etc.
  1806.   current block field (offset 0CH)      = 00H
  1807.   record size field (offset 0EH)        = 0080H
  1808.   [2.0+] size field (offset 10H)        = file size from directory
  1809.   [2.0+] date field (offset 14H)        = date stamp from directory
  1810.   [2.0+] time field (offset 16H)        = time stamp from directory
  1811.  
  1812.   If function unsuccessful (directory full)
  1813.  
  1814.   AL            = FFH
  1815.  
  1816. Notes:
  1817.  
  1818.   ■ Since an existing file with the specified name is truncated to zero
  1819.     length (i.e., all data in that file is irretrievably lost), this
  1820.     function must be used with caution.
  1821.  
  1822.   ■ If this function is called with an extended file control block (FCB),
  1823.     the new file may be assigned a special attribute, such as hidden or
  1824.     system, during its creation by setting the appropriate bit in the
  1825.     extended FCB's attribute byte.
  1826.  
  1827.   ■ Since this function also opens the file, a subsequent call to Int 21H
  1828.     Function 0FH is not required.
  1829.  
  1830.   ■ For format of directory time and date, see Int 21H Function 57H.
  1831.  
  1832.   ■ [2.0+] Int 21H Functions 3CH, 5AH, 5BH, and 6CH, which provide full
  1833.     access to the hierarchical directory structure, should be used in
  1834.     preference to this function.
  1835.  
  1836.   ■ [3.0+] If the program is running on a network, the user must have Create
  1837.     rights to the directory that will contain the new file.
  1838.  
  1839. Example:
  1840.  
  1841.   Create a file in the current directory using the name in the file control
  1842.   block myfcb.
  1843.  
  1844.   myfcb   db      0               ; drive = default
  1845.           db      'QUACK   '      ; filename, 8 chars
  1846.           db      'DAT'           ; extension, 3 chars
  1847.           db      25 dup (0)      ; remainder of FCB
  1848.           .
  1849.           .
  1850.           .
  1851.           mov     ah,16h          ; function number
  1852.           mov     dx,seg myfcb    ; address of FCB
  1853.           mov     ds,dx
  1854.           mov     dx,offset myfcb
  1855.           int     21h             ; transfer to MS-DOS
  1856.           or      al,al           ; check status
  1857.           jnz     error           ; jump if create failed
  1858.           .
  1859.           .
  1860.           .
  1861.  
  1862.  
  1863. ────────────────────────────────────────────────────────────────────────────
  1864. Int 21H                                                                [1.0]
  1865. Function 17H (23)
  1866. Rename file
  1867. ────────────────────────────────────────────────────────────────────────────
  1868.  
  1869.   Alters the name of all matching files in the current directory on the disk
  1870.   in the specified drive.
  1871.  
  1872. Call with:
  1873.  
  1874.   AH            = 17H
  1875.   DS:DX         = segment:offset of "special" file control block
  1876.  
  1877. Returns:
  1878.  
  1879.   If function successful (one or more files renamed)
  1880.  
  1881.   AL            = 00H
  1882.  
  1883.   If function unsuccessful (no matching files, or new filename matched an
  1884.   existing file)
  1885.  
  1886.   AL            = FFH
  1887.  
  1888. Notes:
  1889.  
  1890.   ■ The special file control block has a drive code, filename, and extension
  1891.     in the usual position (bytes 0 through 0BH) and a second filename
  1892.     starting 6 bytes after the first (offset 11H).
  1893.  
  1894.   ■ The ? wildcard character can be used in the first filename. Every file
  1895.     matching the first file specification will be renamed to match the
  1896.     second file specification.
  1897.  
  1898.   ■ If the second file specification contains any ? wildcard characters, the
  1899.     corresponding letters in the first filename are left unchanged.
  1900.  
  1901.   ■ The function terminates if the new name to be assigned to a file matches
  1902.     that of an existing file.
  1903.  
  1904.   ■ [2.0+] An extended FCB can be used with this function to rename a
  1905.     directory.
  1906.  
  1907.   ■ [2.0+] Int 21H Function 56H, which allows full access to the
  1908.     hierarchical directory structure, should be used in preference to this
  1909.     function.
  1910.  
  1911. Example:
  1912.  
  1913.   Rename the file OLDNAME.DAT to NEWNAME.DAT.
  1914.  
  1915.   myfcb   db      0               ; drive = default
  1916.           db      'OLDNAME '      ; old file name, 8 chars
  1917.           db      'DAT'           ; old extension, 3 chars
  1918.           db      6 dup (0)       ; reserved area
  1919.           db      'NEWNAME '      ; new file name, 8 chars
  1920.           db      'DAT'           ; new extension, 3 chars
  1921.           db      14 dup (0)      ; reserved area
  1922.           .
  1923.           .
  1924.           .
  1925.           mov     ah,17h          ; function number
  1926.           mov     dx,seg myfcb    ; address of FCB
  1927.           mov     ds,dx
  1928.           mov     dx,offset myfcb
  1929.           int     21h             ; transfer to MS-DOS
  1930.           or      al,al           ; check status
  1931.           jnz     error           ; jump if rename failed
  1932.           .
  1933.           .
  1934.           .
  1935.  
  1936.  
  1937. ────────────────────────────────────────────────────────────────────────────
  1938. Int 21H
  1939. Function 18H (24)
  1940. Reserved
  1941. ────────────────────────────────────────────────────────────────────────────
  1942.  
  1943.  
  1944. ────────────────────────────────────────────────────────────────────────────
  1945. Int 21H                                                                [1.0]
  1946. Function 19H (25)
  1947. Get current disk
  1948. ────────────────────────────────────────────────────────────────────────────
  1949.  
  1950.   Returns the drive code of the current, or default, disk drive.
  1951.  
  1952. Call with:
  1953.  
  1954.   AH            = 19H
  1955.  
  1956. Returns:
  1957.  
  1958.   AL            = drive code (0 = A, 1 = B, etc.)
  1959.  
  1960. Notes:
  1961.  
  1962.   ■ To set the default drive, use Int 21H Function 0EH.
  1963.  
  1964.   ■ Some other Int 21H functions use drive codes beginning at 1 (that is,
  1965.     1 = A, 2 = B, etc.) and reserve drive code zero for the default drive.
  1966.  
  1967. Example:
  1968.  
  1969.   Get the current disk drive and save the code in the variable cdrive.
  1970.  
  1971.   cdrive  db      0               ; current drive code
  1972.           .
  1973.           .
  1974.           .
  1975.           mov     ah,19h          ; function number
  1976.           int     21h             ; transfer to MS-DOS
  1977.           mov     cdrive,al       ; save drive code
  1978.           .
  1979.           .
  1980.           .
  1981.  
  1982.  
  1983. ────────────────────────────────────────────────────────────────────────────
  1984. Int 21H                                                                [1.0]
  1985. Function 1AH (26)
  1986. Set DTA address
  1987. ────────────────────────────────────────────────────────────────────────────
  1988.  
  1989.   Specifies the address of the disk transfer area (DTA) to be used for
  1990.   subsequent FCB-related function calls.
  1991.  
  1992. Call with:
  1993.  
  1994.   AH            = 1AH
  1995.   DS:DX         = segment:offset of disk transfer area
  1996.  
  1997. Returns:
  1998.  
  1999.   Nothing
  2000.  
  2001. Notes:
  2002.  
  2003.   ■ If this function is never called by the program, the DTA defaults to a
  2004.     128-byte buffer at offset 0080H in the program segment prefix.
  2005.  
  2006.   ■ In general, it is the programmer's responsibility to ensure that the
  2007.     buffer area specified is large enough for any disk operation that will
  2008.     use it. The only exception to this is that MS-DOS will detect and abort
  2009.     disk transfers that would cause a segment wrap.
  2010.  
  2011.   ■ Int 21H Function 2FH can be used to determine the current disk transfer
  2012.     address.
  2013.  
  2014.   ■ The only handle-type operations that rely on the DTA address are the
  2015.     directory search functions, Int 21H Functions 4EH and 4FH.
  2016.  
  2017. Example:
  2018.  
  2019.   Set the current disk transfer area address to the buffer labeled buff.
  2020.  
  2021.   buff    db      128 dup (?)
  2022.           .
  2023.           .
  2024.           .
  2025.           mov     ah,1ah          ; function number
  2026.           mov     dx,seg buff     ; address of disk
  2027.           mov     ds,dx           ; transfer area
  2028.           mov     dx,offset buff
  2029.           int     21h             ; transfer to MS-DOS
  2030.           .
  2031.           .
  2032.           .
  2033.  
  2034.  
  2035. ────────────────────────────────────────────────────────────────────────────
  2036. Int 21H                                                                [1.0]
  2037. Function 1BH (27)
  2038. Get default drive data
  2039. ────────────────────────────────────────────────────────────────────────────
  2040.  
  2041.   Obtains selected information about the default disk drive and a pointer to
  2042.   the media identification byte from its file allocation table.
  2043.  
  2044. Call with:
  2045.  
  2046.   AH            = 1BH
  2047.  
  2048. Returns:
  2049.  
  2050.   If function successful
  2051.  
  2052.   AL            = sectors per cluster
  2053.   DS:BX         = segment:offset of media ID byte
  2054.   CX            = size of physical sector (bytes)
  2055.   DX            = number of clusters for default drive
  2056.  
  2057.   If function unsuccessful (invalid drive or critical error)
  2058.  
  2059.   AL            = FFH
  2060.  
  2061. Notes:
  2062.  
  2063.   ■ The media ID byte has the following meanings:
  2064.  
  2065.   0F0H           3.5-inch double-sided, 18 sectors
  2066.                  or "other"
  2067.   0F8H           fixed disk
  2068.   0F9H           5.25-inch double-sided, 15 sectors
  2069.                  or 3.5-inch double-sided, 9 sectors
  2070.   0FCH           5.25-inch single-sided, 9 sectors
  2071.   0FDH           5.25-inch double-sided, 9 sectors
  2072.   0FEH           5.25-inch single-sided, 8 sectors
  2073.   0FFH           5.25-inch double-sided, 8 sectors
  2074.  
  2075.   ■ To obtain information about disks other than the one in the default
  2076.     drive, use Int 21H Function 1CH or 36H.
  2077.  
  2078.   ■ [1] The address returned in DS:BX points to a copy of the first sector
  2079.     of the actual FAT, with the media ID byte in the first byte.
  2080.  
  2081.   ■ [2.0+] The address returned in DS:BX points only to a copy of the media
  2082.     ID byte from the disk's FAT; the memory above that address cannot be
  2083.     assumed to contain the FAT or any other useful information. If direct
  2084.     access to the FAT is required, use Int 25H to read it into memory.
  2085.  
  2086. Example:
  2087.  
  2088.   Determine whether the current disk drive is fixed or removable.
  2089.  
  2090.           .
  2091.           .
  2092.           .
  2093.           mov     ah,1bh          ; function number
  2094.           int     21h             ; transfer to MS-DOS
  2095.  
  2096.                                   ; check media ID byte
  2097.           cmp     byte ptr [bx],0f8h
  2098.           je      fixed           ; jump if fixed disk
  2099.           jmp     floppy          ; else assume floppy
  2100.           .
  2101.           .
  2102.           .
  2103.  
  2104.  
  2105. ────────────────────────────────────────────────────────────────────────────
  2106. Int 21H                                                                [2.0]
  2107. Function 1CH (28)
  2108. Get drive data
  2109. ────────────────────────────────────────────────────────────────────────────
  2110.  
  2111.   Obtains allocation information about the specified disk drive and a
  2112.   pointer to the media identification byte from its file allocation table.
  2113.  
  2114. Call with:
  2115.  
  2116.   AH            = 1CH
  2117.   DL            = drive code (0 = default, 1 = A, etc.)
  2118.  
  2119. Returns:
  2120.  
  2121.   If function successful
  2122.  
  2123.   AL            = sectors per cluster
  2124.   DS:BX         = segment:offset of media ID byte
  2125.   CX            = size of physical sector (bytes)
  2126.   DX            = number of clusters for default or specified drive
  2127.  
  2128.   If function unsuccessful (invalid drive or critical error)
  2129.  
  2130.   AL            = FFH
  2131.  
  2132. Notes:
  2133.  
  2134.   ■ The media ID byte has the following meanings:
  2135.  
  2136.   0F0H           3.5-inch double-sided, 18 sectors
  2137.                  or "other"
  2138.   0F8H           fixed disk
  2139.   0F9H           5.25-inch double-sided, 15 sectors
  2140.                  or 3.5-inch double-sided, 9 sectors
  2141.   0FCH           5.25-inch single-sided, 9 sectors
  2142.   0FDH           5.25-inch double-sided, 9 sectors
  2143.   0FEH           5.25-inch single-sided, 8 sectors
  2144.   0FFH           5.25-inch double-sided, 8 sectors
  2145.  
  2146.   ■ In general, this call is identical to Int 21H Function 1BH, except for
  2147.     the ability to designate a specific disk drive. See also Int 21H
  2148.     Function 36H, which returns similar information.
  2149.  
  2150.   ■ [1] The address returned in DS:BX points to a copy of the first sector
  2151.     of the actual FAT, with the media ID byte in the first byte.
  2152.  
  2153.   ■ [2.0+] The address returned in DS:BX points only to a copy of the media
  2154.     ID byte from the disk's FAT; the memory above that address cannot be
  2155.     assumed to contain the FAT or any other useful information. If direct
  2156.     access to the FAT is required, use Int 25H to read it into memory.
  2157.  
  2158. Example:
  2159.  
  2160.   Determine whether disk drive C is fixed or removable.
  2161.  
  2162.           .
  2163.           .
  2164.           .
  2165.           mov     ah,1ch          ; function number
  2166.           mov     dl,3            ; drive code 3 = C
  2167.           int     21h             ; transfer to MS-DOS
  2168.  
  2169.                                   ; check media ID byte
  2170.           cmp     byte ptr ds:[bx],0f8h
  2171.           je      fixed           ; jump if fixed disk
  2172.           jmp     floppy          ; else assume floppy
  2173.           .
  2174.           .
  2175.           .
  2176.  
  2177.  
  2178. ────────────────────────────────────────────────────────────────────────────
  2179. Int 21H
  2180. Function 1DH (29)
  2181. Reserved
  2182. ────────────────────────────────────────────────────────────────────────────
  2183.  
  2184.  
  2185. ────────────────────────────────────────────────────────────────────────────
  2186. Int 21H
  2187. Function 1EH (30)
  2188. Reserved
  2189. ────────────────────────────────────────────────────────────────────────────
  2190.  
  2191.  
  2192. ────────────────────────────────────────────────────────────────────────────
  2193. Int 21H
  2194. Function 1FH (31)
  2195. Reserved
  2196. ────────────────────────────────────────────────────────────────────────────
  2197.  
  2198.  
  2199. ────────────────────────────────────────────────────────────────────────────
  2200. Int 21H
  2201. Function 20H (32)
  2202. Reserved
  2203. ────────────────────────────────────────────────────────────────────────────
  2204.  
  2205.  
  2206. ────────────────────────────────────────────────────────────────────────────
  2207. Int 21H                                                                [1.0]
  2208. Function 21H (33)
  2209. Random read
  2210. ────────────────────────────────────────────────────────────────────────────
  2211.  
  2212.   Reads a selected record from a file into memory.
  2213.  
  2214. Call with:
  2215.  
  2216.   AH            = 21H
  2217.   DS:DX         = segment:offset of previously opened file control block
  2218.  
  2219. Returns:
  2220.  
  2221.   AL            = 00H       if read successful
  2222.                   01H       if end of file
  2223.                   02H       if segment wrap, read canceled
  2224.                   03H       if partial record read at end of file
  2225.  
  2226. Notes:
  2227.  
  2228.   ■ The record is read into memory at the current disk transfer area
  2229.     address, specified by the most recent call to Int 21H Function 1AH. It
  2230.     is the programmer's responsibility to ensure that this area is large
  2231.     enough for any record that will be transferred. If the size and location
  2232.     of the buffer are such that a segment overflow or wraparound would
  2233.     occur, the function fails with a return code of 02H.
  2234.  
  2235.   ■ The file location of the data to be read is determined by the
  2236.     combination of the relative-record field (offset 21H) and the
  2237.     record-size field (offset 0EH) of the FCB. The default record size is
  2238.     128 bytes.
  2239.  
  2240.   ■ The current block field (offset 0CH) and current record field (offset
  2241.     20H) are updated to agree with the relative-record field as a side
  2242.     effect of the function.
  2243.  
  2244.   ■ The relative-record field of the FCB is not incremented by this
  2245.     function; it is the responsibility of the application to update the FCB
  2246.     appropriately if it wishes to read successive records. Compare with Int
  2247.     21H Function 27H, which can read multiple records with one function
  2248.     call and automatically increments the relative-record field.
  2249.  
  2250.   ■ If a partial record is read at end of file, it is padded to the
  2251.     requested record length with zeros.
  2252.  
  2253.   ■ [3.0+] If the program is running on a network, the user must have Read
  2254.     access rights to the directory containing the file to be read.
  2255.  
  2256. Example:
  2257.  
  2258.   Open the file MYFILE.DAT, set the record length to 1024 bytes, then read
  2259.   record number 4 from the file into the buffer named buff.
  2260.  
  2261.   myfcb   db      0               ; drive = default
  2262.           db      'MYFILE  '      ; filename, 8 chars
  2263.           db      'DAT'           ; extension, 3 chars
  2264.           db      25 dup (0)      ; remainder of FCB
  2265.  
  2266.   buff    db      1024 dup (?)    ; receives read data
  2267.           .
  2268.           .
  2269.           .
  2270.                                   ; open the file
  2271.           mov     ah,0fh          ; function number
  2272.           mov     dx,seg myfcb    ; address of FCB
  2273.           mov     ds,dx
  2274.           mov     dx,offset myfcb
  2275.           int     21h             ; transfer to MS-DOS
  2276.           or      al,al           ; check open status
  2277.           jnz     error           ; jump if no file
  2278.  
  2279.                                   ; set DTA address
  2280.           mov     ah,1ah          ; function number
  2281.           mov     dx,offset buff  ; read buffer address
  2282.           int     21h             ; transfer to MS-DOS
  2283.  
  2284.                                   ; set record size
  2285.           mov     word ptr myfcb+0eh,1024
  2286.  
  2287.                                   ; set record number
  2288.           mov     word ptr myfcb+21h,4
  2289.           mov     word ptr myfcb+23h,0
  2290.  
  2291.                                   ; read the record
  2292.           mov     ah,21h          ; function number
  2293.           mov     dx,offset myfcb ; address of FCB
  2294.           int     21h             ; transfer to MS-DOS
  2295.           or      al,al           ; check status
  2296.           jnz     error           ; jump if read failed
  2297.           .
  2298.           .
  2299.           .
  2300.  
  2301.  
  2302. ────────────────────────────────────────────────────────────────────────────
  2303. Int 21H                                                                [1.0]
  2304. Function 22H (34)
  2305. Random write
  2306. ────────────────────────────────────────────────────────────────────────────
  2307.  
  2308.   Writes data from memory into a selected record in a file.
  2309.  
  2310. Call with:
  2311.  
  2312.   AH            = 22H
  2313.   DS:DX         = segment:offset of previously opened file control block
  2314.  
  2315. Returns:
  2316.  
  2317.   AL            = 00H       if write successful
  2318.                   01H       if disk full
  2319.                   02H       if segment wrap, write canceled
  2320.  
  2321. Notes:
  2322.  
  2323.   ■ The record is written (logically, not necessarily physically) to the
  2324.     file from memory at the current disk transfer address, specified by the
  2325.     most recent call to Int 21H Function 1AH. If the size and location of
  2326.     the buffer are such that a segment overflow or wraparound would occur,
  2327.     the function fails with a return code of 02H.
  2328.  
  2329.   ■ The file location of the data to be written is determined by the
  2330.     combination of the relative-record field (offset 21H) and the
  2331.     record-size field (offset 0EH) of the FCB. The default record size is
  2332.     128 bytes.
  2333.  
  2334.   ■ The current block field (offset 0CH) and current record field (offset
  2335.     20H) are updated to agree with the relative-record field as a side
  2336.     effect of the function.
  2337.  
  2338.   ■ The relative-record field of the FCB is not incremented by this
  2339.     function; it is the responsibility of the application to update the FCB
  2340.     appropriately if it wishes to write successive records. Compare with Int
  2341.     21H Function 28H, which can write multiple records with one function
  2342.     call and automatically increments the relative-record field.
  2343.  
  2344.   ■ If a record is written beyond the current end of file, the space between
  2345.     the old end of file and the new record is allocated but not initialized.
  2346.  
  2347.   ■ [3.0+] If the program is running on a network, the user must have Write
  2348.     access rights to the directory containing the file to be written.
  2349.  
  2350. Example:
  2351.  
  2352.   Open the file MYFILE.DAT, set the record length to 1024 bytes, write
  2353.   record number 4 into the file from the buffer named buff, then close the
  2354.   file.
  2355.  
  2356.   myfcb   db      0               ; drive = default
  2357.           db      'MYFILE  '      ; filename, 8 chars
  2358.           db      'DAT'           ; extension, 3 chars
  2359.           db      25 dup (0)      ; remainder of FCB
  2360.  
  2361.   buff    db      1024 dup (?)    ; buffer for write
  2362.           .
  2363.           .
  2364.           .
  2365.                                   ; open the file
  2366.           mov     ah,0fh          ; function number
  2367.           mov     dx,seg myfcb    ; address of FCB
  2368.           mov     ds,dx
  2369.           mov     dx,offset myfcb
  2370.           int     21h             ; transfer to MS-DOS
  2371.           or      al,al           ; check status
  2372.           jnz     error           ; jump if no file
  2373.  
  2374.                                   ; set DTA address
  2375.           mov     dx,offset buff  ; buffer address
  2376.           mov     ah,1ah          ; function number
  2377.           int     21h             ; transfer to MS-DOS
  2378.  
  2379.                                   ; set record size
  2380.           mov     word ptr myfcb+0eh,1024
  2381.  
  2382.                                   ; set record number
  2383.           mov     word ptr myfcb+21h,4
  2384.           mov     word ptr myfcb+23h,0
  2385.  
  2386.                                   ; write the record
  2387.           mov     ah,22h          ; function number
  2388.           mov     dx,offset myfcb ; address of FCB
  2389.           int     21h             ; transfer to MS-DOS
  2390.           or      al,al           ; check status
  2391.           jnz     error           ; jump if write failed
  2392.  
  2393.                                   ; close the file
  2394.           mov     ah,10h          ; function number
  2395.           mov     dx,offset myfcb ; address of FCB
  2396.           int     21h             ; transfer to MS-DOS
  2397.           or      al,al           ; check status
  2398.           jnz     error           ; jump if close failed
  2399.           .
  2400.           .
  2401.           .
  2402.  
  2403.  
  2404. ────────────────────────────────────────────────────────────────────────────
  2405. Int 21H                                                                [1.0]
  2406. Function 23H (35)
  2407. Get file size
  2408. ────────────────────────────────────────────────────────────────────────────
  2409.  
  2410.   Searches for a matching file in the current directory; if one is found,
  2411.   updates the FCB with the file's size in terms of number of records.
  2412.  
  2413. Call with:
  2414.  
  2415.   AH            = 23H
  2416.   DS:DX         = segment:offset of unopened file control block
  2417.  
  2418. Returns:
  2419.  
  2420.   If function successful (matching file found)
  2421.  
  2422.   AL            = 00H
  2423.  
  2424.   and FCB relative-record field (offset 21H) set to the number of records in
  2425.   the file, rounded up if necessary to the next complete record
  2426.  
  2427.   If function unsuccessful (no matching file found)
  2428.  
  2429.   AL            = FFH
  2430.  
  2431. Notes:
  2432.  
  2433.   ■ An appropriate value must be placed in the FCB record-size field (offset
  2434.     0EH) before calling this function. There is no default record size for
  2435.     this function. Compare with the FCB-related open and create functions
  2436.     (Int 21H Functions 0FH and 16H), which initialize the FCB for a
  2437.     default record size of 128 bytes.
  2438.  
  2439.   ■ The record-size field can be set to 1 to find the size of the file in
  2440.     bytes.
  2441.  
  2442.   ■ Because record numbers are zero based, this function can be used to
  2443.     position the FCB's file pointer to the end of file.
  2444.  
  2445. Example:
  2446.  
  2447.   Determine the size in bytes of the file MYFILE.DAT and leave the result in
  2448.   registers DX:AX.
  2449.  
  2450.   myfcb   db      0               ; drive = default
  2451.           db      'MYFILE  '      ; filename, 8 chars
  2452.           db      'DAT'           ; extension, 3 chars
  2453.           db      25 dup (0)      ; remainder of FCB
  2454.           .
  2455.           .
  2456.           .
  2457.           mov     ah,23h          ; function number
  2458.           mov     dx,seg myfcb    ; address of FCB
  2459.           mov     ds,dx
  2460.           mov     dx,offset myfcb
  2461.                                   ; record size = 1 byte
  2462.           mov     word ptr myfcb+0eh,1
  2463.           int     21h             ; transfer to MS-DOS
  2464.           or      al,al           ; check status
  2465.           jnz     error           ; jump if no file
  2466.  
  2467.                                   ; get file size in bytes
  2468.           mov     ax,word ptr myfcb+21h
  2469.           mov     dx,word ptr myfcb+23h
  2470.           .
  2471.           .
  2472.           .
  2473.  
  2474.  
  2475. ────────────────────────────────────────────────────────────────────────────
  2476. Int 21H                                                                [1.0]
  2477. Function 24H (36)
  2478. Set relative record number
  2479. ────────────────────────────────────────────────────────────────────────────
  2480.  
  2481.   Sets the relative-record-number field of a file control block (FCB) to
  2482.   correspond to the current file position as recorded in the opened FCB.
  2483.  
  2484. Call with:
  2485.  
  2486.   AH            = 24H
  2487.   DS:DX         = segment:offset of previously opened file control block
  2488.  
  2489. Returns:
  2490.  
  2491.   AL is destroyed (other registers not affected)
  2492.  
  2493.   FCB relative-record field (offset 21H) updated
  2494.  
  2495. Notes:
  2496.  
  2497.   ■ This function is used when switching from sequential to random I/O
  2498.     within a file. The contents of the relative-record field (offset 21H)
  2499.     are derived from the record size (offset 0EH), current block (offset
  2500.     0CH), and current record (offset 20H) fields of the file control block.
  2501.  
  2502.   ■ All four bytes of the FCB relative-record field (offset 21H) should be
  2503.     initialized to zero before calling this function.
  2504.  
  2505. Example:
  2506.  
  2507.   After a series of sequential record transfers have been performed using
  2508.   the file control block myfcb, obtain the current relative-record position
  2509.   in the file and leave the record number in DX.
  2510.  
  2511.   myfcb   db      0               ; drive = default
  2512.           db      'MYFILE  '      ; filename, 8 chars
  2513.           db      'DAT'           ; extension, 3 chars
  2514.           db      25 dup (0)      ; remainder of FCB
  2515.           .
  2516.           .
  2517.           .
  2518.           mov     dx,seg myfcb    ; make FCB addressable
  2519.           mov     ds,dx
  2520.  
  2521.                                   ; initialize relative
  2522.                                   ; record field to zero
  2523.           mov     word ptr myfcb+21h,0
  2524.           mov     word ptr myfcb+23h,0
  2525.  
  2526.                                   ; now set record number
  2527.           mov     ah,24h          ; function number
  2528.           mov     dx,offset myfcb ; address of FCB
  2529.           int     21h             ; transfer to MS-DOS
  2530.  
  2531.                                   ; load record number in DX
  2532.           mov     dx,word ptr myfcb+21h
  2533.           .
  2534.           .
  2535.           .
  2536.  
  2537.  
  2538. ────────────────────────────────────────────────────────────────────────────
  2539. Int 21H                                                                [1.0]
  2540. Function 25H (37)
  2541. Set interrupt vector
  2542. ────────────────────────────────────────────────────────────────────────────
  2543.  
  2544.   Initializes a CPU interrupt vector to point to an interrupt handling
  2545.   routine.
  2546.  
  2547. Call with:
  2548.  
  2549.   AH            = 25H
  2550.   AL            = interrupt number
  2551.   DS:DX         = segment:offset of interrupt handling routine
  2552.  
  2553. Returns:
  2554.  
  2555.   Nothing
  2556.  
  2557. Notes:
  2558.  
  2559.   ■ This function should be used in preference to direct editing of the
  2560.     interrupt-vector table by well-behaved applications.
  2561.  
  2562.   ■ Before an interrupt vector is modified, its original value should be
  2563.     obtained with Int 21H Function 35H and saved, so that it can be restored
  2564.     using this function before program termination.
  2565.  
  2566. Example:
  2567.  
  2568.   Install a new interrupt handler, named zdiv, for "divide by zero" CPU
  2569.   exceptions.
  2570.  
  2571.           .
  2572.           .
  2573.           .
  2574.           mov     ah,25h          ; function number
  2575.           mov     al,0            ; interrupt number
  2576.           mov     dx,seg zdiv     ; address of handler
  2577.           mov     ds,dx
  2578.           mov     dx,offset zdiv
  2579.           int     21h             ; transfer to MS-DOS
  2580.           .
  2581.           .
  2582.           .
  2583.   zdiv:                           ; int 00h handler
  2584.           iret                    ; (does nothing)
  2585.  
  2586.  
  2587. ────────────────────────────────────────────────────────────────────────────
  2588. Int 21H                                                                [1.0]
  2589. Function 26H (38)
  2590. Create new PSP
  2591. ────────────────────────────────────────────────────────────────────────────
  2592.  
  2593.   Copies the program segment prefix (PSP) of the currently executing program
  2594.   to a specified segment address in free memory, then updates the new PSP to
  2595.   make it usable by another program.
  2596.  
  2597. Call with:
  2598.  
  2599.   AH            = 26H
  2600.   DX            = segment of new program segment prefix
  2601.  
  2602. Returns:
  2603.  
  2604.   Nothing
  2605.  
  2606. Notes:
  2607.  
  2608.   ■ After the executing program's PSP is copied into the new segment, the
  2609.     memory size information in the new PSP is updated appropriately and the
  2610.     current contents of the termination (Int 22H), Ctrl-C handler (Int 23H),
  2611.     and critical-error handler (Int 24H) vectors are saved starting at
  2612.     offset 0AH.
  2613.  
  2614.   ■ This function does not load another program or in itself cause one to be
  2615.     executed.
  2616.  
  2617.   ■ [2.0+] Int 21H Function 4BH (EXEC), which can be used to load and
  2618.     execute programs or overlays in either .COM or .EXE format, should be
  2619.     used in preference to this function.
  2620.  
  2621. Example:
  2622.  
  2623.   Create a new program segment prefix 64 KB above the currently executing
  2624.   program. This example assumes that the running program was loaded as a
  2625.   .COM file so that the CS register points to its PSP throughout its
  2626.   execution. If the running program was loaded as a .EXE file, the address
  2627.   of the PSP must be obtained with Int 21H Function 62H (under MS-DOS 3.0
  2628.   or later) or by saving the original contents of the DS or ES registers at
  2629.   entry.
  2630.  
  2631.           .
  2632.           .
  2633.           .
  2634.           mov     ah,26h          ; function number
  2635.           mov     dx,cs           ; PSP segment of
  2636.                                   ; this program
  2637.           add     dx,1000h        ; add 64 KB as
  2638.                                   ; paragraph address
  2639.           int     21h             ; transfer to MS-DOS
  2640.           .
  2641.           .
  2642.           .
  2643.  
  2644.  
  2645. ────────────────────────────────────────────────────────────────────────────
  2646. Int 21H                                                                [1.0]
  2647. Function 27H (39)
  2648. Random block read
  2649. ────────────────────────────────────────────────────────────────────────────
  2650.  
  2651.   Reads one or more sequential records from a file into memory, starting at
  2652.   a designated file location.
  2653.  
  2654. Call with:
  2655.  
  2656.   AH            = 27H
  2657.   CX            = number of records to read
  2658.   DS:DX         = segment:offset of previously opened file control block
  2659.  
  2660. Returns:
  2661.  
  2662.   AL            = 00H       if all requested records read
  2663.                   01H       if end of file
  2664.                   02H       if segment wrap
  2665.                   03H       if partial record read at end of file
  2666.  
  2667.   CX            = actual number of records read
  2668.  
  2669. Notes:
  2670.  
  2671.   ■ The records are read into memory at the current disk transfer area
  2672.     address, specified by the most recent call to Int 21H Function 1AH. It
  2673.     is the programmer's responsibility to ensure that this area is large
  2674.     enough for the group of records that will be transferred. If the size
  2675.     and location of the buffer are such that a segment overflow or
  2676.     wraparound would occur, the function fails with a return code of 02H.
  2677.  
  2678.   ■ The file location of the data to be read is determined by the
  2679.     combination of the relative-record field (offset 21H) and the
  2680.     record-size field (offset 0EH) of the FCB. The default record size is
  2681.     128 bytes.
  2682.  
  2683.   ■ After the disk transfer is performed, the current block (offset 0CH),
  2684.     current record (offset 20H), and relative-record (offset 21H) fields of
  2685.     the FCB are updated to point to the next record in the file.
  2686.  
  2687.   ■ If a partial record is read at the end of file, the remainder of the
  2688.     record is padded with zeros.
  2689.  
  2690.   ■ Compare with Int 21H Function 21H, which transfers only one record per
  2691.     function call and does not update the FCB relative-record field.
  2692.  
  2693.   ■ [3.0+] If the program is running on a network, the user must have Read
  2694.     access rights to the directory containing the file to be read.
  2695.  
  2696. Example:
  2697.  
  2698.   Read four 1024-byte records starting at record number 8 into the buffer
  2699.   named buff, using the file control block myfcb.
  2700.  
  2701.   myfcb   db      0               ; drive = default
  2702.           db      'MYFILE  '      ; filename, 8 chars
  2703.           db      'DAT'           ; extension, 3 chars
  2704.           db      25 dup (0)      ; remainder of FCB
  2705.  
  2706.   buff    db      4096 dup (?)    ; buffer for data
  2707.           .
  2708.           .
  2709.           .
  2710.                                   ; set DTA address
  2711.           mov     ah,1ah          ; function number
  2712.           mov     dx,seg buff     ; address of buffer
  2713.           mov     ds,dx
  2714.           mov     dx,offset buff
  2715.           int     21h             ; transfer to MS-DOS
  2716.  
  2717.                                   ; set relative-record number
  2718.           mov     word ptr myfcb+21h,8
  2719.           mov     word ptr myfcb+23h,0
  2720.  
  2721.                                   ; set record size
  2722.           mov     word ptr myfcb+0eh,1024
  2723.  
  2724.                                   ; read the records
  2725.           mov     ah,27h          ; function number
  2726.           mov     cx,4            ; number of records
  2727.           mov     dx,offset myfcb ; address of FCB
  2728.           int     21h             ; transfer to MS-DOS
  2729.           or      al,al           ; check status
  2730.           jnz     error           ; jump if read error
  2731.           .
  2732.           .
  2733.           .
  2734.  
  2735.  
  2736. ────────────────────────────────────────────────────────────────────────────
  2737. Int 21H                                                                [1.0]
  2738. Function 28H (40)
  2739. Random block write
  2740. ────────────────────────────────────────────────────────────────────────────
  2741.  
  2742.   Writes one or more sequential records from memory to a file, starting at a
  2743.   designated file location.
  2744.  
  2745. Call with:
  2746.  
  2747.   AH            = 28H
  2748.   CX            = number of records to write
  2749.   DS:DX         = segment:offset of previously opened file control block
  2750.  
  2751. Returns:
  2752.  
  2753.   AL            = 00H       if all requeste  records written
  2754.                   01H       if disk full
  2755.                   02H       if segment wrap
  2756.  
  2757.   CX            = actual number of records written
  2758.  
  2759. Notes:
  2760.  
  2761.   ■ The records are written (logically, not necessarily physically) to disk
  2762.     from memory at the current disk transfer area address, specified by the
  2763.     most recent call to Int 21H Function 1AH. If the size and location of
  2764.     the buffer are such that a segment overflow or wraparound would occur,
  2765.     the function fails with a return code of 02H.
  2766.  
  2767.   ■ The file location of the data to be written is determined by the
  2768.     combination of the relative-record field (offset 21H) and the
  2769.     record-size field (offset 0EH) of the FCB. The default record size is
  2770.     128 bytes.
  2771.  
  2772.   ■ After the disk transfer is performed, the current block (offset 0CH),
  2773.     current record (offset 20H), and relative-record (offset 21H) fields of
  2774.     the FCB are updated to point to the next record in the file.
  2775.  
  2776.   ■ If this function is called with CX = 0, no data is written to the disk
  2777.     but the file is extended or truncated to the length specified by
  2778.     combination of the record-size (offset 0EH) and the relative-record
  2779.     (offset 21H) fields of the FCB.
  2780.  
  2781.   ■ Compare with Int 21H Function 22H, which transfers only one record per
  2782.     function call and does not update the FCB relative-record field.
  2783.  
  2784.   ■ [3.0+] If the program is running on a network, the user must have Write
  2785.     access rights to the directory containing the file to be written.
  2786.  
  2787. Example:
  2788.  
  2789.   Write four 1024-byte records, starting at record number 8, to disk from
  2790.   the buffer named buff, using the file control block myfcb.
  2791.  
  2792.   myfcb   db      0               ; drive = default
  2793.           db      'MYFILE  '      ; filename, 8 chars
  2794.           db      'DAT'           ; extension, 3 chars
  2795.           db      25 dup (0)      ; remainder of FCB
  2796.  
  2797.   buff    db      4096 dup (?)    ; buffer for data
  2798.           .
  2799.           .
  2800.           .
  2801.                                   ; set DTA address
  2802.           mov     ah,1ah          ; function number
  2803.           mov     dx,seg buff     ; address of buffer
  2804.           mov     ds,dx
  2805.           mov     dx,offset buff
  2806.           int     21h             ; transfer to MS-DOS
  2807.  
  2808.                                   ; set relative-record number
  2809.           mov     word ptr myfcb+21h,8
  2810.           mov     word ptr myfcb+23h,0
  2811.  
  2812.                                   ; set record size
  2813.           mov     word ptr myfcb+0eh,1024
  2814.  
  2815.                                   ; write the records
  2816.           mov     ah,28h          ; function number
  2817.           mov     cx,4            ; number of records
  2818.           mov     dx,offset myfcb ; address of FCB
  2819.           int     21h             ; transfer to MS-DOS
  2820.           or      al,al           ; check status
  2821.           jnz     error           ; jump if write error
  2822.           .
  2823.           .
  2824.           .
  2825.  
  2826.  
  2827. ────────────────────────────────────────────────────────────────────────────
  2828. Int 21H                                                                [1.0]
  2829. Function 29H (41)
  2830. Parse filename
  2831. ────────────────────────────────────────────────────────────────────────────
  2832.  
  2833.   Parses a text string into the various fields of a file control block
  2834.   (FCB).
  2835.  
  2836. Call with:
  2837.  
  2838.   AH            = 29H
  2839.   AL            = flags to control parsing
  2840.  
  2841.                  Bit 3        = 1    if extension field in FCB will be
  2842.                                      modified only if an extension is
  2843.                                      specified in the string being parsed.
  2844.                               = 0    if extension field in FCB will be
  2845.                                      modified regardless; if no extension is
  2846.                                      present in the parsed string, FCB
  2847.                                      extension is set to ASCII blanks.
  2848.                  Bit 2        = 1    if filename field in FCB will be
  2849.                                      modified only if a filename is
  2850.                                      specified in the string being parsed.
  2851.                               = 0    if filename field in FCB will be
  2852.                                      modified regardless; if no filename is
  2853.                                      present in the parsed string, FCB
  2854.                                      filename is set to ASCII blanks.
  2855.                  Bit 1        = 1    if drive ID byte in FCB will be
  2856.                                      modified only if a drive was specified
  2857.                                      in the string being parsed.
  2858.                               = 0    if the drive ID byte in FCB will be
  2859.                                      modified regardless; if no drive
  2860.                                      specifier is present in the parsed
  2861.                                      string, FCB drive-code field is set to
  2862.                                      0 (default).
  2863.                  Bit 0        = 1    if leading separators will be scanned
  2864.                                      off (ignored).
  2865.                               = 0    if leading separators will not be
  2866.                                      scanned off.
  2867.  
  2868.   DS:SI         = segment:offset of string
  2869.   ES:DI         = segment:offset of file control block
  2870.  
  2871. Returns:
  2872.  
  2873.   AL            = 00H if no wildcard characters encountered
  2874.                   01H if parsed string contained wildcard characters
  2875.                   FFH if drive specifier invalid
  2876.   DS:SI         = segment:offset of first character after parsed filename
  2877.   ES:DI         = segment:offset of formatted unopened file control block
  2878.  
  2879. Notes:
  2880.  
  2881.   ■ This function regards the following as separator characters:
  2882.  
  2883.   [1]        : . ; ,      = + tab space / " [ ]
  2884.   [2.0+]     : . ; ,      = + tab space
  2885.  
  2886.   ■ This function regards all control characters and the following as
  2887.     terminator characters:
  2888.  
  2889.              : . ; ,      = + tab space < > | / " [ ]
  2890.  
  2891.   ■ If no valid filename is present in the string to be parsed, upon return
  2892.     ES:DI + 1 points to an ASCII blank.
  2893.  
  2894.   ■ If the * wildcard character occurs in a filename or extension, it and
  2895.     all remaining characters in the corresponding field in the FCB are set
  2896.     to ?.
  2897.  
  2898.   ■ This function (and file control blocks in general) cannot be used with
  2899.     file specifications that include a path.
  2900.  
  2901. Example:
  2902.  
  2903.   Parse the string fname into the file control block myfcb.
  2904.  
  2905.   fname   db      'D:QUACK.DAT',0 ; filename to be parsed
  2906.  
  2907.   myfcb   db      37 dup (0)      ; becomes file control block
  2908.           .
  2909.           .
  2910.           .
  2911.           mov     ah,29h          ; function number
  2912.           mov     al,01h          ; skip leading separators
  2913.           mov     si,seg fname    ; address of filename
  2914.           mov     ds,si
  2915.           mov     si,offset fname
  2916.           mov     di,seg myfcb    ; address of FCB
  2917.           mov     es,di
  2918.           mov     di,offset myfcb
  2919.           int     21h             ; transfer to MS-DOS
  2920.           cmp     al,0ffh         ; check status
  2921.           je      error           ; jump, drive invalid
  2922.           .
  2923.           .
  2924.           .
  2925.  
  2926.  
  2927. ────────────────────────────────────────────────────────────────────────────
  2928. Int 21H                                                                [1.0]
  2929. Function 2AH (42)
  2930. Get date
  2931. ────────────────────────────────────────────────────────────────────────────
  2932.  
  2933.   Obtains the system day of the month, day of the week, month, and year.
  2934.  
  2935. Call with:
  2936.  
  2937.   AH            = 2AH
  2938.  
  2939. Returns:
  2940.  
  2941.   CX            = year (1980 through 2099)
  2942.   DH            = month (1 through 12)
  2943.   DL            = day (1 through 31)
  2944.  
  2945.   Under MS-DOS versions 1.1 and later
  2946.  
  2947.   AL            = day of the week (0 = Sunday, 1 = Monday, etc.)
  2948.  
  2949. Notes:
  2950.  
  2951.   ■ This function's register format is the same as that required for Int 21H
  2952.     Function 2BH (Set Date).
  2953.  
  2954.   ■ This function can be used together with Int 21H Function 2BH to find
  2955.     the day of the week for an arbitrary date. The current date is first
  2956.     obtained with Function 2AH and saved. The date of interest is then set
  2957.     with Function 2BH, and the day of the week for that date is obtained
  2958.     with a subsequent call to Function 2AH. Finally, the current date is
  2959.     restored with an additional call to Function 2BH, using the values
  2960.     obtained with the original Function 2AH call.
  2961.  
  2962. Example:
  2963.  
  2964.   Obtain the current date and save its components in the variables year,
  2965.   day, and month.
  2966.  
  2967.   year    dw      0
  2968.   month   db      0
  2969.   day     db      0
  2970.           .
  2971.           .
  2972.           .
  2973.           mov     ah,2ah          ; function number
  2974.           int     21h             ; transfer to MS-DOS
  2975.           mov     year,cx         ; save year (word)
  2976.           mov     month,dh        ; save month (byte)
  2977.           mov     day,dl          ; save day (byte)
  2978.           .
  2979.           .
  2980.           .
  2981.  
  2982.  
  2983. ────────────────────────────────────────────────────────────────────────────
  2984. Int 21H                                                                [1.0]
  2985. Function 2BH (43)
  2986. Set date
  2987. ────────────────────────────────────────────────────────────────────────────
  2988.  
  2989.   Initializes the system clock driver to a specific date. The system time is
  2990.   not affected.
  2991.  
  2992. Call with:
  2993.  
  2994.   AH            = 2BH
  2995.   CX            = year (1980 through 2099)
  2996.   DH            = month (1 through 12)
  2997.   DL            = day (1 through 31)
  2998.  
  2999. Returns:
  3000.  
  3001.   AL            = 00H       if date set successfully
  3002.                   FFH       if date not valid (ignored)
  3003.  
  3004. Note:
  3005.  
  3006.   ■ This function's register format is the same as that required for Int 21H
  3007.     Function 2AH (Get Date).
  3008.  
  3009. Example:
  3010.  
  3011.   Set the system date according to the contents of the variables year, day,
  3012.   and month.
  3013.  
  3014.   year    dw      0
  3015.   month   db      0
  3016.   day     db      0
  3017.           .
  3018.           .
  3019.           .
  3020.           mov     ah,2bh          ; function number
  3021.           mov     cx,year         ; get year (word)
  3022.           mov     dh,month        ; get month (byte)
  3023.           mov     dl,day          ; get day (byte)
  3024.           int     21h             ; transfer to MS-DOS
  3025.           or      al,al           ; check status
  3026.           jnz     error           ; jump if date invalid
  3027.           .
  3028.           .
  3029.           .
  3030.  
  3031.  
  3032. ────────────────────────────────────────────────────────────────────────────
  3033. Int 21H                                                                [1.0]
  3034. Function 2CH (44)
  3035. Get time
  3036. ────────────────────────────────────────────────────────────────────────────
  3037.  
  3038.   Obtains the time of day from the system real-time clock driver, converted
  3039.   to hours, minutes, seconds, and hundredths of seconds.
  3040.  
  3041. Call with:
  3042.  
  3043.   AH            = 2CH
  3044.  
  3045. Returns:
  3046.  
  3047.   CH            = hours (0 through 23)
  3048.   CL            = minutes (0 through 59)
  3049.   DH            = seconds (0 through 59)
  3050.   DL            = hundredths of seconds (0 through 99)
  3051.  
  3052. Notes:
  3053.  
  3054.   ■ This function's register format is the same as that required for Int 21H
  3055.     Function 2DH (Set Time).
  3056.  
  3057.   ■ On most IBM PC─compatible systems, the real-time clock does not have a
  3058.     resolution of single hundredths of seconds. On such machines, the values
  3059.     returned by this function in register DL are discontinuous.
  3060.  
  3061. Example:
  3062.  
  3063.   Obtain the current time and save its two major components in the variables
  3064.   hours and minutes.
  3065.  
  3066.   hours   db      0
  3067.   minutes db      0
  3068.           .
  3069.           .
  3070.           .
  3071.           mov     ah,2ch          ; function number
  3072.           int     21h             ; transfer to MS-DOS
  3073.           mov     hours,ch        ; save hours (byte)
  3074.           mov     minutes,cl      ; save minutes (byte)
  3075.           .
  3076.           .
  3077.           .
  3078.  
  3079.  
  3080. ────────────────────────────────────────────────────────────────────────────
  3081. Int 21H                                                                [1.0]
  3082. Function 2DH (45)
  3083. Set time
  3084. ────────────────────────────────────────────────────────────────────────────
  3085.  
  3086.   Initializes the system real-time clock to a specified hour, minute,
  3087.   second, and hundredth of second. The system date is not affected.
  3088.  
  3089. Call with:
  3090.  
  3091.   AH            = 2DH
  3092.   CH            = hours (0 through 23)
  3093.   CL            = minutes (0 through 59)
  3094.   DH            = seconds (0 through 59)
  3095.   DL            = hundredths of seconds (0 through 99)
  3096.  
  3097. Returns:
  3098.  
  3099.   AL            = 00H       if time set successfully
  3100.                   FFH       if time not valid (ignored)
  3101.  
  3102. Note:
  3103.  
  3104.   ■ This function's register format is the same as that required for Int 21H
  3105.     Function 2CH (Get Time).
  3106.  
  3107. Example:
  3108.  
  3109.   Set the system time according to the contents of the variables hours and
  3110.   minutes. Force the current seconds and hundredths of seconds to zero.
  3111.  
  3112.   hours   db      0
  3113.   minutes db      0
  3114.           .
  3115.           .
  3116.           .
  3117.           mov     ah,2dh          ; function number
  3118.           mov     ch,hours        ; get hours (byte)
  3119.           mov     cl,minutes      ; get minutes (byte)
  3120.           mov     dx,0            ; force seconds and
  3121.                                   ; hundredths to zero
  3122.           int     21h             ; transfer to MS-DOS
  3123.           or      al,al           ; check status
  3124.           jnz     error           ; jump if time invalid
  3125.           .
  3126.           .
  3127.           .
  3128.  
  3129.  
  3130. ────────────────────────────────────────────────────────────────────────────
  3131. Int 21H                                                                [1.0]
  3132. Function 2EH (46)
  3133. Set verify flag
  3134. ────────────────────────────────────────────────────────────────────────────
  3135.  
  3136.   Turns off or turns on the operating-system flag for automatic
  3137.   read-after-write verification of data.
  3138.  
  3139. Call with:
  3140.  
  3141.   AH            = 2EH
  3142.   AL            = 00H       if turning off verify flag
  3143.                   01H       if turning on verify flag
  3144.  
  3145.   DL            = 00H (MS-DOS versions 1 and 2)
  3146.  
  3147. Returns:
  3148.  
  3149.   Nothing
  3150.  
  3151. Notes:
  3152.  
  3153.   ■ Because read-after-write verification slows disk operations, the default
  3154.     setting of the verify flag is OFF.
  3155.  
  3156.   ■ If a particular disk unit's device driver does not support
  3157.     read-after-write verification, this function has no effect.
  3158.  
  3159.   ■ The current state of the verify flag can be determined using Int 21H
  3160.     Function 54H.
  3161.  
  3162.   ■ The state of the verify flag is also controlled by the MS-DOS commands
  3163.     VERIFY OFF and VERIFY ON.
  3164.  
  3165. Example:
  3166.  
  3167.   Save the current state of the system verify flag in the variable vflag,
  3168.   then force all subsequent disk writes to be verified.
  3169.  
  3170.   vflag   db      0               ; previous verify flag
  3171.           .
  3172.           .
  3173.           .
  3174.                                   ; get verify flag
  3175.           mov     ah,54h          ; function number
  3176.           int     21h             ; transfer to MS-DOS
  3177.           mov     vflag,al        ; save current flag state
  3178.  
  3179.                                   ; set verify flag
  3180.           mov     ah,2eh          ; function number
  3181.           mov     al,1            ; AL = 1 for verify on
  3182.           mov     dl,0            ; DL must be zero
  3183.           int     21h             ; transfer to MS-DOS
  3184.           .
  3185.           .
  3186.           .
  3187.  
  3188.  
  3189. ────────────────────────────────────────────────────────────────────────────
  3190. Int 21H                                                                [2.0]
  3191. Function 2FH (47)
  3192. Get DTA address
  3193. ────────────────────────────────────────────────────────────────────────────
  3194.  
  3195.   Obtains the current address of the disk transfer area (DTA) for FCB file
  3196.   read/write operations.
  3197.  
  3198. Call with:
  3199.  
  3200.   AH            = 2FH
  3201.  
  3202. Returns:
  3203.  
  3204.   ES:BX         = segment:offset of disk transfer area
  3205.  
  3206. Note:
  3207.  
  3208.   ■ The disk transfer area address is set with Int 21H Function 1AH. The
  3209.     default DTA is a 128-byte buffer at offset 80H in the program segment
  3210.     prefix.
  3211.  
  3212. Example:
  3213.  
  3214.   Obtain the current disk transfer area address and save it in the variable
  3215.   olddta.
  3216.  
  3217.   olddta  dd      ?               ; save disk transfer address
  3218.           .
  3219.           .
  3220.           .
  3221.           mov     ah,2fh          ; function number
  3222.           int     21h             ; transfer to MS-DOS
  3223.  
  3224.                                   ; save it as DWORD pointer
  3225.           mov     word ptr olddta,bx
  3226.           mov     word ptr olddta+2,es
  3227.           .
  3228.           .
  3229.           .
  3230.  
  3231.  
  3232. ────────────────────────────────────────────────────────────────────────────
  3233. Int 21H                                                                [2.0]
  3234. Function 30H (48)
  3235. Get MS-DOS version number
  3236. ────────────────────────────────────────────────────────────────────────────
  3237.  
  3238.   Returns the version number of the host MS-DOS operating system. This
  3239.   function is used by application programs to determine the capabilities of
  3240.   their environment.
  3241.  
  3242. Call with:
  3243.  
  3244.   AH            = 30H
  3245.   AL            = 00H
  3246.  
  3247. Returns:
  3248.  
  3249.   If running under MS-DOS version 1
  3250.  
  3251.   AL            = 00H
  3252.  
  3253.   If running under MS-DOS versions 2.0 or later
  3254.  
  3255.   AL            = major version number (MS-DOS 3.10 = 3, etc.)
  3256.   AH            = minor version number (MS-DOS 3.10 = 0AH, etc.)
  3257.   BH            = Original Equipment Manufacturer's (OEM's) serial number
  3258.                   (OEM-dependent──usually 00H for IBM's PC-DOS, 0FFH or
  3259.                   other values for MS-DOS)
  3260.   BL:CX         = 24-bit user serial number (optional, OEM-dependent)
  3261.  
  3262. Notes:
  3263.  
  3264.   ■ Because this function was not defined under MS-DOS version 1, it should
  3265.     always be called with AL = 00H. In an MS-DOS version 1 environment, AL
  3266.     will be returned unchanged.
  3267.  
  3268.   ■ Care must be taken not to exit in an unacceptable fashion if an MS-DOS
  3269.     version 1 environment is detected. For example, Int 21H Function 4CH
  3270.     (Terminate Process with Return Code), Int 21H Function 40H (Write to
  3271.     File or Device), and the standard error handle are not available in
  3272.     MS-DOS version 1. In such cases a program should display an error
  3273.     message using Int 21H Function 09H and then terminate with Int 20H or
  3274.     Int 21H Function 00H.
  3275.  
  3276. Example:
  3277.  
  3278.   Get the MS-DOS version number, terminating the current process with an
  3279.   error message if not running under MS-DOS version 2.0 or later.
  3280.  
  3281.   cr      equ     0dh             ; ASCII carriage return
  3282.   lf      equ     0ah             ; ASCII line feed
  3283.  
  3284.   msg     db      cr,lf
  3285.           db      'Wrong MS-DOS version'
  3286.           db      cr,lf,'$'
  3287.           .
  3288.           .
  3289.           .
  3290.           mov     ax,3000h        ; function number
  3291.           int     21h             ; transfer to MS-DOS
  3292.           cmp     al,2            ; version 2 or later?
  3293.           jae     label1          ; yes, jump
  3294.  
  3295.                                   ; display error message
  3296.           mov     ah,09           ; function number
  3297.           mov     dx,offset msg   ; message address
  3298.           int     21h             ; transfer to MS-DOS
  3299.  
  3300.                                   ; terminate process
  3301.           mov     ah,0            ; function number
  3302.           int     21h             ; transfer to MS-DOS
  3303.  
  3304.   label1: .
  3305.           .
  3306.           .
  3307.  
  3308.  
  3309. ────────────────────────────────────────────────────────────────────────────
  3310. Int 21H                                                                [2.0]
  3311. Function 31H (49)
  3312. Terminate and stay resident
  3313. ────────────────────────────────────────────────────────────────────────────
  3314.  
  3315.   Terminates execution of the currently executing program, passing a return
  3316.   code to the parent process, but reserves part or all of the program's
  3317.   memory so that it will not be overlaid by the next transient program to be
  3318.   loaded. MS-DOS then takes the following actions:
  3319.  
  3320.   ■ File buffers are flushed and any open handles for files or devices owned
  3321.     by the process are closed.
  3322.  
  3323.   ■ The termination handler vector (Int 22H) is restored from PSP:000AH.
  3324.  
  3325.   ■ The Ctrl-C handler vector (Int 23H) is restored from PSP:000EH.
  3326.  
  3327.   ■ [2.0+] The critical-error handler vector (Int 24H) is restored from
  3328.     PSP:0012H.
  3329.  
  3330.   ■ Control is transferred to the termination handler.
  3331.  
  3332.   If the program is returning to COMMAND.COM, control transfers to the
  3333.   resident portion, and the transient portion is reloaded if necessary. If a
  3334.   batch file is in progress, the next line of the file is fetched and
  3335.   interpreted; otherwise, a prompt is issued for the next user command.
  3336.  
  3337. Call with:
  3338.  
  3339.   AH            = 31H
  3340.   AL            = return code
  3341.   DX            = amount of memory to reserve (in paragraphs)
  3342.  
  3343. Returns:
  3344.  
  3345.   Nothing
  3346.  
  3347. Notes:
  3348.  
  3349.   ■ This function call is typically used to allow user-written utilities,
  3350.     drivers, or interrupt handlers to be loaded as ordinary .COM or .EXE
  3351.     programs and then remain resident. Subsequent entrance to the code is
  3352.     via a hardware or software interrupt.
  3353.  
  3354.   ■ This function attempts to set the initial memory allocation block to the
  3355.     length in paragraphs specified in register DX. If other memory blocks
  3356.     have been requested by the application using Int 21H Function 48H, they
  3357.     will not be released by this function.
  3358.  
  3359.   ■ Other methods of performing a final exit are:
  3360.  
  3361.     ∙ Int 20H
  3362.  
  3363.     ∙ Int 21H Function 00H
  3364.  
  3365.     ∙ Int 21H Function 4CH
  3366.  
  3367.     ∙ Int 27H
  3368.  
  3369.   ■ The return code may be retrieved by a parent process with Int 21H
  3370.     Function 4DH (Get Return Code). It can also be tested in a batch file
  3371.     with an IF ERRORLEVEL statement. By convention, a return code of zero
  3372.     indicates successful execution, and a nonzero return code indicates an
  3373.     error.
  3374.  
  3375.   ■ This function should not be called by .EXE programs that are loaded at
  3376.     the high end of the transient program area (that is, linked with the
  3377.     /HIGH switch) because doing so reserves the memory that is normally used
  3378.     by the transient part of COMMAND.COM. If COMMAND.COM cannot be reloaded,
  3379.     the system will fail.
  3380.  
  3381.   ■ [2.0+] This function should be used in preference to Int 27H because it
  3382.     supports return codes, allows larger amounts of memory to be reserved,
  3383.     and does not require CS to contain the segment of the program segment
  3384.     prefix.
  3385.  
  3386.   ■ [3.0+] If the program is running on a network, it should remove all
  3387.     locks it has placed on file regions before terminating.
  3388.  
  3389. Example:
  3390.  
  3391.   Exit with a return code of 1 but stay resident, reserving 16 KB of memory
  3392.   starting at the program segment prefix of the process.
  3393.  
  3394.           .
  3395.           .
  3396.           .
  3397.           mov     ah,31h          ; function number
  3398.           mov     al,1            ; return code for parent
  3399.           mov     dx,0400h        ; paragraphs to reserve
  3400.           int     21h             ; transfer to MS-DOS
  3401.           .
  3402.           .
  3403.           .
  3404.  
  3405.  
  3406. ────────────────────────────────────────────────────────────────────────────
  3407. Int 21H
  3408. Function 32H (50)
  3409. Reserved
  3410. ────────────────────────────────────────────────────────────────────────────
  3411.  
  3412.  
  3413. ────────────────────────────────────────────────────────────────────────────
  3414. Int 21H                                                                [2.0]
  3415. Function 33H (51)
  3416. Get or set break flag, get boot drive
  3417. ────────────────────────────────────────────────────────────────────────────
  3418.  
  3419.   Obtains or changes the status of the operating system's break flag, which
  3420.   influences Ctrl-C checking during function calls. Also returns the system
  3421.   boot drive in version 4.0.
  3422.  
  3423. Call with:
  3424.  
  3425.   If getting break flag
  3426.  
  3427.   AH            = 33H
  3428.   AL            = 00H
  3429.  
  3430.   If setting break flag
  3431.  
  3432.   AH            = 33H
  3433.   AL            = 01H
  3434.   DL            = 00H       if turning break flag OFF
  3435.                   01H       if turning break flag ON
  3436.  
  3437.   [4] If getting boot drive
  3438.  
  3439.   AH            = 33H
  3440.   AL            = 05H
  3441.  
  3442. Returns:
  3443.  
  3444.   If called with AL = 00H or 01H
  3445.  
  3446.   DL            = 00H       break flag is OFF
  3447.                   01H       break flag is ON
  3448.  
  3449.   [4] If called with AL = 05H
  3450.  
  3451.   DL            = boot drive (1 = A, 2 = B, etc.)
  3452.  
  3453. Notes:
  3454.  
  3455.   ■ When the system break flag is on, the keyboard is examined for a Ctrl-C
  3456.     entry whenever any operating-system input or output is requested; if
  3457.     Ctrl-C is detected, control is transferred to the Ctrl-C handler (Int
  3458.     23H). When the break flag is off, MS-DOS only checks for a Ctrl-C entry
  3459.     when executing the traditional character I/O functions (Int 21H
  3460.     Functions 01H through 0CH).
  3461.  
  3462.   ■ The break flag is not part of the local environment of the currently
  3463.     executing program; it affects all programs. An application that alters
  3464.     the flag should first save the flag's original status, then restore the
  3465.     flag before terminating.
  3466.  
  3467. Example:
  3468.  
  3469.   Save the current state of the system break flag in the variable brkflag,
  3470.   then turn the break flag off to disable Ctrl-C checking during most MS-DOS
  3471.   function calls.
  3472.  
  3473.   brkflag db      0               ; save break flag
  3474.           .
  3475.           .
  3476.           .
  3477.                                   ; get current break flag
  3478.           mov     ah,33h          ; function number
  3479.           mov     al,0            ; AL = 0 to get flag
  3480.           int     21h             ; transfer to MS-DOS
  3481.           mov     brkflag,dl      ; save current flag
  3482.  
  3483.                                   ; now set break flag
  3484.           mov     ah,33h          ; function number
  3485.           mov     al,1            ; AL = 1 to set flag
  3486.           mov     dl,0            ; set break flag OFF
  3487.           int     21h             ; transfer to MS-DOS
  3488.           .
  3489.           .
  3490.           .
  3491.  
  3492.  
  3493. ────────────────────────────────────────────────────────────────────────────
  3494. Int 21H
  3495. Function 34H (52)
  3496. Reserved
  3497. ────────────────────────────────────────────────────────────────────────────
  3498.  
  3499.  
  3500. ────────────────────────────────────────────────────────────────────────────
  3501. Int 21H                                                                [2.0]
  3502. Function 35H (53)
  3503. Get interrupt vector
  3504. ────────────────────────────────────────────────────────────────────────────
  3505.  
  3506.   Obtains the address of the current interrupt-handler routine for the
  3507.   specified machine interrupt.
  3508.  
  3509. Call with:
  3510.  
  3511.   AH            = 35H
  3512.   AL            = interrupt number
  3513.  
  3514. Returns:
  3515.  
  3516.   ES:BX         = segment:offset of interrupt handler
  3517.  
  3518. Note:
  3519.  
  3520.   ■ Together with Int 21H Function 25H (Set Interrupt Vector), this
  3521.     function is used by well-behaved application programs to modify or
  3522.     inspect the machine interrupt vector table.
  3523.  
  3524. Example:
  3525.  
  3526.   Obtain the address of the current interrupt handler for hardware interrupt
  3527.   level 0 (divide by zero) and save it in the variable oldint0.
  3528.  
  3529.   oldint0 dd      ?               ; previous handler address
  3530.           .
  3531.           .
  3532.           .
  3533.           mov     ah,35h          ; function number
  3534.           mov     al,0            ; interrupt level
  3535.           int     21h             ; transfer to MS-DOS
  3536.  
  3537.                                   ; save old handler address
  3538.           mov     word ptr oldint0,bx
  3539.           mov     word ptr oldint0+2,es
  3540.           .
  3541.           .
  3542.           .
  3543.  
  3544.  
  3545. ────────────────────────────────────────────────────────────────────────────
  3546. Int 21H                                                                [2.0]
  3547. Function 36H (54)
  3548. Get drive allocation information
  3549. ────────────────────────────────────────────────────────────────────────────
  3550.  
  3551.   Obtains selected information about a disk drive, from which the drive's
  3552.   capacity and remaining free space can be calculated.
  3553.  
  3554. Call with:
  3555.  
  3556.   AH            = 36H
  3557.   DL            = drive code (0 = default, 1 = A, etc.)
  3558.  
  3559. Returns:
  3560.  
  3561.   If function successful
  3562.  
  3563.   AX            = sectors per cluster
  3564.   BX            = number of available clusters
  3565.   CX            = bytes per sector
  3566.   DX            = clusters per drive
  3567.  
  3568.   If function unsuccessful (drive invalid)
  3569.  
  3570.   AX            = FFFFH
  3571.  
  3572. Notes:
  3573.  
  3574.   ■ This function regards "lost" clusters as being in use and does not
  3575.     report them as part of the number of available clusters, even though
  3576.     they are not assigned to a file.
  3577.  
  3578.   ■ Similar information is returned by Int 21H Functions 1BH and 1CH.
  3579.  
  3580. Example:
  3581.  
  3582.   Calculate the capacity of disk drive C in bytes, leaving the result in the
  3583.   variable drvsize. (This code assumes that the product of sectors/cluster *
  3584.   bytes/sector will not overflow 16 bits.)
  3585.  
  3586.   drvsize dd      ?               ; drive C size in bytes
  3587.           .
  3588.           .
  3589.           .
  3590.           mov     ah,36h          ; function number
  3591.           mov     dl,3            ; drive C = 3
  3592.           int     21h             ; transfer to MS-DOS
  3593.  
  3594.           mul     cx              ; sectors/cluster
  3595.                                   ; * bytes/sector
  3596.           mul     dx              ; * total clusters
  3597.                                   ; result now in DX:AX
  3598.  
  3599.                                   ; store low word
  3600.           mov     word ptr drvsize,ax
  3601.                                   ; store high word
  3602.           mov     word ptr drvsize+2,dx
  3603.           .
  3604.           .
  3605.           .
  3606.  
  3607.  
  3608. ────────────────────────────────────────────────────────────────────────────
  3609. Int 21H
  3610. Function 37H (55)
  3611. Reserved
  3612. ────────────────────────────────────────────────────────────────────────────
  3613.  
  3614.  
  3615. ────────────────────────────────────────────────────────────────────────────
  3616. Int 21H                                                                [2.0]
  3617. Function 38H (56)
  3618. Get or set country information
  3619. ────────────────────────────────────────────────────────────────────────────
  3620.  
  3621.   [2] Obtains internationalization information for the current country.
  3622.  
  3623.   [3.0+] Obtains internationalization information for the current or
  3624.   specified country or sets the current country code.
  3625.  
  3626. Call with:
  3627.  
  3628.   If getting country information (MS-DOS version 2)
  3629.  
  3630.   AH            = 38H
  3631.   AL            = 0         to get "current" country information
  3632.  
  3633.   DS:DX         = segment:offset of buffer for returned information
  3634.  
  3635.   If getting country information (MS-DOS versions 3.0 and later)
  3636.  
  3637.   AH            = 38H
  3638.   AL            = 0         to get "current" country information
  3639.                   1─FEH     to get information for countries with code < 255
  3640.                   FFH       to get information for countries with code >=
  3641.                             255
  3642.  
  3643.   BX            = country code, if AL = FFH
  3644.   DS:DX         = segment:offset of buffer for returned information
  3645.  
  3646.   If setting current country code (MS-DOS versions 3.0 and later)
  3647.  
  3648.   AH            = 38H
  3649.   AL            = 1─FEH     country code for countries with code < 255
  3650.                   FFH       for countries with code >= 255
  3651.  
  3652.   BX            = country code, if AL = 0FFH
  3653.   DX            = FFFFH
  3654.  
  3655. Returns:
  3656.  
  3657.   If function successful
  3658.  
  3659.   Carry flag    = clear
  3660.  
  3661.   and, if getting internationalization information
  3662.  
  3663.   BX            = country code
  3664.   DS:DX         = segment:offset of buffer holding internationalization
  3665.                   information
  3666.  
  3667.   and buffer filled in as follows:
  3668.  
  3669.   (for PC-DOS 2.0 and 2.1)
  3670.  
  3671.   Byte(s)    Contents
  3672.   00H─01H    date format
  3673.  
  3674.              0 = USA              m d y
  3675.              1 = Europe           d m y
  3676.              2 = Japan            y m d
  3677.  
  3678.   02H─03H    ASCIIZ currency symbol
  3679.   04H─05H    ASCIIZ thousands separator
  3680.   06H─07H    ASCIIZ decimal separator
  3681.   08H─1FH    reserved
  3682.  
  3683.   (for MS-DOS versions 2.0 and later, PC-DOS versions 3.0 and later)
  3684.  
  3685.   Byte(s)    Contents
  3686.   00H─01H    date format
  3687.  
  3688.              0 = USA   m d y
  3689.              1 =       d m y
  3690.              Europe
  3691.              2 = Japan y m d
  3692.  
  3693.   02H─06H    ASCIIZ currency symbol string
  3694.   07H─08H    ASCIIZ thousands separator character
  3695.   09H─0AH    ASCIIZ decimal separator character
  3696.   0BH─0CH    ASCIIZ date separator character
  3697.   0DH─0EH    ASCIIZ time separator character
  3698.   0FH        currency format
  3699.  
  3700.              bit 0                = 0 if currency symbol precedes value
  3701.                                   = 1 if currency symbol follows value
  3702.              bit 1                = 0 if no space between value and currency
  3703.                                   symbol
  3704.                                   = 1 if one space between value and
  3705.                                   currency symbol
  3706.              bit 2                = 0 if currency symbol and decimal are
  3707.                                   separate
  3708.                                   = 1 if currency symbol replaces decimal
  3709.                                   separator
  3710.  
  3711.   10H        number of digits after decimal in currency
  3712.   11H        time format
  3713.  
  3714.              bit 0                = 0 if 12-hour clock
  3715.                                   = 1 if 24-hour clock
  3716.  
  3717.   12H─15H    case-map call address
  3718.   16H─17H    ASCIIZ data-list separator
  3719.   18H─21H    reserved
  3720.  
  3721.   If function unsuccessful
  3722.  
  3723.   Carry flag    = set
  3724.   AX            = error code
  3725.  
  3726. Notes:
  3727.  
  3728.   ■ The default country code is determined by the COUNTRY= directive in
  3729.     CONFIG.SYS or by the KEYBxx keyboard driver file if one is loaded.
  3730.     Otherwise, the default country code is OEM-dependent.
  3731.  
  3732.   ■ The previous contents of register CX may be destroyed by the Get Country
  3733.     Information subfunction.
  3734.  
  3735.   ■ The case-map call address is the segment:offset of a FAR procedure that
  3736.     performs country-specific mapping on character values from 80H through
  3737.     0FFH. The procedure must be called with the character to be mapped in
  3738.     register AL. If an alternate value exists for that character, it is
  3739.     returned in AL; otherwise, AL is unchanged. In general, lowercase
  3740.     characters are mapped to their uppercase equivalents, and accented or
  3741.     otherwise modified vowels are mapped to their plain vowel equivalents.
  3742.  
  3743.   ■ [3.0+] The value in register DX is used by MS-DOS to select between the
  3744.     Set Country and Get Country Information subfunctions.
  3745.  
  3746.   ■ [3.3+] Int 21H Function 65H (Get Extended Country Information) returns
  3747.     a superset of the information supplied by this function.
  3748.  
  3749. Examples:
  3750.  
  3751.   Obtain internationalization information for the current country in the
  3752.   buffer ctrybuf.
  3753.  
  3754.   ctrybuf db      34 dup (0)
  3755.           .
  3756.           .
  3757.           .
  3758.           mov     ah,38h          ; function number
  3759.           mov     al,0            ; get current country
  3760.           mov     dx,seg ctrybuf  ; address of buffer
  3761.           mov     ds,dx           ; for country information
  3762.           mov     dx,offset ctrybuf
  3763.           int     21h             ; transfer to MS-DOS
  3764.           jc      error           ; jump if function failed
  3765.           .
  3766.           .
  3767.           .
  3768.  
  3769.   If the program is running under PC-DOS 3.3 and the current country code is
  3770.   49 (West Germany), ctrybuf is filled in with the following information:
  3771.  
  3772.           dw      0001h           ; date format
  3773.           db      'DM',0,0,0      ; ASCIIZ currency symbol
  3774.           db      '.',0           ; ASCIIZ thousands separator
  3775.           db      ',',0           ; ASCIIZ decimal separator
  3776.           db      '.',0           ; ASCIIZ date separator
  3777.           db      '.',0           ; ASCIIZ time separator
  3778.           db      02h             ; currency format
  3779.           db      02h             ; digits after decimal
  3780.           db      01h             ; time format
  3781.           dd      026ah:176ch     ; case-map call address
  3782.           db      ';',0           ; ASCIIZ data-list separator
  3783.           db      10 dup (0)      ; reserved
  3784.  
  3785.  
  3786. ────────────────────────────────────────────────────────────────────────────
  3787. Int 21H                                                                [2.0]
  3788. Function 39H (57)
  3789. Create directory
  3790. ────────────────────────────────────────────────────────────────────────────
  3791.  
  3792.   Creates a directory using the specified drive and path.
  3793.  
  3794. Call with:
  3795.  
  3796.   AH            = 39H
  3797.   DS:DX         = segment:offset of ASCIIZ pathname
  3798.  
  3799. Returns:
  3800.  
  3801.   If function successful
  3802.  
  3803.   Carry flag    = clear
  3804.  
  3805.   If function unsuccessful
  3806.  
  3807.   Carry flag    = set
  3808.   AX            = error code
  3809.  
  3810. Note:
  3811.  
  3812.   ■ The function fails if:
  3813.  
  3814.     ∙ any element of the pathname does not exist.
  3815.  
  3816.     ∙ a directory with the same name at the end of the same path already
  3817.       exists.
  3818.  
  3819.     ∙ the parent directory for the new directory is the root directory and
  3820.       is full.
  3821.  
  3822.     ∙ [3.0+] the program is running on a network and the user running the
  3823.       program has insufficient access rights.
  3824.  
  3825. Example:
  3826.  
  3827.   Create a directory named MYSUB in the root directory on drive C.
  3828.  
  3829.   dname   db      'C:\MYSUB',0
  3830.           .
  3831.           .
  3832.           .
  3833.           mov     ah,39h          ; function number
  3834.           mov     dx,seg dname    ; address of pathname
  3835.           mov     ds,dx
  3836.           mov     dx,offset dname
  3837.           int     21h             ; transfer to MS-DOS
  3838.           jc      error           ; jump if create failed
  3839.           .
  3840.           .
  3841.           .
  3842.  
  3843.  
  3844. ────────────────────────────────────────────────────────────────────────────
  3845. Int 21H                                                                [2.0]
  3846. Function 3AH (58)
  3847. Delete directory
  3848. ────────────────────────────────────────────────────────────────────────────
  3849.  
  3850.   Removes a directory using the specified drive and path.
  3851.  
  3852. Call with:
  3853.  
  3854.   AH            = 3AH
  3855.   DS:DX         = segment:offset of ASCIIZ pathname
  3856.  
  3857. Returns:
  3858.  
  3859.   If function successful
  3860.  
  3861.   Carry flag    = clear
  3862.  
  3863.   If function unsuccessful
  3864.  
  3865.   Carry flag    = set
  3866.   AX            = error code
  3867.  
  3868. Note:
  3869.  
  3870.   ■ The function fails if:
  3871.  
  3872.     ∙ any element of the pathname does not exist.
  3873.  
  3874.     ∙ the specified directory is also the current directory.
  3875.  
  3876.     ∙ the specified directory contains any files.
  3877.  
  3878.     ∙ [3.0+] the program is running on a network and the user running the
  3879.       program has insufficient access rights.
  3880.  
  3881. Example:
  3882.  
  3883.   Remove the directory named MYSUB in the root directory on drive C.
  3884.  
  3885.   dname   db      'C:\MYSUB',0
  3886.           .
  3887.           .
  3888.           .
  3889.           mov     ah,3ah          ; function number
  3890.           mov     dx,seg dname    ; address of pathname
  3891.           mov     ds,dx
  3892.           mov     dx,offset dname
  3893.           int     21h             ; transfer to MS-DOS
  3894.           jc      error           ; jump if delete failed
  3895.           .
  3896.           .
  3897.           .
  3898.  
  3899.  
  3900. ────────────────────────────────────────────────────────────────────────────
  3901. Int 21H                                                                [2.0]
  3902. Function 3BH (59)
  3903. Set current directory
  3904. ────────────────────────────────────────────────────────────────────────────
  3905.  
  3906.   Sets the current, or default, directory using the specified drive and
  3907.   path.
  3908.  
  3909. Call with:
  3910.  
  3911.   AH            = 3BH
  3912.   DS:DX         = segment:offset of ASCIIZ pathname
  3913.  
  3914. Returns:
  3915.  
  3916.   If function successful
  3917.  
  3918.   Carry flag    = clear
  3919.  
  3920.   If function unsuccessful
  3921.  
  3922.   Carry flag    = set
  3923.   AX            = error code
  3924.  
  3925. Notes:
  3926.  
  3927.   ■ The function fails if any element of the pathname does not exist.
  3928.  
  3929.   ■ Int 21H Function 47H can be used to obtain the name of the current
  3930.     directory before using Int 21H Function 3BH to select another, so that
  3931.     the original directory can be restored later.
  3932.  
  3933. Example:
  3934.  
  3935.   Change the current directory for drive C to the directory \MYSUB.
  3936.  
  3937.   dname   db      'C:\MYSUB',0
  3938.           .
  3939.           .
  3940.           .
  3941.           mov     ah,3bh          ; function number
  3942.           mov     dx,seg dname    ; address of pathname
  3943.           mov     ds,dx
  3944.           mov     dx,offset dname
  3945.           int     21h             ; transfer to MS-DOS
  3946.           jc      error           ; jump if bad path
  3947.           .
  3948.           .
  3949.           .
  3950.  
  3951.  
  3952. ────────────────────────────────────────────────────────────────────────────
  3953. Int 21H                                                                [2.0]
  3954. Function 3CH (60)
  3955. Create file
  3956. ────────────────────────────────────────────────────────────────────────────
  3957.  
  3958.   Given an ASCIIZ pathname, creates a new file in the designated or default
  3959.   directory on the designated or default disk drive. If the specified file
  3960.   already exists, it is truncated to zero length. In either case, the file
  3961.   is opened and a handle is returned that can be used by the program for
  3962.   subsequent access to the file.
  3963.  
  3964. Call with:
  3965.  
  3966.   AH            = 3CH
  3967.   CX            = file attribute (bits may be combined)
  3968.  
  3969.                   Bit(s)    Significance (if set)
  3970.                   0         read-only
  3971.                   1         hidden
  3972.                   2         system
  3973.                   3         volume label
  3974.                   4         reserved (0)
  3975.                   5         archive
  3976.                   6─15      reserved (0)
  3977.  
  3978.   DS:DX         = segment:offset of ASCIIZ pathname
  3979.  
  3980. Returns:
  3981.  
  3982.   If function successful
  3983.  
  3984.   Carry flag    = clear
  3985.   AX            = handle
  3986.  
  3987.   If function failed
  3988.  
  3989.   Carry flag    = set
  3990.   AX            = error code
  3991.  
  3992. Notes:
  3993.  
  3994.   ■ The function fails if:
  3995.  
  3996.     ∙ any element of the pathname does not exist.
  3997.  
  3998.     ∙ the file is being created in the root directory and the root directory
  3999.       is full.
  4000.  
  4001.     ∙ a file with the same name and the read-only attribute already exists
  4002.       in the specified directory.
  4003.  
  4004.     ∙ [3.0+] the program is running on a network and the user running the
  4005.       program has insufficient access rights.
  4006.  
  4007.   ■ A file is usually given a normal (0) attribute when it is created. The
  4008.     file's attribute can subsequently be modified with Int 21H Function
  4009.     43H.
  4010.  
  4011.   ■ [3.0+] A volume label can be created using an attribute of 0008H, if one
  4012.     does not already exist. When files are created, bit 3 of the attribute
  4013.     parameter should always be clear (0).
  4014.  
  4015.   ■ [3.0+] See the entries for Int 21H Functions 5AH and 5BH, which may
  4016.     also be used to create files.
  4017.  
  4018.   ■ [4.0+] Int 21H Function 6CH combines the services of Functions 3CH,
  4019.     3DH, and 5BH.
  4020.  
  4021. Example:
  4022.  
  4023.   Create and open, or truncate to zero length and open, the file
  4024.   C:\MYDIR\MYFILE.DAT, and save the handle for subsequent access to the
  4025.   file.
  4026.  
  4027.   fname   db      'C:\MYDIR\MYFILE.DAT',0
  4028.  
  4029.   fhandle dw      ?
  4030.           .
  4031.           .
  4032.           .
  4033.           mov     ah,3ch          ; function number
  4034.           xor     cx,cx           ; normal attribute
  4035.           mov     dx,seg fname    ; address of pathname
  4036.           mov     ds,dx
  4037.           mov     dx,offset fname
  4038.           int     21h             ; transfer to MS-DOS
  4039.           jc      error           ; jump if create failed
  4040.           mov     fhandle,ax      ; save file handle
  4041.           .
  4042.           .
  4043.           .
  4044.  
  4045.  
  4046. ────────────────────────────────────────────────────────────────────────────
  4047. Int 21H                                                                [2.0]
  4048. Function 3DH (61)
  4049. Open file
  4050. ────────────────────────────────────────────────────────────────────────────
  4051.  
  4052.   Given an ASCIIZ pathname, opens the specified file in the designated or
  4053.   default directory on the designated or default disk drive. A handle is
  4054.   returned which can be used by the program for subsequent access to the
  4055.   file.
  4056.  
  4057. Call with:
  4058.  
  4059.   AH            = 3DH
  4060.   AL            = access mode
  4061.  
  4062.                   Bit(s)    Significance
  4063.                   0─2       access mode
  4064.                             000 = read access
  4065.                             001 = write access
  4066.                             010 = read/write access
  4067.                   3         reserved (0)
  4068.                   4─6       sharing mode (MS-DOS versions 3.0 and later)
  4069.                             000 = compatibility mode
  4070.                             001 = deny all
  4071.                             010 = deny write
  4072.                             011 = deny read
  4073.                             100 = deny none
  4074.                   7         inheritance flag (MS-DOS versions 3.0 and later)
  4075.                             0 = child process inherits handle
  4076.                             1 = child does not inherit handle
  4077.  
  4078.   DS:DX         = segment:offset of ASCIIZ pathname
  4079.  
  4080. Returns:
  4081.  
  4082.   If function successful
  4083.  
  4084.   Carry flag    = clear
  4085.   AX            = handle
  4086.  
  4087.   If function unsuccessful
  4088.  
  4089.   Carry flag    = set
  4090.   AX            = error code
  4091.  
  4092. Notes:
  4093.  
  4094.   ■ Any normal, system, or hidden file with a matching name will be opened
  4095.     by this function. If the file is read-only, the success of the operation
  4096.     also depends on the access code in bits 0─2 of register AL. After
  4097.     opening the file, the file read/write pointer is set to offset zero (the
  4098.     first byte of the file).
  4099.  
  4100.   ■ The function fails if:
  4101.  
  4102.     ∙ any element of the pathname does not exist.
  4103.  
  4104.     ∙ the file is opened with an access mode of read/write and the file has
  4105.       the read-only attribute.
  4106.  
  4107.     ∙ [3.0+] SHARE.EXE is loaded and the file has already been opened by one
  4108.       or more other processes in a sharing mode that is incompatible with
  4109.       the current program's request.
  4110.  
  4111.   ■ The file's date and time stamp can be accessed after a successful open
  4112.     call with Int 21H Function 57H.
  4113.  
  4114.   ■ The file's attributes (hidden, system, read-only, or archive) can be
  4115.     obtained with Int 21H Function 43H.
  4116.  
  4117.   ■ When a file handle is inherited by a child process or is duplicated with
  4118.     Int 21H Function 45H or 46H, all sharing and access restrictions are
  4119.     also inherited.
  4120.  
  4121.   ■ [2] Only bits 0─2 of register AL are significant; the remaining bits
  4122.     should be zero for upward compatibility.
  4123.  
  4124.   ■ [3.0+] Bits 4─7 of register AL control access to the file by other
  4125.     programs. (Bits 4─6 have no effect unless SHARE.EXE is loaded.)
  4126.  
  4127.   ■ [3.0+] A file-sharing error causes a critical-error exception (Int 24H)
  4128.     with an error code of 02H. Int 21H Function 59H can be used to obtain
  4129.     information about the sharing violation.
  4130.  
  4131.   ■ [4.0+] Int 21H Function 6CH combines the services of Functions 3CH,
  4132.     3DH, and 5BH.
  4133.  
  4134. Example:
  4135.  
  4136.   Open the file C:\MYDIR\MYFILE.DAT for both reading and writing, and save
  4137.   the handle for subsequent access to the file.
  4138.  
  4139.   fname   db      'C:\MYDIR\MYFILE.DAT',0
  4140.  
  4141.   fhandle dw      ?
  4142.           .
  4143.           .
  4144.           .
  4145.           mov     ah,3dh          ; function number
  4146.           mov     al,2            ; mode = read/write
  4147.           mov     dx,seg fname    ; address of pathname
  4148.           mov     ds,dx
  4149.           mov     dx,offset fname
  4150.           int     21h             ; transfer to MS-DOS
  4151.           jc      error           ; jump if open failed
  4152.           mov     fhandle,ax      ; save file handle
  4153.           .
  4154.           .
  4155.           .
  4156.  
  4157.  
  4158. ────────────────────────────────────────────────────────────────────────────
  4159. Int 21H                                                                [2.0]
  4160. Function 3EH (62)
  4161. Close file
  4162. ────────────────────────────────────────────────────────────────────────────
  4163.  
  4164.   Given a handle that was obtained by a previous successful open or create
  4165.   operation, flushes all internal buffers associated with the file to disk,
  4166.   closes the file, and releases the handle for reuse. If the file was
  4167.   modified, the time and date stamp and file size are updated in the file's
  4168.   directory entry.
  4169.  
  4170. Call with:
  4171.  
  4172.   AH            = 3EH
  4173.   BX            = handle
  4174.  
  4175. Returns:
  4176.  
  4177.   If function successful
  4178.  
  4179.   Carry flag    = clear
  4180.  
  4181.   If function unsuccessful
  4182.  
  4183.   Carry flag    = set
  4184.   AX            = error code
  4185.  
  4186. Note:
  4187.  
  4188.   ■ If you accidentally call this function with a zero handle, the standard
  4189.     input device is closed, and the keyboard appears to go dead. Make sure
  4190.     you always call the close function with a valid, nonzero handle.
  4191.  
  4192. Example:
  4193.  
  4194.   Close the file whose handle is saved in the variable fhandle.
  4195.  
  4196.   fhandle dw      0
  4197.           .
  4198.           .
  4199.           .
  4200.           mov     ah,3eh          ; function number
  4201.           mov     bx,fhandle      ; file handle
  4202.           int     21h             ; transfer to MS-DOS
  4203.           jc      error           ; jump if close failed
  4204.           .
  4205.           .
  4206.           .
  4207.  
  4208.  
  4209. ────────────────────────────────────────────────────────────────────────────
  4210. Int 21H                                                                [2.0]
  4211. Function 3FH (63)
  4212. Read file or device
  4213. ────────────────────────────────────────────────────────────────────────────
  4214.  
  4215.   Given a valid file handle from a previous open or create operation, a
  4216.   buffer address, and a length in bytes, transfers data at the current
  4217.   file-pointer position from the file into the buffer and then updates the
  4218.   file pointer position.
  4219.  
  4220. Call with:
  4221.  
  4222.   AH            = 3FH
  4223.   BX            = handle
  4224.   CX            = number of bytes to read
  4225.   DS:DX         = segment:offset of buffer
  4226.  
  4227. Returns:
  4228.  
  4229.   If function successful
  4230.  
  4231.   Carry flag    = clear
  4232.   AX            = bytes transferred
  4233.  
  4234.   If function unsuccessful
  4235.  
  4236.   Carry flag    = set
  4237.   AX            = error code
  4238.  
  4239. Notes:
  4240.  
  4241.   ■ If reading from a character device (such as the standard input) in
  4242.     cooked mode, at most one line of input will be read (i.e., up to a
  4243.     carriage return character or the specified length, whichever comes
  4244.     first).
  4245.  
  4246.   ■ If the carry flag is returned clear but AX = 0, then the file pointer
  4247.     was already at end of file when the program requested the read.
  4248.  
  4249.   ■ If the carry flag is returned clear but AX < CX, then a partial record
  4250.     was read at end of file or there is an error.
  4251.  
  4252.   ■ [3.0+] If the program is running on a network, the user must have Read
  4253.     access rights to the directory and file.
  4254.  
  4255. Example:
  4256.  
  4257.   Using the file handle from a previous open or create operation, read 1024
  4258.   bytes at the current file pointer into the buffer named buff.
  4259.  
  4260.   buff    db      1024 dup (?)    ; buffer for read
  4261.  
  4262.   fhandle dw      ?               ; contains file handle
  4263.           .
  4264.           .
  4265.           .
  4266.           mov     ah,3fh          ; function number
  4267.           mov     dx,seg buff     ; buffer address
  4268.           mov     ds,dx
  4269.           mov     dx,offset buff
  4270.           mov     bx,fhandle      ; file handle
  4271.           mov     cx,1024         ; length to read
  4272.           int     21h             ; transfer to MS-DOS
  4273.           jc      error           ; jump, read failed
  4274.  
  4275.           cmp     ax,cx           ; check length of read
  4276.           jl      done            ; jump, end of file
  4277.           .
  4278.           .
  4279.           .
  4280.  
  4281.  
  4282. ────────────────────────────────────────────────────────────────────────────
  4283. Int 21H                                                                [2.0]
  4284. Function 40H (64)
  4285. Write file or device
  4286. ────────────────────────────────────────────────────────────────────────────
  4287.  
  4288.   Given a valid file handle from a previous open or create operation, a
  4289.   buffer address, and a length in bytes, transfers data from the buffer into
  4290.   the file and then updates the file pointer position.
  4291.  
  4292. Call with:
  4293.  
  4294.   AH            = 40H
  4295.   BX            = handle
  4296.   CX            = number of bytes to write
  4297.   DS:DX         = segment:offset of buffer
  4298.  
  4299. Returns:
  4300.  
  4301.   If function successful
  4302.  
  4303.   Carry flag    = clear
  4304.   AX            = bytes transferred
  4305.  
  4306.   If function unsuccessful
  4307.  
  4308.   Carry flag    = set
  4309.   AX            = error code
  4310.  
  4311. Notes:
  4312.  
  4313.   ■ If the carry flag is returned clear but AX < CX, then a partial record
  4314.     was written or there is an error. This can be caused by a Ctrl-Z (1AH)
  4315.     embedded in the data if the destination is a character device in cooked
  4316.     mode or by a disk full condition if the destination is a file.
  4317.  
  4318.   ■ If the function is called with CX = 0, the file is truncated or extended
  4319.     to the current file pointer position.
  4320.  
  4321.   ■ [3.0+] If the program is running on a network, the user must have Write
  4322.     access rights to the directory and file.
  4323.  
  4324. Example:
  4325.  
  4326.   Using the handle from a previous open or create operation, write 1024
  4327.   bytes to disk at the current file pointer from the buffer named buff.
  4328.  
  4329.   buff    db      1024 dup (?)    ; buffer for write
  4330.  
  4331.   fhandle dw      ?               ; contains file handle
  4332.           .
  4333.           .
  4334.           .
  4335.           mov     ah,40h          ; function number
  4336.           mov     dx,seg buff     ; buffer address
  4337.           mov     ds,dx
  4338.           mov     dx,offset buff
  4339.           mov     bx,fhandle      ; file handle
  4340.           mov     cx,1024         ; length to write
  4341.           int     21h             ; transfer to MS-DOS
  4342.           jc      error           ; jump, write failed
  4343.           cmp     ax,1024         ; entire record written?
  4344.           jne     error           ; no, jump
  4345.           .
  4346.           .
  4347.           .
  4348.  
  4349.  
  4350. ────────────────────────────────────────────────────────────────────────────
  4351. Int 21H                                                                [2.0]
  4352. Function 41H (65)
  4353. Delete file
  4354. ────────────────────────────────────────────────────────────────────────────
  4355.  
  4356.   Deletes a file from the specified or default disk and directory.
  4357.  
  4358. Call with:
  4359.  
  4360.   AH            = 41H
  4361.   DS:DX         = segment:offset of ASCIIZ pathname
  4362.  
  4363. Returns:
  4364.  
  4365.   If function successful
  4366.  
  4367.   Carry flag    = clear
  4368.  
  4369.   If function unsuccessful
  4370.  
  4371.   Carry flag    = set
  4372.   AX            = error code
  4373.  
  4374. Notes:
  4375.  
  4376.   ■ This function deletes a file by replacing the first character of its
  4377.     filename in the directory with the character e (E5H) and marking the
  4378.     file's clusters as "free" in the disk's file allocation table. The
  4379.     actual data stored in those clusters is not overwritten.
  4380.  
  4381.   ■ Only one file at a time may be deleted with this function. Unlike the
  4382.     FCB-related Delete File function (Int 21H Function 13H), the * and ?
  4383.     wildcard characters are not allowed in the file specification.
  4384.  
  4385.   ■ The function fails if:
  4386.  
  4387.     ∙ any element of the pathname does not exist.
  4388.  
  4389.     ∙ the designated file exists but has the read-only attribute. (Int 21H
  4390.       Function 43H can be used to examine and modify a file's attribute
  4391.       before attempting to delete it.)
  4392.  
  4393.     ∙ [3.0+] the program is running on a network, and the user running the
  4394.       program has insufficient access rights.
  4395.  
  4396. Example:
  4397.  
  4398.   Delete the file named MYFILE.DAT from the directory \MYDIR on drive C.
  4399.  
  4400.   fname   db      'C:\MYDIR\MYFILE.DAT',0
  4401.           .
  4402.           .
  4403.           .
  4404.           mov     ah,41h          ; function number
  4405.           mov     dx,seg fname    ; filename address
  4406.           mov     ds,dx
  4407.           mov     dx,offset fname
  4408.           int     21h             ; transfer to MS-DOS
  4409.           jc      error           ; jump if delete failed
  4410.           .
  4411.           .
  4412.           .
  4413.  
  4414.  
  4415. ────────────────────────────────────────────────────────────────────────────
  4416. Int 21H                                                                [2.0]
  4417. Function 42H (66)
  4418. Set file pointer
  4419. ────────────────────────────────────────────────────────────────────────────
  4420.  
  4421.   Sets the file location pointer relative to the start of file, end of file,
  4422.   or current file position.
  4423.  
  4424. Call with:
  4425.  
  4426.   AH            = 42H
  4427.   AL            = method code
  4428.                   00H absolute offset from start of file
  4429.                   01H signed offset from current file pointer
  4430.                   02H signed offset from end of file
  4431.   BX            = handle
  4432.   CX            = most significant half of offset
  4433.   DX            = least significant half of offset
  4434.  
  4435. Returns:
  4436.  
  4437.   If function successful
  4438.  
  4439.   Carry flag    = clear
  4440.   DX            = most significant half of resulting file pointer
  4441.   AX            = least significant half of resulting file pointer
  4442.  
  4443.   If function unsuccessful
  4444.  
  4445.   Carry flag    = set
  4446.   AX            = error code
  4447.  
  4448. Notes:
  4449.  
  4450.   ■ This function uses a method code and a double-precision (32-bit) value
  4451.     to set the file pointer. The next record read or written in the file
  4452.     will begin at the new file pointer location. No matter what method is
  4453.     used in the call to this function, the file pointer returned in DX:AX is
  4454.     always the resulting absolute byte offset from the start of file.
  4455.  
  4456.   ■ Method 02H may be used to find the size of the file by calling Int 21H
  4457.     Function 42H with an offset of 0 and examining the pointer location
  4458.     that is returned.
  4459.  
  4460.   ■ Using methods 01H or 02H, it is possible to set the file pointer to a
  4461.     location that is before the start of file. If this is done, no error is
  4462.     returned by this function, but an error will be encountered upon a
  4463.     subsequent attempt to read or write the file.
  4464.  
  4465. Examples:
  4466.  
  4467.   Using the file handle from a previous open or create operation, set the
  4468.   current file pointer position to 1024 bytes after the start of file.
  4469.  
  4470.   fhandle dw      ?
  4471.           .
  4472.           .
  4473.           .
  4474.           mov     ah,42h          ; function number
  4475.           mov     al,0            ; method = absolute
  4476.           mov     bx,fhandle      ; file handle
  4477.           mov     cx,0            ; upper half of offset
  4478.           mov     dx,1024         ; lower half of offset
  4479.           int     21h             ; transfer to MS-DOS
  4480.           jc      error           ; jump, function failed
  4481.           .
  4482.           .
  4483.           .
  4484.  
  4485.   The following subroutine accepts a record number, record size, and handle
  4486.   and sets the file pointer appropriately.
  4487.  
  4488.   ; call this routine with BX = handle
  4489.   ;                        AX = record number
  4490.   ;                        CX = record size
  4491.   ; returns all registers unchanged
  4492.   ;
  4493.   setptr  proc    near
  4494.           push    ax              ; save record number
  4495.           push    cx              ; save record size
  4496.           push    dx              ; save whatever's in DX
  4497.           mul     cx              ; size * record number
  4498.           mov     cx,ax           ; upper part to CX
  4499.           xchg    cx,dx           ; lower part to DX
  4500.           mov     ax,4200h        ; function number & method
  4501.           int     21h             ; transfer to MS-DOS
  4502.           pop     dx              ; restore previous DX
  4503.           pop     cx              ; restore record size
  4504.           pop     ax              ; restore record number
  4505.           ret                     ; back to caller
  4506.   setptr  endp
  4507.  
  4508.  
  4509. ────────────────────────────────────────────────────────────────────────────
  4510. Int 21H                                                                [2.0]
  4511. Function 43H (67)
  4512. Get or set file attributes
  4513. ────────────────────────────────────────────────────────────────────────────
  4514.  
  4515.   Obtains or alters the attributes of a file (read-only, hidden, system, or
  4516.   archive) or directory.
  4517.  
  4518. Call with:
  4519.  
  4520.   AH            = 43H
  4521.   AL            = 00H       to get attributes
  4522.                   01H       to set attributes
  4523.  
  4524.   CX            = file attribute, if AL = 01H (bits can be combined)
  4525.  
  4526.                   Bit(s)    Significance (if set)
  4527.                   0         read-only
  4528.                   1         hidden
  4529.                   2         system
  4530.                   3─4       reserved (0)
  4531.                   5         archive
  4532.                   6─15      reserved (0)
  4533.  
  4534.   DS:DX         = segment:offset of ASCIIZ pathname
  4535.  
  4536. Returns:
  4537.  
  4538.   If function successful
  4539.  
  4540.   Carry flag    = clear
  4541.   CX            = file attribute
  4542.  
  4543.                   Bit(s)    Significance (if set)
  4544.                   0         read-only
  4545.                   1         hidden
  4546.                   2         system
  4547.                   3         volume label
  4548.                   4         directory
  4549.                   5         archive
  4550.                   6─15      reserved (0)
  4551.  
  4552.   If function unsuccessful
  4553.  
  4554.   Carry flag    = set
  4555.   AX            = error code
  4556.  
  4557. Notes:
  4558.  
  4559.   ■ Bits 3 and 4 of register CX must always be clear (0) when this function
  4560.     is called; in other words, you cannot change an existing file into a
  4561.     directory or volume label. However, you can assign the "hidden"
  4562.     attribute to an existing directory with this function.
  4563.  
  4564.   ■ [3.0+] If the program is running on a network, the user must have Create
  4565.     access rights to the directory containing the file whose attribute is to
  4566.     be modified.
  4567.  
  4568. Example:
  4569.  
  4570.   Change the attribute of the file D:\MYDIR\MYFILE.DAT to read-only, so that
  4571.   it cannot be accidentally modified or deleted by other application
  4572.   programs.
  4573.  
  4574.   rdonly  equ     01h             ; file attributes
  4575.   hidden  equ     02h
  4576.   system  equ     04h
  4577.   volume  equ     08h
  4578.   subdir  equ     10h
  4579.   archive equ     20h
  4580.  
  4581.   fname   db      'D:\MYDIR\MYFILE.DAT',0
  4582.           .
  4583.           .
  4584.           .
  4585.           mov     ah,43h          ; function number
  4586.           mov     al,01h          ; subfunction = modify
  4587.           mov     cx,rdonly       ; read-only attribute
  4588.           mov     dx,seg fname    ; filename address
  4589.           mov     ds,dx
  4590.           mov     dx,offset fname
  4591.           int     21h             ; transfer to MS-DOS
  4592.           jc      error           ; jump if modify failed
  4593.           .
  4594.           .
  4595.           .
  4596.  
  4597.  
  4598. ────────────────────────────────────────────────────────────────────────────
  4599. Int 21H                                                                [2.0]
  4600. Function 44H (68)
  4601. IOCTL (I/O control)
  4602. ────────────────────────────────────────────────────────────────────────────
  4603.  
  4604.   Provides a direct path of communication between an application program and
  4605.   a device driver. Allows a program to obtain hardware-dependent information
  4606.   and to request operations that are not supported by other MS-DOS function
  4607.   calls.
  4608.  
  4609.   The IOCTL subfunctions and the MS-DOS versions in which they first became
  4610.   available are:
  4611.  
  4612.  
  4613.   Subfunction     Name                                      MS-DOS version
  4614.   ──────────────────────────────────────────────────────────────────────────
  4615.   00H            Get Device Information                    2.0
  4616.   01H            Set Device Information                    2.0
  4617.   02H            Receive Control Data from Character       2.0
  4618.                   Device Driver
  4619.   03H            Send Control Data to Character Device     2.0
  4620.                   Driver
  4621.   04H            Receive Control Data from Block Device    2.0
  4622.                   Driver
  4623.   05H            Send Control Data to Block Device Driver  2.0
  4624.   06H            Check Input Status                        2.0
  4625.   07H            Check Output Status                       2.0
  4626.   08H            Check If Block Device Is Removable        3.0
  4627.   09H            Check If Block Device Is Remote           3.1
  4628.   0AH (10)       Check If Handle Is Remote                 3.1
  4629.   0BH (11)       Change Sharing Retry Count                3.1
  4630.   0CH (12)       Generic I/O Control for Character Devices
  4631.                   CL = 45H: Set Iteration Count             3.2
  4632.                   CL = 4AH: Select Code Page                3.3
  4633.                   CL = 4CH: Start Code Page Preparation     3.3
  4634.                   CL = 4DH: End Code Page Preparation       3.3
  4635.                   CL = 5FH: Set Display Information         4.0
  4636.                   CL = 65H: Get Iteration Count             3.2
  4637.                   CL = 6AH: Query Selected Code Page        3.3
  4638.                   CL = 6BH: Query Prepare List              3.3
  4639.                   CL = 7FH: Get Display Information         4.0
  4640.   0DH (13)       Generic I/O Control for Block Devices
  4641.                   CL = 40H: Set Device Parameters           3.2
  4642.                   CL = 41H: Write Track                     3.2
  4643.                   CL = 42H: Format and Verify Track         3.2
  4644.                   CL = 47H: Set Access Flag                 4.0
  4645.                   CL = 60H: Get Device Parameters           3.2
  4646.                   CL = 61H: Read Track                      3.2
  4647.                   CL = 62H: Verify Track                    3.2
  4648.                   CL = 67H: Get Access Flag                 4.0
  4649.   0EH (14)       Get Logical Drive Map                     3.2
  4650.   0FH (15)       Set Logical Drive Map                     3.2
  4651.   ──────────────────────────────────────────────────────────────────────────
  4652.  
  4653.  
  4654.   Only IOCTL Subfunctions 00H, 06H, and 07H may be used for handles
  4655.   associated with files. Subfunctions 00H─08H are not supported on network
  4656.   devices.
  4657.  
  4658.  
  4659. ────────────────────────────────────────────────────────────────────────────
  4660. Int 21H                                                                [2.0]
  4661. Function 44H (68) Subfunction 00H
  4662. IOCTL: get device information
  4663. ────────────────────────────────────────────────────────────────────────────
  4664.  
  4665.   Returns a device information word for the file or device associated with
  4666.   the specified handle.
  4667.  
  4668. Call with:
  4669.  
  4670.   AH            = 44H
  4671.   AL            = 00H
  4672.   BX            = handle
  4673.  
  4674. Returns:
  4675.  
  4676.   If function successful
  4677.  
  4678.   Carry flag    = clear
  4679.   DX            = device information word
  4680.  
  4681.                   For a file:
  4682.  
  4683.                   Bit(s)    Significance
  4684.                   0─5       drive number (0 = A, 1 = B, etc.)
  4685.                   6         0 if file has been written
  4686.                             1 if file has not been written
  4687.                   7         0, indicating a file
  4688.                   8─15      reserved
  4689.  
  4690.   For a device:
  4691.  
  4692.                   Bit(s)    Significance
  4693.                   0         1 if standard input
  4694.                   1         1 if standard output
  4695.                   2         1 if NUL device
  4696.                   3         1 if clock device
  4697.                   4         reserved
  4698.                   5         0 if handle in ASCII mode
  4699.                             1 if handle in binary mode
  4700.                   6         0 if end of file on input
  4701.                   7         1, indicating a device
  4702.                   8─13      reserved
  4703.                   14        0 if IOCTL subfunctions 02H and 03H not
  4704.                             supported
  4705.                             1 if IOCTL subfunctions 02H and 03H supported
  4706.                   15        reserved
  4707.                             If function unsuccessful
  4708.  
  4709.   Carry flag    = set
  4710.   AX            = error code
  4711.  
  4712. Notes:
  4713.  
  4714.   ■ Bits 8─15 of DX correspond to the upper 8 bits of the device-driver
  4715.     attribute word.
  4716.  
  4717.   ■ Bit 5 of the device information word for a handle associated with a
  4718.     character device signifies whether MS-DOS considers that handle to be in
  4719.     binary ("raw") mode or ASCII ("cooked") mode. In ASCII mode, MS-DOS
  4720.     filters the character stream and may take special action when the
  4721.     characters Ctrl-C, Ctrl-S, Ctrl-P, Ctrl-Z, and carriage return are
  4722.     detected. In binary mode, all characters are treated as data, and the
  4723.     exact number of characters requested is always read or written.
  4724.  
  4725. Example:
  4726.  
  4727.   See Int 21H Function 44H Subfunction 01H.
  4728.  
  4729.  
  4730. ────────────────────────────────────────────────────────────────────────────
  4731. Int 21H                                                                [2.0]
  4732. Function 44H (68) Subfunction 01H
  4733. IOCTL: set device information
  4734. ────────────────────────────────────────────────────────────────────────────
  4735.  
  4736.   Sets certain flags for a handle associated with a character device. This
  4737.   subfunction may not be used for a handle that is associated with a file.
  4738.  
  4739. Call with:
  4740.  
  4741.   AH            = 44H
  4742.   AL            = 01H
  4743.   BX            = handle
  4744.   DX            = device information word
  4745.  
  4746.                   Bit(s)    Significance
  4747.                   0         1 if standard input
  4748.                   1         1 if standard output
  4749.                   2         1 if NUL device
  4750.                   3         1 if clock device
  4751.                   4         reserved (0)
  4752.                   5         0 to select ASCII mode
  4753.                             1 to select binary mode
  4754.                   6         reserved (0)
  4755.                   7         1, indicating a device
  4756.                   8─15      reserved (0)
  4757.  
  4758. Returns:
  4759.  
  4760.   If function successful
  4761.  
  4762.   Carry flag    = clear
  4763.  
  4764.   If function unsuccessful
  4765.  
  4766.   Carry flag    = set
  4767.   AX            = error code
  4768.  
  4769. Notes:
  4770.  
  4771.   ■ If register DH does not contain 00H, control returns to the program with
  4772.     the carry flag set and error code 0001H (invalid function) in register
  4773.     AX.
  4774.  
  4775.   ■ Bit 5 of the information word for a handle associated with a character
  4776.     device signifies whether MS-DOS considers that handle to be in binary
  4777.     ("raw") or ASCII ("cooked") mode. See Notes for Int 21H Function 44H
  4778.     Subfunction 00H.
  4779.  
  4780. Example:
  4781.  
  4782.   Place the standard output handle into binary ("raw") mode. This speeds up
  4783.   output by disabling checking for Ctrl-C, Ctrl-S, and Ctrl-P between each
  4784.   character.
  4785.  
  4786.           .
  4787.           .
  4788.           .
  4789.                                   ; get device information
  4790.           mov     ax,4400h        ; function & subfunction
  4791.           mov     bx,1            ; standard output handle
  4792.           int     21h             ; transfer to MS-DOS
  4793.  
  4794.           mov     dh,0            ; force DH = 0
  4795.           or      dl,20h          ; set binary mode bit
  4796.  
  4797.                                   ; set device information
  4798.           mov     ax,4401h        ; function & subfunction
  4799.           int     21h             ; transfer to MS-DOS
  4800.           .
  4801.           .
  4802.           .
  4803.  
  4804.  
  4805. ────────────────────────────────────────────────────────────────────────────
  4806. Int 21H                                                                [2.0]
  4807. Function 44H (68) Subfunction 02H
  4808. IOCTL: read control data from character device driver
  4809. ────────────────────────────────────────────────────────────────────────────
  4810.  
  4811.   Reads control data from a character-device driver. The length and contents
  4812.   of the data are specific to each device driver and do not follow any
  4813.   standard format. This function does not necessarily result in any input
  4814.   from the physical device.
  4815.  
  4816. Call with:
  4817.  
  4818.   AH            = 44H
  4819.   AL            = 02H
  4820.   BX            = handle
  4821.   CX            = number of bytes to read
  4822.   DS:DX         = segment:offset of buffer
  4823.  
  4824. Returns:
  4825.  
  4826.   If function successful
  4827.  
  4828.   Carry flag    = clear
  4829.   AX            = bytes read
  4830.  
  4831.   and buffer contains control data from driver
  4832.  
  4833.   If function unsuccessful
  4834.  
  4835.   Carry flag    = set
  4836.   AX            = error code
  4837.  
  4838. Notes:
  4839.  
  4840.   ■ If supported by the driver, this subfunction can be used to obtain
  4841.     hardware-dependent status and availability information that is not
  4842.     supported by other MS-DOS function calls.
  4843.  
  4844.   ■ Character-device drivers are not required to support IOCTL Subfunction
  4845.     02H. A program can test bit 14 of the device information word returned
  4846.     by IOCTL Subfunction 00H to determine whether the driver supports this
  4847.     subfunction. If Subfunction 02H is requested and the driver does not
  4848.     have the ability to process control data, control returns to the program
  4849.     with the carry flag set and error code 0001H (invalid function) in
  4850.     register AX.
  4851.  
  4852. Example:
  4853.  
  4854.   Read a control string from the standard list driver into the buffer buff.
  4855.  
  4856.   stdprn  equ     4               ; standard list handle
  4857.   buflen  equ     64              ; length of buffer
  4858.  
  4859.   ctllen  dw      ?               ; length of control string
  4860.   buff    db      buflen dup (0)  ; receives control string
  4861.           .
  4862.           .
  4863.           .
  4864.           mov     ax,4402h        ; function & subfunction
  4865.           mov     bx,stdprn       ; standard list handle
  4866.           mov     cx,buflen       ; buffer length
  4867.           mov     dx,seg buff     ; buffer address
  4868.           mov     ds,dx
  4869.           mov     dx,offset buff
  4870.           int     21h             ; transfer to MS-DOS
  4871.           jc      error           ; jump if read failed
  4872.           mov     ctllen,ax       ; save control string length
  4873.           .
  4874.           .
  4875.           .
  4876.  
  4877.  
  4878. ────────────────────────────────────────────────────────────────────────────
  4879. Int 21H                                                                [2.0]
  4880. Function 44H (68) Subfunction 03H
  4881. IOCTL: write control data to character-device driver
  4882. ────────────────────────────────────────────────────────────────────────────
  4883.  
  4884.   Transfers control data from an application to a character-device driver.
  4885.   The length and contents of the data are specific to each device driver and
  4886.   do not follow any standard format. This function does not necessarily
  4887.   result in any output to the physical device.
  4888.  
  4889. Call with:
  4890.  
  4891.   AH            = 44H
  4892.   AL            = 03H
  4893.   BX            = handle
  4894.   CX            = number of bytes to write
  4895.   DS:DX         = segment:offset of data
  4896.  
  4897. Returns:
  4898.  
  4899.   If function successful
  4900.  
  4901.   Carry flag    = clear
  4902.   AX            = bytes transferred
  4903.  
  4904.   If function unsuccessful
  4905.  
  4906.   Carry flag    = set
  4907.   AX            = error code
  4908.  
  4909. Notes:
  4910.  
  4911.   ■ If supported by the driver, this subfunction can be used to request
  4912.     hardware-dependent operations (such as setting baud rate for a serial
  4913.     port) that are not supported by other MS-DOS function calls.
  4914.  
  4915.   ■ Character-device drivers are not required to support IOCTL Subfunction
  4916.     03H. A program can test bit 14 of the device information word returned
  4917.     by IOCTL Subfunction 00H to determine whether the driver supports this
  4918.     subfunction. If Subfunction 03H is requested and the driver does not
  4919.     have the ability to process control data, control returns to the program
  4920.     with the carry flag set and error code 0001H (invalid function) in
  4921.     register AX.
  4922.  
  4923. Example:
  4924.  
  4925.   Write a control string from the buffer buff to the standard list device
  4926.   driver. The length of the string is assumed to be in the variable ctllen.
  4927.  
  4928.   stdprn  equ     4               ; standard list handle
  4929.   buflen  equ     64              ; length of buffer
  4930.  
  4931.   ctllen  dw      ?               ; length of control data
  4932.   buff    db      buflen dup (?)  ; contains control data
  4933.           .
  4934.           .
  4935.           .
  4936.           mov     ax,4403h        ; function & subfunction
  4937.           mov     bx,stdprn       ; standard list handle
  4938.           mov     dx,seg buff     ; buffer address
  4939.           mov     ds,dx
  4940.           mov     dx,offset buff
  4941.           mov     cx,ctllen       ; length of control data
  4942.           int     21h             ; transfer to MS-DOS
  4943.           jc      error           ; jump if write failed
  4944.           .
  4945.           .
  4946.           .
  4947.  
  4948.  
  4949.  
  4950.  
  4951. ────────────────────────────────────────────────────────────────────────────
  4952. Int 21H                                                                [2.0]
  4953. Function 44H (68) Subfunction 04H
  4954. IOCTL: read control data from block-device driver
  4955. ────────────────────────────────────────────────────────────────────────────
  4956.  
  4957.   Transfers control data from a block-device driver directly into an
  4958.   application program's buffer. The length and contents of the data are
  4959.   specific to each device driver and do not follow any standard format. This
  4960.   function does not necessarily result in any input from the physical
  4961.   device.
  4962.  
  4963. Call with:
  4964.  
  4965.   AH            = 44H
  4966.   AL            = 04H
  4967.   BL            = drive code (0 = default, 1 = A, 2 = B, etc.)
  4968.   CX            = number of bytes to read
  4969.   DS:DX         = segment:offset of buffer
  4970.  
  4971. Returns:
  4972.  
  4973.   If function successful
  4974.  
  4975.   Carry flag    = clear
  4976.   AX            = bytes transferred
  4977.  
  4978.   and buffer contains control data from device driver
  4979.  
  4980.   If function unsuccessful
  4981.  
  4982.   Carry flag    = set
  4983.   AX            = error code
  4984.  
  4985. Notes:
  4986.  
  4987.   ■ When supported by the driver, this subfunction can be used to obtain
  4988.     hardware-dependent status and availability information that is not
  4989.     provided by other MS-DOS function calls.
  4990.  
  4991.   ■ Block-device drivers are not required to support IOCTL Subfunction 04H.
  4992.     If this subfunction is requested and the driver does not have the
  4993.     ability to process control data, control returns to the program with the
  4994.     carry flag set and error code 0001H (invalid function) in register AX.
  4995.  
  4996. Example:
  4997.  
  4998.   Read a control string from the block-device driver for drive C into the
  4999.   buffer buff.
  5000.  
  5001.   buflen  equ     64              ; length of buffer
  5002.  
  5003.   ctllen  dw      ?               ; length of control string
  5004.   buff    db      buflen dup (0)  ; receives control string
  5005.           .
  5006.           .
  5007.           .
  5008.           mov     ax,4404h        ; function & subfunction
  5009.           mov     bl,3            ; drive C = 3
  5010.           mov     cx,buflen       ; buffer length
  5011.           mov     dx,seg buff     ; buffer address
  5012.  
  5013.           mov     ds,dx
  5014.           mov     dx,offset buff
  5015.           int     21h             ; transfer to MS-DOS
  5016.           jc      error           ; jump if read failed
  5017.           mov     ctllen,ax       ; save control string length
  5018.           .
  5019.           .
  5020.           .
  5021.  
  5022.  
  5023. ────────────────────────────────────────────────────────────────────────────
  5024. Int 21H                                                                [2.0]
  5025. Function 44H (68) Subfunction 05H
  5026. IOCTL: write control data to block-device driver
  5027. ────────────────────────────────────────────────────────────────────────────
  5028.  
  5029.   Transfers control data from an application program directly to a
  5030.   block-device driver. The length and contents of the control data are
  5031.   specific to each device driver and do not follow any standard format. This
  5032.   function does not necessarily result in any output to the physical device.
  5033.  
  5034. Call with:
  5035.  
  5036.   AH            = 44H
  5037.   AL            = 05H
  5038.   BL            = drive code (0 = default, 1 = A, 2 = B, etc.)
  5039.   CX            = number of bytes to write
  5040.   DS:DX         = segment:offset of data
  5041.  
  5042. Returns:
  5043.  
  5044.   If function successful
  5045.  
  5046.   Carry flag    = clear
  5047.   AX            = bytes transferred
  5048.  
  5049.   If function unsuccessful
  5050.  
  5051.   Carry flag    = set
  5052.   AX            = error code
  5053.  
  5054. Notes:
  5055.  
  5056.   ■ When supported by the driver, this subfunction can be used to request
  5057.     hardware-dependent operations (such as tape rewind or disk eject) that
  5058.     are not provided by other MS-DOS function calls.
  5059.  
  5060.   ■ Block-device drivers are not required to support IOCTL Subfunction 05H.
  5061.     If this subfunction is requested and the driver does not have the
  5062.     ability to process control data, control returns to the program with the
  5063.     carry flag set and error code 0001H (invalid function) in register AX.
  5064.  
  5065. Example:
  5066.  
  5067.   Write a control string from the buffer buff to the block-device driver for
  5068.   drive C. The length of the string is assumed to be in the variable ctllen.
  5069.  
  5070.   buflen  equ     64              ; length of buffer
  5071.  
  5072.   ctllen  dw      ?               ; length of control data
  5073.   buff    db      buflen dup (?)  ; contains control data
  5074.           .
  5075.           .
  5076.           .
  5077.           mov     ax,4405h        ; function & subfunction
  5078.           mov     bl,3            ; drive C = 3
  5079.           mov     dx,seg buff     ; buffer address
  5080.           mov     ds,dx
  5081.           mov     dx,offset buff
  5082.           mov     cx,ctllen       ; length of control data
  5083.           int     21h             ; transfer to MS-DOS
  5084.           jc      error           ; jump if write failed
  5085.           .
  5086.           .
  5087.           .
  5088.  
  5089.  
  5090. ────────────────────────────────────────────────────────────────────────────
  5091. Int 21H                                                                [2.0]
  5092. Function 44H (68) Subfunction 06H
  5093. IOCTL: check input status
  5094. ────────────────────────────────────────────────────────────────────────────
  5095.  
  5096.   Returns a code indicating whether the device or file associated with a
  5097.   handle is ready for input.
  5098.  
  5099. Call with:
  5100.  
  5101.   AH            = 44H
  5102.   AL            = 06H
  5103.   BX            = handle
  5104.  
  5105. Returns:
  5106.  
  5107.   If function successful
  5108.  
  5109.   Carry flag    = clear
  5110.  
  5111.   and, for a device:
  5112.  
  5113.   AL            = 00H       if device not ready
  5114.                   FFH       if device ready
  5115.  
  5116.   or, for a file:
  5117.  
  5118.   AL            = 00H       if file pointer at EOF
  5119.                   FFH       if file pointer not at EOF
  5120.  
  5121.   If function unsuccessful
  5122.  
  5123.   Carry flag    = set
  5124.   AX            = error code
  5125.  
  5126. Note:
  5127.  
  5128.   ■ This function can be used to check the status of character devices, such
  5129.     as the serial port, that do not have their own "traditional" MS-DOS
  5130.     status calls.
  5131.  
  5132. Example:
  5133.  
  5134.   Check whether a character is ready from the standard auxiliary device
  5135.   (usually COM1).
  5136.  
  5137.   stdaux  equ     3               ; standard auxiliary handle
  5138.           .
  5139.           .
  5140.           .
  5141.           mov     ax,4406h        ; function & subfunction
  5142.           mov     bx,stdaux       ; standard auxiliary handle
  5143.           int     21h             ; transfer to MS-DOS
  5144.           jc      error           ; jump if function failed
  5145.           or      al,al           ; test status flag
  5146.           jnz     ready           ; jump if character ready
  5147.           .
  5148.           .
  5149.           .
  5150.  
  5151.  
  5152. ────────────────────────────────────────────────────────────────────────────
  5153. Int 21H                                                                [2.0]
  5154. Function 44H (68) Subfunction 07H
  5155. IOCTL: check output status
  5156. ────────────────────────────────────────────────────────────────────────────
  5157.  
  5158.   Returns a code indicating whether the device associated with a handle is
  5159.   ready for output.
  5160.  
  5161. Call with:
  5162.  
  5163.   AH            = 44H
  5164.   AL            = 07H
  5165.   BX            = handle
  5166.  
  5167. Returns:
  5168.  
  5169.   If function successful
  5170.  
  5171.   Carry flag    = clear
  5172.  
  5173.   and, for a device:
  5174.  
  5175.   AL            = 00H       if device not ready
  5176.                   FFH       if device ready
  5177.  
  5178.   or, for a file:
  5179.  
  5180.   AL            = FFH
  5181.  
  5182.   If function unsuccessful
  5183.  
  5184.   Carry flag    = set
  5185.   AX            = error code
  5186.  
  5187. Note:
  5188.  
  5189.   ■ When used with a handle for a file, this function always returns a ready
  5190.     status, even if the disk is full or no disk is in the drive.
  5191.  
  5192. Example:
  5193.  
  5194.   Check whether the standard auxiliary device (usually COM1) can accept a
  5195.   character for output.
  5196.  
  5197.   stdaux  equ     3               ; standard auxiliary handle
  5198.           .
  5199.           .
  5200.           .
  5201.           mov     ax,4407h        ; function & subfunction
  5202.           mov     bx,stdaux       ; standard auxiliary handle
  5203.           int     21h             ; transfer to MS-DOS
  5204.           jc      error           ; jump if function failed
  5205.           or      al,al           ; test status flag
  5206.           jnz     ready           ; jump if not busy
  5207.           .
  5208.           .
  5209.           .
  5210.  
  5211.  
  5212. ────────────────────────────────────────────────────────────────────────────
  5213. Int 21H                                                                [3.0]
  5214. Function 44H (68) Subfunction 08H
  5215. IOCTL: check if block device is removable
  5216. ────────────────────────────────────────────────────────────────────────────
  5217.  
  5218.   Checks whether the specified block device contains a removable storage
  5219.   medium, such as a floppy disk.
  5220.  
  5221. Call with:
  5222.  
  5223.   AH            = 44H
  5224.   AL            = 08H
  5225.   BL            = drive number (0 = default, 1 = A, 2 = B, etc.)
  5226.  
  5227. Returns:
  5228.  
  5229.   If function successful
  5230.  
  5231.   Carry flag    = clear
  5232.   AL            = 00H       if medium is removable
  5233.                   01H       if medium is not removable
  5234.  
  5235.   If function unsuccessful
  5236.  
  5237.   Carry flag    = set
  5238.   AX            = error code
  5239.  
  5240. Notes:
  5241.  
  5242.   ■ If a file is not found as expected on a particular drive, a program can
  5243.     use this subfunction to determine whether the user should be prompted to
  5244.     insert another disk.
  5245.  
  5246.   ■ This subfunction may not be used for a network drive.
  5247.  
  5248.   ■ Block drivers are not required to support Subfunction 08H. If this
  5249.     subfunction is requested and the block device cannot supply the
  5250.     information, control returns to the program with the carry flag set and
  5251.     error code 0001H (invalid function) in register AX.
  5252.  
  5253. Example:
  5254.  
  5255.   Check whether drive C is removable.
  5256.  
  5257.           .
  5258.           .
  5259.           .
  5260.           mov     ax,4408h        ; function & subfunction
  5261.           mov     bl,3            ; drive 3 = C
  5262.           int     21h             ; transfer to MS-DOS
  5263.           jc      error           ; jump if function failed
  5264.           and     al,1            ; test type of medium
  5265.           jnz     fixed           ; jump if not removable
  5266.           .
  5267.           .
  5268.           .
  5269.  
  5270.  
  5271. ────────────────────────────────────────────────────────────────────────────
  5272. Int 21H                                                                [3.1]
  5273. Function 44H (68) Subfunction 09H
  5274. IOCTL: check if block device is remote
  5275. ────────────────────────────────────────────────────────────────────────────
  5276.  
  5277.   Checks whether the specified block device is local (attached to the
  5278.   computer running the program) or remote (redirected to a network server).
  5279.  
  5280. Call with:
  5281.  
  5282.   AH            = 44H
  5283.   AL            = 09H
  5284.   BL            = drive number (0 = default, 1 = A, 2 = B, etc.)
  5285.  
  5286. Returns:
  5287.  
  5288.   If function successful
  5289.  
  5290.   Carry flag    = clear
  5291.   DX            = device attribute word
  5292.                   bit 12        = 0 if drive is local
  5293.                                   1 if drive is remote
  5294.  
  5295.   If function unsuccessful
  5296.  
  5297.   Carry flag    = set
  5298.   AX            = error code
  5299.  
  5300. Note:
  5301.  
  5302.   ■ Use of this subfunction should be avoided. Application programs should
  5303.     not distinguish between files on local and remote devices.
  5304.  
  5305. Example:
  5306.  
  5307.   Check whether drive D is mounted on the machine running the program or is
  5308.   a network drive.
  5309.  
  5310.           .
  5311.           .
  5312.           .
  5313.           mov     ax,4409h        ; function & subfunction
  5314.           mov     bl,4            ; drive 4 = D
  5315.           int     21h             ; transfer to MS-DOS
  5316.           jc      error           ; jump if function failed
  5317.           and     dx,1000h        ; test local/remote bit
  5318.           jnz     remote          ; jump if network drive
  5319.           .
  5320.           .
  5321.           .
  5322.  
  5323.  
  5324. ────────────────────────────────────────────────────────────────────────────
  5325. Int 21H                                                                [3.1]
  5326. Function 44H (68) Subfunction 0AH (10)
  5327. IOCTL: check if handle is remote
  5328. ────────────────────────────────────────────────────────────────────────────
  5329.  
  5330.   Checks whether the specified handle refers to a file or device that is
  5331.   local (located on the PC that is running the program) or remote (located
  5332.   on a network server).
  5333.  
  5334. Call with:
  5335.  
  5336.   AH            = 44H
  5337.   AL            = 0AH
  5338.   BX            = handle
  5339.  
  5340. Returns:
  5341.  
  5342.   If function successful
  5343.  
  5344.   Carry flag    = clear
  5345.   DX            = attribute word for file or device
  5346.  
  5347.                   bit 15             = 0 if local
  5348.  
  5349.                                        1 if remote
  5350.  
  5351.                                        If function unsuccessful
  5352.  
  5353.   Carry flag    = set
  5354.   AX            = error code
  5355.  
  5356. Notes:
  5357.  
  5358.   ■ Application programs should not ordinarily attempt to distinguish
  5359.     between files on local and remote devices.
  5360.  
  5361.   ■ If the network has not been started, control returns to the calling
  5362.     program with the carry flag set and error code 0001H (invalid function)
  5363.     in register AX.
  5364.  
  5365. Example:
  5366.  
  5367.   Check if the handle saved in the variable fhandle is associated with a
  5368.   file or device on the machine running the program or on a network server.
  5369.  
  5370.   fhandle dw      ?               ; device handle
  5371.           .
  5372.           .
  5373.           .
  5374.           mov     ax,440ah        ; function & subfunction
  5375.           mov     bx,fhandle      ; file/device handle
  5376.           int     21h             ; transfer to MS-DOS
  5377.           jc      error           ; jump if function failed
  5378.           and     dx,8000h        ; test local/remote bit
  5379.           jnz     remote          ; jump if network handle
  5380.           .
  5381.           .
  5382.           .
  5383.  
  5384.  
  5385. ────────────────────────────────────────────────────────────────────────────
  5386. Int 21H                                                                [3.1]
  5387. Function 44H (68) Subfunction 0BH (11)
  5388. IOCTL: change sharing retry count
  5389. ────────────────────────────────────────────────────────────────────────────
  5390.  
  5391.   Sets the number of times MS-DOS retries a disk operation after a failure
  5392.   caused by a file-sharing violation before it returns an error to the
  5393.   requesting process. This subfunction is not available unless the
  5394.   file-sharing module (SHARE.EXE) is loaded.
  5395.  
  5396. Call with:
  5397.  
  5398.   AH            = 44H
  5399.   AL            = 0BH
  5400.   CX            = delays per retry (default = 1)
  5401.   DX            = number of retries (default = 3)
  5402.  
  5403. Returns:
  5404.  
  5405.   If function successful
  5406.  
  5407.   Carry flag    = clear
  5408.  
  5409.   If function unsuccessful
  5410.  
  5411.   Carry flag    = set
  5412.   AX            = error code
  5413.  
  5414. Notes:
  5415.  
  5416.   ■ The length of a delay is a machine-dependent value determined by the CPU
  5417.     type and clock speed. Each delay consists of the following instruction
  5418.     sequence:
  5419.  
  5420.           xor     cx,cx
  5421.           loop    $
  5422.  
  5423.   which executes 65,536 times before falling out of the loop.
  5424.  
  5425.   ■ The sharing retry count affects the behavior of the system as a whole
  5426.     and is not a local parameter for the process. If a program changes the
  5427.     sharing retry count, it should restore the default values before
  5428.     terminating.
  5429.  
  5430. Example:
  5431.  
  5432.   Change the number of automatic retries for a file-sharing violation to
  5433.   five.
  5434.  
  5435.           .
  5436.           .
  5437.           .
  5438.           mov     ax,440bh        ; function & subfunction
  5439.           mov     cx,1            ; delays per retry
  5440.           mov     dx,5            ; number of retries
  5441.           int     21h             ; transfer to MS-DOS
  5442.           jc      error           ; jump if function failed
  5443.           .
  5444.           .
  5445.           .
  5446.  
  5447.  
  5448. ────────────────────────────────────────────────────────────────────────────
  5449. Int 21H                                                                [3.2]
  5450. Function 44H (68) Subfunction 0CH (12)
  5451. IOCTL: generic I/O control for character devices
  5452. ────────────────────────────────────────────────────────────────────────────
  5453.  
  5454.   Provides a general-purpose mechanism for communication between application
  5455.   programs and character-device drivers.
  5456.  
  5457. Call with:
  5458.  
  5459.   AH            = 44H
  5460.   AL            = 0CH
  5461.   BX            = handle
  5462.   CH            = category (major) code:
  5463.                   00H = unknown
  5464.                   01H = COM1, COM2, COM3, or COM4 (3.3)
  5465.                   03H = CON (keyboard and display) (3.3)
  5466.                   05H = LPT1, LPT2, or LPT3 (3.2)
  5467.   CL            = function (minor) code:
  5468.                   45H = Set Iteration Count (3.2)
  5469.                   4AH = Select Code Page (3.3)
  5470.                   4CH = Start Code Page Preparation (3.3)
  5471.                   4DH = End Code Page Preparation (3.3)
  5472.                   5FH = Set Display Information (4.0)
  5473.                   65H = Get Iteration Count (3.2)
  5474.                   6AH = Query Selected Code Page (3.3)
  5475.                   6BH = Query Prepare List (3.3)
  5476.                   7FH = Get Display Information (4.0)
  5477.   DS:DX         = segment:offset of parameter block
  5478.  
  5479. Returns:
  5480.  
  5481.   If function successful
  5482.  
  5483.   Carry flag    = clear
  5484.  
  5485.   and, if called with CL = 65H, 6AH, 6BH, or 7FH
  5486.  
  5487.   DS:DX         = segment:offset of parameter block
  5488.  
  5489.   If function unsuccessful
  5490.  
  5491.   Carry flag    = set
  5492.   AX            = error code
  5493.  
  5494. Notes:
  5495.  
  5496.   ■ If the minor code is 45H (Set Iteration Count) or 65H (Get Iteration
  5497.     Count), the parameter block is simply a 2-byte buffer containing or
  5498.     receiving the iteration count for the printer. This call is valid only
  5499.     for printer drivers that support Output Until Busy, and determines the
  5500.     number of times the device driver will wait for the device to signal
  5501.     ready before returning from the output call.
  5502.  
  5503.   ■ The parameter block for minor code 4DH (End Code Page Preparation) has
  5504.     the following format:
  5505.  
  5506.           dw      2               ; length of following data
  5507.           dw      0               ; (reserved)
  5508.  
  5509.   ■ For MS-DOS version 3.3, the parameter block for minor codes 4AH (Select
  5510.     Code Page) and 6AH (Query Code Page) has the following format:
  5511.  
  5512.           dw      2               ; length of following data
  5513.           dw      ?               ; code page ID
  5514.  
  5515.   For MS-DOS version 4.0, minor codes 4AH and 6AH also set or get the
  5516.   double-byte character set (DBCS) lead byte table, and the following format
  5517.   is used:
  5518.  
  5519.           dw      (n+2)*2+1       ; length of following data
  5520.           dw      ?               ; code page ID
  5521.           db      start,end       ; DBCS lead byte range 1
  5522.           .
  5523.           .
  5524.           .
  5525.           db      start,end       ; DBCS lead byte range n
  5526.           db      0,0
  5527.  
  5528.   ■ The parameter block for minor code 4CH (Start Code Page Preparation) has
  5529.     the following format:
  5530.  
  5531.           dw      0               ; font type
  5532.                                   ; bit 0   = 0 downloaded
  5533.                                   ;         = 1 cartridge
  5534.                                   ; bits 1-15 = reserved (0)
  5535.           dw      (n+1)*2         ; length of remainder of
  5536.                                   ;   parameter block
  5537.           dw      n               ; number of code pages in
  5538.                                   ;   the following list
  5539.           dw      ?               ; code page 1
  5540.           dw      ?               ; code page 2
  5541.           .
  5542.           .
  5543.           .
  5544.           dw      ?               ; code page n
  5545.  
  5546.   ■ The parameter block for minor code 6BH (Query Prepare List) has the
  5547.     following format, assuming n hardware code pages and m prepared code
  5548.     pages (n <= 12, m <= 12):
  5549.  
  5550.           dw      (n+m+2)*2       ; length of following data
  5551.           dw      n               ; number of hardware code pages
  5552.           dw      ?               ; hardware code page 1
  5553.           dw      ?               ; hardware code page 2
  5554.           .
  5555.           .
  5556.           .
  5557.           dw      ?               ; hardware code page n
  5558.           dw      m               ; number of prepared code pages
  5559.           dw      ?               ; prepared code page 1
  5560.           dw      ?               ; prepared code page 2
  5561.           .
  5562.           .
  5563.           .
  5564.           dw      ?               ; prepared code page m
  5565.  
  5566.   ■ After a minor code 4CH (Start Code Page Preparation) call, the data
  5567.     defining the code page font is written to the driver using one or more
  5568.     calls to the IOCTL Write Control Data subfunction (Interrupt 21H,
  5569.     Function 44H, Subfunction 03H). The format of the data is device- and
  5570.     driver-specific. After the font data has been written to the driver, a
  5571.     minor code 4DH (End Code Page Preparation) call must be issued. If no
  5572.     data is written to the driver between the minor code 4CH and 4DH calls,
  5573.     the driver interprets the newly prepared code pages as hardware code
  5574.     pages.
  5575.  
  5576.   ■ A special variation of the minor code 4CH (Start Code Page Preparation)
  5577.     call, called "Refresh," is required to actually load the peripheral
  5578.     device with the prepared code pages. The refresh operation is obtained
  5579.     by requesting minor code 4CH with each code page position in the
  5580.     parameter block set to -1, followed by an immediate call for minor code
  5581.     4DH (End Code Page Preparation).
  5582.  
  5583.   ■ [4.0+] For minor codes 5FH (Set Display Information) and 7FH (Get
  5584.     Display Information), the parameter block is formatted as follows:
  5585.  
  5586.           db      0               ; level (0 in MS-DOS 4.0)
  5587.           db      0               ; reserved (must be 0)
  5588.           dw      14              ; length of following data
  5589.           dw      ?               ; control flags
  5590.                                   ; bit 0     = 0 intensity
  5591.                                   ;           = 1 blink
  5592.                                   ; bits 1-15 = reserved (0)
  5593.           db      ?               ; mode type (1 = text, 2 = APA)
  5594.           db      0               ; reserved (must be 0)
  5595.           dw      ?               ; colors
  5596.                                   ; 0 = monochrome compatible
  5597.                                   ; 1 = 2 colors
  5598.                                   ; 2 = 4 colors
  5599.                                   ; 4 = 16 colors
  5600.                                   ; 8 = 256 colors
  5601.           dw      ?               ; pixel columns
  5602.           dw      ?               ; pixel rows
  5603.           dw      ?               ; character columns
  5604.           dw      ?               ; character rows
  5605.  
  5606. Example:
  5607.  
  5608.   Get the current code page for the standard list device.
  5609.  
  5610.   stdprn  equ     4               ; standard list handle
  5611.  
  5612.   pars    dw      2               ; length of data
  5613.           dw      ?               ; receives code page
  5614.           .
  5615.           .
  5616.           .
  5617.           mov     ax,440ch        ; function & subfunction
  5618.           mov     bx,stdprn       ; standard list handle
  5619.           mov     ch,5            ; LPTx category
  5620.           mov     cl,6ah          ; query code page
  5621.           mov     dx,seg pars     ; parameter block address
  5622.           mov     ds,dx
  5623.           mov     dx,offset pars
  5624.           int     21h             ; transfer to MS-DOS
  5625.           jc      error           ; jump if function failed
  5626.           .
  5627.           .
  5628.           .
  5629.  
  5630.  
  5631. ────────────────────────────────────────────────────────────────────────────
  5632. Int 21H                                                                [3.2]
  5633. Function 44H Subfunction 0DH (13)
  5634. IOCTL: generic I/O control for block devices
  5635. ────────────────────────────────────────────────────────────────────────────
  5636.  
  5637.   Provides a general-purpose mechanism for communication between application
  5638.   programs and block-device drivers. Allows a program to inspect or change
  5639.   device parameters for a logical drive and to read, write, format, and
  5640.   verify disk tracks in a hardware-independent manner.
  5641.  
  5642. Call with:
  5643.  
  5644.   AH            = 44H
  5645.   AL            = 0DH
  5646.   BL            = drive code (0 = default, 1 = A, 2 = B, etc.)
  5647.   CH            = category (major) code:
  5648.                   08H = disk drive
  5649.   CL            = function (minor) code:
  5650.                   40H = Set Device Parameters
  5651.                   41H = Write Track
  5652.                   42H = Format and Verify Track
  5653.                   47H = Set Access Flag (4.0)
  5654.                   60H = Get Device Parameters
  5655.                   61H = Read Track
  5656.                   62H = Verify Track
  5657.                   67H = Get Access Flag (4.0)
  5658.   DS:DX         = segment:offset of parameter block
  5659.  
  5660. Returns:
  5661.  
  5662.   If function successful
  5663.  
  5664.   Carry flag    = clear
  5665.  
  5666.   and, if called with CL = 60H or 61H
  5667.  
  5668.   DS:DX         = segment:offset of parameter block
  5669.  
  5670.   If function unsuccessful
  5671.  
  5672.   Carry flag    = set
  5673.   AX            = error code
  5674.  
  5675. Notes:
  5676.  
  5677.   ■ The minor code 40H (Set Device Parameters) function must be used before
  5678.     an attempt to write, read, format, or verify a track on a logical drive.
  5679.     In general, the following sequence applies to any of these operations:
  5680.  
  5681.     ∙ Get the current parameters (minor code 60H). Examine and save them.
  5682.  
  5683.     ∙ Set the new parameters (minor code 40H).
  5684.  
  5685.     ∙ Perform the task.
  5686.  
  5687.     ∙ Retrieve the original parameters and restore them with minor code 40H.
  5688.  
  5689.   ■ For minor codes 40H (Set Device Parameters) and 60H (Get Device
  5690.     Parameters), the parameter block is formatted as follows:
  5691.  
  5692.     Special-functions field: offset 00H, length = 1 byte
  5693.  
  5694.     Bit(s)    Value      Meaning
  5695.     0         0          device BPB field contains a new default BPB
  5696.               1          use current BPB
  5697.     1         0          use all fields in parameter block
  5698.               1          use track layout field only
  5699.     2         0          sectors in track may be different sizes (should
  5700.                          always be avoided)
  5701.               1          sectors in track are all same size; sector numbers
  5702.                          range from 1 to the total number of sectors in the
  5703.                          track (should always be used)
  5704.     3─7       0          reserved
  5705.  
  5706.     Device type field: offset 01H, length 1 byte
  5707.  
  5708.     Value             Meaning
  5709.     0                 320/360 KB, 5.25-inch disk
  5710.     1                 1.2 MB, 5.25-inch disk
  5711.     2                 720 KB, 3.5-inch disk
  5712.     3                 single-density, 8-inch disk
  5713.     4                 double-density, 8-inch disk
  5714.     5                 fixed disk
  5715.     6                 tape drive
  5716.     7                 other type of block device
  5717.  
  5718.     Device attributes field: offset 02H, length 1 word
  5719.  
  5720.     Bit(s)        Value          Meaning
  5721.     0             0              removable storage medium
  5722.                   1              nonremovable storage medium
  5723.     1             0              door lock not supported
  5724.                   1              door lock supported
  5725.     2─15          0              reserved
  5726.  
  5727.     Number of cylinders field: offset 04H, length 1 word
  5728.     Maximum number of cylinders supported on the block device
  5729.  
  5730.     Media type field: offset 06H, length 1 byte
  5731.  
  5732.     Value             Meaning
  5733.     0                 1.2 MB, 5.25-inch disk
  5734.     1                 320/360 KB, 5.25-inch disk
  5735.  
  5736.     Device BPB field: offset 07H, length 31 bytes
  5737.     For format of the device BPB, see separate Note below.
  5738.     If bit 0 = 0 in special-functions field, this field contains the new
  5739.     default BPB for the device.
  5740.     If bit 0 = 1 in special-functions field, the BPB in this field is
  5741.     returned by the device driver in response to subsequent Build BPB
  5742.     requests.
  5743.  
  5744.     Track layout field: offset 26H, variable-length table
  5745.  
  5746.     Length      Meaning
  5747.     Word        number of sectors in track
  5748.     Word        number of first sector in track
  5749.     Word        size of first sector in track
  5750.     .
  5751.     .
  5752.     .
  5753.     Word        number of last sector in track
  5754.     Word        size of last sector in track
  5755.  
  5756.   ■ The device BPB field is a 31-byte data structure that describes the
  5757.     current disk and its control areas. The field is formatted as follows:
  5758.  
  5759.     Byte(s)     Meaning
  5760.     00H─01H     bytes per sector
  5761.     02H         sectors per cluster (allocation unit)
  5762.     03─04H      reserved sectors, beginning at sector 0
  5763.     05H         number of file allocation tables (FATs)
  5764.     06H─07H     maximum number of root-directory entries
  5765.     08H─09H     number of sectors
  5766.     0AH         media descriptor
  5767.     0BH─0CH     sectors per FAT
  5768.     0DH─0EH     sectors per track
  5769.     0FH─10H     number of heads
  5770.     11H─14H     number of hidden sectors
  5771.     15H─18H     large number of sectors (if bytes 08H─09H=0)
  5772.     19H─1EH     reserved
  5773.  
  5774.   ■ When minor code 40H (Set Device Parameters) is used, the number of
  5775.     cylinders should not be altered, or some or all of the volume may become
  5776.     inaccessible.
  5777.  
  5778.   ■ For minor codes 41H (Write Track) and 61H (Read Track), the parameter
  5779.     block is formatted as follows:
  5780.  
  5781.     Byte(s)     Meaning
  5782.     00H         special-functions field (must be 0)
  5783.     01H─02H     head
  5784.     03H─04H     cylinder
  5785.     05H─06H     starting sector
  5786.     07H─08H     sectors to transfer
  5787.     09H─0CH     transfer buffer address
  5788.  
  5789.   ■ For minor codes 42H (Format and Verify Track) and 62H (Verify Track),
  5790.     the parameter block is formatted as follows:
  5791.  
  5792.     Byte(s)     Meaning
  5793.     00H         special-functions field
  5794.  
  5795.                 Bit(s)      Significance
  5796.                 0           0 = Format/Verify track
  5797.                             1 = Format status call (MS-DOS 4.0 only)
  5798.                 1─7         reserved (0)
  5799.     01H─02H     head
  5800.     03H─04H     cylinder
  5801.  
  5802.     In MS-DOS 4.0, this function may be called with bit 0 of the
  5803.     special-functions field set after a minor code 40H call (Set Device
  5804.     Parameters) to determine whether the driver supports the specified
  5805.     number of tracks and sectors per track. A status is returned in the
  5806.     special-functions field which is interpreted as follows:
  5807.  
  5808.     Value       Meaning
  5809.     0           specified number of tracks and sectors per track supported
  5810.     1           this function not supported by the ROM BIOS
  5811.     2           specified number of tracks and sectors per track not
  5812.                 supported
  5813.     3           no disk in drive
  5814.  
  5815.   ■ For minor codes 47H (Set Access Flag) and 67H (Get Access Flag), the
  5816.     parameter block is formatted as follows:
  5817.  
  5818.     Byte        Meaning
  5819.     00H         special-functions field (must be 0)
  5820.     01H         disk access flag
  5821.  
  5822.     When the disk access flag is zero, access to the medium is blocked by
  5823.     the driver. The flag is set to zero when the driver detects an
  5824.     unformatted medium or a medium with an invalid boot record. When the
  5825.     access flag is nonzero, read/write operations to the medium are allowed
  5826.     by the driver. A formatting program must clear the disk access flag with
  5827.     minor code 47H before it requests minor code 42H (Format and Verify
  5828.     Track).
  5829.  
  5830. Example:
  5831.  
  5832.   Get the device parameter block for disk drive C.
  5833.  
  5834.   dbpb    db      128 dup (0)     ; device parameter block
  5835.           .
  5836.           .
  5837.           .
  5838.           mov     ax,440dh        ; function & subfunction
  5839.           mov     bl,3            ; drive C = 3
  5840.           mov     ch,8            ; disk category
  5841.           mov     cl,60h          ; get device parameters
  5842.           mov     dx,seg dbpb     ; buffer address
  5843.           mov     ds,dx
  5844.           mov     dx,offset dbpb
  5845.           int     21h             ; transfer to MS-DOS
  5846.           jc      error         o ; jump if function failed
  5847.           .
  5848.           .
  5849.           .
  5850.  
  5851.  
  5852. ────────────────────────────────────────────────────────────────────────────
  5853. Int 21H                                                                [3.2]
  5854. Function 44H (68) Subfunction 0EH (14)
  5855. IOCTL: get logical drive map
  5856. ────────────────────────────────────────────────────────────────────────────
  5857.  
  5858.   Returns the logical drive code that was most recently used to access the
  5859.   specified block device.
  5860.  
  5861. Call with:
  5862.  
  5863.   AH            = 44H
  5864.   AL            = 0EH
  5865.   BL            = drive code (0 = default, 1 = A, 2 = B, etc.)
  5866.  
  5867. Returns:
  5868.  
  5869.   If function successful
  5870.  
  5871.   Carry flag    = clear
  5872.   AL            = mapping code
  5873.  
  5874.                   00H       if only one logical drive code assigned to the
  5875.                             block device
  5876.                   01H─1AH   logical drive code (1 = A, 2 = B, etc.) mapped
  5877.                             to the block device
  5878.  
  5879.   If function unsuccessful
  5880.  
  5881.   Carry flag    = set
  5882.   AX            = error code
  5883.  
  5884. Note:
  5885.  
  5886.   ■ If a drive has not been assigned a logical mapping with Function 44H
  5887.     Subfunction 0FH, the logical and physical drive codes are the same.
  5888.  
  5889. Example:
  5890.  
  5891.   Check whether drive A has more than one logical drive code.
  5892.  
  5893.           .
  5894.           .
  5895.           .
  5896.           mov     ax,440eh        ; function & subfunction
  5897.           mov     bl,1            ; drive 1 = A
  5898.           int     21h             ; transfer to MS-DOS
  5899.           jc      error           ; jump if function failed
  5900.           or      al,al           ; test drive code
  5901.           jz      label1          ; jump, no drive aliases
  5902.           .
  5903.           .
  5904.           .
  5905.  
  5906.  
  5907. ────────────────────────────────────────────────────────────────────────────
  5908. Int 21H                                                                [3.2]
  5909. Function 44H (68) Subfunction 0FH (15)
  5910. IOCTL: set logical drive map
  5911. ────────────────────────────────────────────────────────────────────────────
  5912.  
  5913.   Sets the next logical drive code that will be used to reference a block
  5914.   device.
  5915.  
  5916. Call with:
  5917.  
  5918.   AH            = 44H
  5919.   AL            = 0FH
  5920.   BL            = drive code (0 = default, 1 = A, 2 = B, etc.)
  5921.  
  5922. Returns:
  5923.  
  5924.   If function successful
  5925.  
  5926.   Carry flag    = clear
  5927.   AL            = mapping code
  5928.  
  5929.                   00H       if only one logical drive code assigned to the
  5930.                             block device
  5931.                   01H─1AH   logical drive code (1 = A, 2 = B, etc.) mapped
  5932.                             to the block device
  5933.  
  5934.   If function unsuccessful
  5935.  
  5936.   Carry flag    = set
  5937.   AX            = error code
  5938.  
  5939. Note:
  5940.  
  5941.   ■ When a physical block device is aliased to more than one logical drive
  5942.     code, this function can be used to inform the driver which drive code
  5943.     will next be used to access the device.
  5944.  
  5945. Example:
  5946.  
  5947.   Notify the floppy-disk driver that the next access will be for logical
  5948.   drive B.
  5949.  
  5950.           .
  5951.           .
  5952.           .
  5953.           mov     ax,440fh        ; function & subfunction
  5954.           mov     bl,2            ; drive 2 = B
  5955.           int     21h             ; transfer to MS-DOS
  5956.           jc      error           ; jump if function failed
  5957.           .
  5958.           .
  5959.           .
  5960.  
  5961.  
  5962. ────────────────────────────────────────────────────────────────────────────
  5963. Int 21H                                                                [2.0]
  5964. Function 45H (69)
  5965. Duplicate handle
  5966. ────────────────────────────────────────────────────────────────────────────
  5967.  
  5968.   Given a handle for a currently open device or file, returns a new handle
  5969.   that refers to the same device or file at the same position.
  5970.  
  5971. Call with:
  5972.  
  5973.   AH            = 45H
  5974.   BX            = handle to be duplicated
  5975.  
  5976. Returns:
  5977.  
  5978.   If function successful
  5979.  
  5980.   Carry flag    = clear
  5981.   AX            = new handle
  5982.  
  5983.   If function unsuccessful
  5984.  
  5985.   Carry flag    = set
  5986.   AX            = error code
  5987.  
  5988. Notes:
  5989.  
  5990.   ■ A seek, read, or write operation that moves the file pointer for one of
  5991.     the two handles also moves the file pointer associated with the other.
  5992.  
  5993.   ■ This function can be used to efficiently update the directory for a file
  5994.     that has changed in length, without incurring the overhead of closing
  5995.     and then reopening the file. The handle for the file is simply
  5996.     duplicated with this function and the duplicate is closed, leaving the
  5997.     original handle open for further read/write operations.
  5998.  
  5999.   ■ [3.3] See also Int 21H Function 68H (Commit File).
  6000.  
  6001. Example:
  6002.  
  6003.   Duplicate the handle stored in the variable fhandle, then close the
  6004.   duplicate. This ensures that all buffered data is physically written to
  6005.   disk and that the directory entry for the corresponding file is updated,
  6006.   but leaves the original handle open for subsequent file operations.
  6007.  
  6008.   fhandle dw      0               ; file handle
  6009.           .
  6010.           .
  6011.           .
  6012.                                   ; get duplicate handle
  6013.           mov     ah,45h          ; function number
  6014.           mov     bx,fhandle      ; original file handle
  6015.           int     21h             ; transfer to MS-DOS
  6016.           jc      error           ; jump if dup failed
  6017.                                   ; now close dup'd handle
  6018.           mov     bx,ax           ; put handle into BX
  6019.           mov     ah,3eh          ; function number
  6020.           int     21h             ; transfer to MS-DOS         jc      error
  6021.    ; jump if close failed
  6022.           .
  6023.           .
  6024.           .
  6025.  
  6026.  
  6027. ────────────────────────────────────────────────────────────────────────────
  6028. Int 21H                                                                [2.0]
  6029. Function 46H (70)
  6030. Redirect handle
  6031. ────────────────────────────────────────────────────────────────────────────
  6032.  
  6033.   Given two handles, makes the second handle refer to the same device or
  6034.   file at the same location as the first handle. The second handle is then
  6035.   said to be redirected.
  6036.  
  6037. Call with:
  6038.  
  6039.   AH            = 46H
  6040.   BX            = handle for file or device
  6041.   CX            = handle to be redirected
  6042.  
  6043. Returns:
  6044.  
  6045.   If function successful
  6046.  
  6047.   Carry flag    = clear
  6048.  
  6049.   If function unsuccessful
  6050.  
  6051.   Carry flag    = set
  6052.   AX            = error code
  6053.  
  6054. Notes:
  6055.  
  6056.   ■ If the handle passed in CX already refers to an open file, that file is
  6057.     closed first.
  6058.  
  6059.   ■ A seek, read, or write operation that moves the file pointer for one of
  6060.     the two handles also moves the file pointer associated with the other.
  6061.  
  6062.   ■ This function is commonly used to redirect the standard input and output
  6063.     handles to another file or device before a child process is executed
  6064.     with Int 21H Function 4BH.
  6065.  
  6066. Example:
  6067.  
  6068.   Redirect the standard output to the list device, so that all output
  6069.   directed to the console will appear on the printer instead. Later, restore
  6070.   the original meaning of the standard output handle.
  6071.  
  6072.   stdin   equ     0
  6073.   stdout  equ     1
  6074.   stderr  equ     2
  6075.   stdaux  equ     3
  6076.   stdprn  equ     4
  6077.  
  6078.   dhandle dw      0               ; duplicate handle
  6079.           .
  6080.           .
  6081.           .
  6082.                                   ; get dup of stdout
  6083.           mov     ah,45h          ; function number
  6084.           mov     bx,stdout       ; standard output handle
  6085.           int     21h             ; transfer to MS-DOS
  6086.           jc      error           ; jump if dup failed
  6087.           mov     dhandle,ax      ; save dup'd handle
  6088.                                   ;
  6089.                                   ; redirect standard output
  6090.                                   ; to standard list device
  6091.           mov     ah,46h          ; function number
  6092.           mov     bx,stdprn       ; standard list handle
  6093.           mov     cx,stdout       ; standard output handle
  6094.           int     21h             ; transfer to MS-DOS
  6095.           jc      error           ; jump if redirect failed
  6096.           .
  6097.           .
  6098.           .
  6099.                                   ; restore standard output
  6100.                                   ; to original meaning
  6101.           mov     ah,46h          ; function number
  6102.           mov     bx,dhandle      ; saved duplicate handle
  6103.           mov     cx,stdout       ; standard output handle
  6104.           int     21h             ; transfer to MS-DOS
  6105.           jc      error           ; jump if redirect failed
  6106.                                   ; close duplicate handle
  6107.                                   ; because no longer needed
  6108.           mov     ah,3eh          ; function number
  6109.           mov     bx,dhandle      ; saved duplicate handle
  6110.           int     21h             ; transfer to MS-DOS
  6111.           jc      error           ; jump if close failed
  6112.           .
  6113.           .
  6114.           .
  6115.  
  6116.  
  6117. ────────────────────────────────────────────────────────────────────────────
  6118. Int 21H                                                                [2.0]
  6119. Function 47H (71)
  6120. Get current directory
  6121. ────────────────────────────────────────────────────────────────────────────
  6122.  
  6123.   Obtains an ASCIIZ string that describes the path from the root to the
  6124.   current directory, and the name of that directory.
  6125.  
  6126. Call with:
  6127.  
  6128.   AH            = 47H
  6129.   DL            = drive code (0 = default, 1 = A, etc.)
  6130.   DS:SI         = segment:offset of 64-byte buffer
  6131.  
  6132. Returns:
  6133.  
  6134.   If function successful
  6135.  
  6136.   Carry flag    = clear
  6137.  
  6138.   and buffer is filled in with full pathname from root of current directory.
  6139.  
  6140.   If function unsuccessful
  6141.  
  6142.   Carry flag    = set
  6143.   AX            = error code
  6144.  
  6145. Notes:
  6146.  
  6147.   ■ The returned path name does not include the drive identifier or a
  6148.     leading backslash (\). It is terminated with a null (00H) byte.
  6149.     Consequently, if the current directory is the root directory, the first
  6150.     byte in the buffer will contain 00H.
  6151.  
  6152.   ■ The function fails if the drive code is invalid.
  6153.  
  6154.   ■ The current directory may be set with Int 21H Function 3BH.
  6155.  
  6156. Example:
  6157.  
  6158.   Get the name of the current directory for drive C into the buffer named
  6159.   dbuff.
  6160.  
  6161.   dbuff   db      64 dup (0)      ; receives path string
  6162.           .
  6163.           .
  6164.           .
  6165.           mov     ah,47h          ; function number
  6166.           mov     dl,03           ; drive C = 3
  6167.           mov     si,seg dbuff    ; buffer address
  6168.           mov     ds,si
  6169.           mov     si,offset dbuff
  6170.           int     21h             ; transfer to MS-DOS
  6171.           jc      error           ; jump if error
  6172.           .
  6173.           .
  6174.           .
  6175.  
  6176.  
  6177. ────────────────────────────────────────────────────────────────────────────
  6178. Int 21H                                                                [2.0]
  6179. Function 48H (72)
  6180. Allocate memory block
  6181. ────────────────────────────────────────────────────────────────────────────
  6182.  
  6183.   Allocates a block of memory and returns a pointer to the beginning of the
  6184.   allocated area.
  6185.  
  6186. Call with:
  6187.  
  6188.   AH            = 48H
  6189.   BX            = number of paragraphs of memory needed
  6190.  
  6191. Returns:
  6192.  
  6193.   If function successful
  6194.  
  6195.   Carry flag    = clear
  6196.   AX            = base segment address of allocated block
  6197.  
  6198.   If function unsuccessful
  6199.  
  6200.   Carry flag    = set
  6201.   AX            = error code
  6202.   BX            = size of largest available block (paragraphs)
  6203.  
  6204. Notes:
  6205.  
  6206.   ■ If the function succeeds, the base address of the newly allocated block
  6207.     is AX:0000.
  6208.  
  6209.   ■ The default allocation strategy used by MS-DOS is "first fit"; that is,
  6210.     the memory block at the lowest address that is large enough to satisfy
  6211.     the request is allocated. The allocation strategy can be altered with
  6212.     Int 21H Function 58H.
  6213.  
  6214.   ■ When a .COM program is loaded, it ordinarily already "owns" all of the
  6215.     memory in the transient program area, leaving none for dynamic
  6216.     allocation. The amount of memory initially allocated to a .EXE program
  6217.     at load time depends on the MINALLOC and MAXALLOC fields in the .EXE
  6218.     file header. See Int 21H Function 4AH.
  6219.  
  6220. Example:
  6221.  
  6222.   Request a 64 KB block of memory for use as a buffer.
  6223.  
  6224.   bufseg  dw      ?               ; segment base of new block
  6225.           .
  6226.           .
  6227.           .
  6228.           mov     ah,48h          ; function number
  6229.           mov     bx,1000h        ; block size (paragraphs)
  6230.           int     21h             ; transfer to MS-DOS
  6231.           jc      error           ; jump if allocation failed
  6232.           mov     bufseg,ax       ; save segment of new block
  6233.           .
  6234.           .
  6235.           .
  6236.  
  6237.  
  6238. ────────────────────────────────────────────────────────────────────────────
  6239. Int 21H                                                                [2.0]
  6240. Function 49H (73)
  6241. Release memory block
  6242. ────────────────────────────────────────────────────────────────────────────
  6243.  
  6244.   Releases a memory block and makes it available for use by other programs.
  6245.  
  6246. Call with:
  6247.  
  6248.   AH            = 49H
  6249.   ES            = segment of block to be released
  6250.  
  6251. Returns:
  6252.  
  6253.   If function successful
  6254.  
  6255.   Carry flag    = clear
  6256.  
  6257.   If function unsuccessful
  6258.  
  6259.   Carry flag    = set
  6260.   AX            = error code
  6261.  
  6262. Notes:
  6263.  
  6264.   ■ This function assumes that the memory block being released was
  6265.     previously obtained by a successful call to Int 21H Function 48H.
  6266.  
  6267.   ■ The function will fail or can cause unpredictable system errors if:
  6268.  
  6269.     ∙ the program releases a memory block that does not belong to it.
  6270.  
  6271.     ∙ the segment address passed in register ES is not a valid base address
  6272.       for an existing memory block.
  6273.  
  6274. Example:
  6275.  
  6276.   Release the memory block that was previously allocated in the example for
  6277.   Int 21H Function 48H (page 438).
  6278.  
  6279.   bufseg  dw      ?               ; segment base of block
  6280.           .
  6281.           .
  6282.           .
  6283.           mov     ah,49h          ; function number
  6284.           mov     es,bufseg       ; base segment of block
  6285.           int     21h             ; transfer to MS-DOS
  6286.           jc      error           ; jump if release failed
  6287.           .
  6288.           .
  6289.           .
  6290.  
  6291.  
  6292. ────────────────────────────────────────────────────────────────────────────
  6293. Int 21H                                                                [2.0]
  6294. Function 4AH (74)
  6295. Resize memory block
  6296. ────────────────────────────────────────────────────────────────────────────
  6297.  
  6298.   Dynamically shrinks or extends a memory block, according to the needs of
  6299.   an application program.
  6300.  
  6301. Call with:
  6302.  
  6303.   AH            = 4AH
  6304.   BX            = desired new block size in paragraphs
  6305.   ES            = segment of block to be modified
  6306.  
  6307. Returns:
  6308.  
  6309.   If function successful
  6310.  
  6311.   Carry flag    = clear
  6312.  
  6313.   If function unsuccessful
  6314.  
  6315.   Carry flag    = set
  6316.   AX            = error code
  6317.   BX            = maximum block size available (paragraphs)
  6318.  
  6319. Notes:
  6320.  
  6321.   ■ This function modifies the size of a memory block that was previously
  6322.     allocated with a call to Int 21H Function 48H.
  6323.  
  6324.   ■ If the program is requesting an increase in the size of an allocated
  6325.     block, and this function fails, the maximum possible size for the
  6326.     specified block is returned in register BX. The program can use this
  6327.     value to determine whether it should terminate, or continue in a
  6328.     degraded fashion with less memory.
  6329.  
  6330.   ■ A program that uses EXEC (Int 21H Function 4BH) to load and execute a
  6331.     child program must call this function first to make memory available for
  6332.     the child, passing the address of its PSP in register ES and the amount
  6333.     of memory needed for its own code, data, and stacks in register BX.
  6334.  
  6335. Example:
  6336.  
  6337.   Resize the memory block that was allocated in the example for Int 21H
  6338.   Function 48H (page 438), shrinking it to 32 KB.
  6339.  
  6340.   bufseg  dw      ?               ; segment base of block
  6341.           .
  6342.           .
  6343.           .
  6344.           mov     ah,4ah          ; function number
  6345.           mov     bx,0800h        ; new size (paragraphs)
  6346.           mov     es,bufseg       ; segment base of block
  6347.           int     21h             ; transfer to MS-DOS
  6348.           jc      error           ; jump, resize failed
  6349.           .
  6350.           .
  6351.           .
  6352.  
  6353.  
  6354. ────────────────────────────────────────────────────────────────────────────
  6355. Int 21H                                                                [2.0]
  6356. Function 4BH (75)
  6357. Execute program (EXEC)
  6358. ────────────────────────────────────────────────────────────────────────────
  6359.  
  6360.   Allows an application program to run another program, regaining control
  6361.   when it is finished. Can also be used to load overlays, although this use
  6362.   is uncommon.
  6363.  
  6364. Call with:
  6365.  
  6366.   AH            = 4BH
  6367.   AL            = subfunction
  6368.                   00H = Load and Execute Program
  6369.                   03H = Load Overlay
  6370.   ES:BX         = segment:offset of parameter block
  6371.   DS:DX         = segment:offset of ASCIIZ program pathname
  6372.  
  6373. Returns:
  6374.  
  6375.   If function successful
  6376.  
  6377.   Carry flag    = clear
  6378.  
  6379.   [2]         all registers except for CS:IP may be destroyed
  6380.   [3.0+]      registers are preserved in the usual fashion
  6381.  
  6382.   If function unsuccessful
  6383.  
  6384.   Carry flag    = set
  6385.   AX            = error code
  6386.  
  6387. Notes:
  6388.  
  6389.   ■ The parameter block format for Subfunction 00H (Load and Execute
  6390.     Program) is as follows:
  6391.  
  6392.     Bytes       Contents
  6393.     00H─01H     segment pointer to environment block
  6394.     02H─03H     offset of command line tail
  6395.     04H─05H     segment of command line tail
  6396.     06H─07H     offset of first FCB to be copied into new PSP + 5CH
  6397.     08H─09H     segment of first FCB
  6398.     0AH─0BH     offset of second FCB to be copied into new PSP + 6CH
  6399.     0CH─0DH     segment of second FCB
  6400.  
  6401.   ■ The parameter block format for Subfunction 03H (Load Overlay) is as
  6402.     follows:
  6403.  
  6404.     Bytes       Contents
  6405.     00H─01H     segment address where overlay is to be loaded
  6406.     02H─03H     relocation factor to apply to loaded image
  6407.  
  6408.   ■ The environment block must be paragraph-aligned. It consists of a
  6409.     sequence of ASCIIZ strings in the form:
  6410.  
  6411.             db      'COMSPEC=A:\COMMAND.COM',0
  6412.  
  6413.     The entire set of strings is terminated by an extra null (00H) byte.
  6414.  
  6415.   ■ The command tail format consists of a count byte, followed by an ASCII
  6416.     string, terminated by a carriage return (which is not included in the
  6417.     count). The first character in the string should be an ASCII space (20H)
  6418.     for compatibility with the command tail passed to programs by
  6419.     COMMAND.COM. For example:
  6420.  
  6421.             db      6,' *.DAT',0dh
  6422.  
  6423.   ■ Before a program uses Int 21H Function 4BH to run another program, it
  6424.     must release all memory it is not actually using with a call to Int 21H
  6425.     Function 4AH, passing the segment address of its own PSP and the number
  6426.     of paragraphs to retain.
  6427.  
  6428.   ■ Ordinarily, all active handles of the parent program are inherited by
  6429.     the child program, although the parent can prevent this in MS-DOS 3.0
  6430.     and later by setting the inheritance bit when the file or device is
  6431.     opened. Any redirection of the standard input and/or output in the
  6432.     parent process also affects the child process.
  6433.  
  6434.   ■ The environment block can be used to pass information to the child
  6435.     process. If the environment block pointer in the parameter block is
  6436.     zero, the child program inherits an exact copy of the parent's
  6437.     environment. In any case, the segment address of the child's environment
  6438.     is found at offset 002CH in the child's PSP.
  6439.  
  6440.   ■ After return from the EXEC function call, the termination type and
  6441.     return code of the child program may be obtained with Int 21H Function
  6442.     4DH.
  6443.  
  6444. Example:
  6445.  
  6446.   See Chapter 12.
  6447.  
  6448.  
  6449. ────────────────────────────────────────────────────────────────────────────
  6450. Int 21H                                                                [2.0]
  6451. Function 4CH (76)
  6452. Terminate process with return code
  6453. ────────────────────────────────────────────────────────────────────────────
  6454.  
  6455.   Terminates the current process, passing a return code to the parent
  6456.   process. This is one of several methods that a program can use to perform
  6457.   a final exit. MS-DOS then takes the following actions:
  6458.  
  6459.   ■ All memory belonging to the process is released.
  6460.  
  6461.   ■ File buffers are flushed and any open handles for files or devices owned
  6462.     by the process are closed.
  6463.  
  6464.   ■ The termination handler vector (Int 22H) is restored from PSP:000AH.
  6465.  
  6466.   ■ The Ctrl-C handler vector (Int 23H) is restored from PSP:000EH.
  6467.  
  6468.   ■ [2.0+] The critical-error handler vector (Int 24H) is restored from
  6469.     PSP:0012H.
  6470.  
  6471.   ■ Control is transferred to the termination handler.
  6472.  
  6473.   If the program is returning to COMMAND.COM, control transfers to the
  6474.   resident portion and the transient portion is reloaded if necessary. If a
  6475.   batch file is in progress, the next line of the file is fetched and
  6476.   interpreted; otherwise, a prompt is issued for the next user command.
  6477.  
  6478. Call with:
  6479.  
  6480.   AH            = 4CH
  6481.   AL            = return code
  6482.  
  6483. Returns:
  6484.  
  6485.   Nothing
  6486.  
  6487. Notes:
  6488.  
  6489.   ■ [2.0+] This is the preferred method of termination for application
  6490.     programs because it allows a return code to be passed to the parent
  6491.     program and does not rely on the contents of any segment register. Other
  6492.     methods of performing a final exit are:
  6493.  
  6494.     ∙ Int 20H
  6495.  
  6496.     ∙ Int 21H Function 00H
  6497.  
  6498.     ∙ Int 21H Function 31H
  6499.  
  6500.     ∙ Int 27H
  6501.  
  6502.   ■ Any files that have been opened using FCBs and modified by the program
  6503.     should be closed before program termination; otherwise, data may be
  6504.     lost.
  6505.  
  6506.   ■ The return code can be retrieved by the parent process with Int 21H
  6507.     Function 4DH (Get Return Code). It can also be tested in a batch file
  6508.     with an IF ERRORLEVEL statement. By convention, a return code of zero
  6509.     indicates successful execution, and a non-zero return code indicates an
  6510.     error.
  6511.  
  6512.   ■ [3.0+] If the program is running on a network, it should remove all
  6513.     locks it has placed on file regions before terminating.
  6514.  
  6515. Example:
  6516.  
  6517.   Terminate the current process, passing a return code of 1 to the parent
  6518.   process.
  6519.  
  6520.           .
  6521.           .
  6522.           .
  6523.           mov     ah,4ch          ; function number
  6524.           mov     al,01h          ; return code
  6525.           int     21h             ; transfer to MS-DOS
  6526.  
  6527.  
  6528. ────────────────────────────────────────────────────────────────────────────
  6529. Int 21H                                                                [2.0]
  6530. Function 4DH (77)
  6531. Get return code
  6532. ────────────────────────────────────────────────────────────────────────────
  6533.  
  6534.   Used by a parent process, after the successful execution of an EXEC call
  6535.   (Int 21H Function 4BH), to obtain the return code and termination type of
  6536.   a child process.
  6537.  
  6538. Call with:
  6539.  
  6540.   AH            = 4DH
  6541.  
  6542. Returns:
  6543.  
  6544.   AH            = exit type
  6545.                   00H if normal termination by Int 20H, Int 21H Function
  6546.                   00H, or Int 21H Function 4CH
  6547.                   01H if termination by user's entry of CtrlDC
  6548.                   02H if termination by critical-error handler
  6549.                   03H if termination by Int 21H Function 31H or Int 27H
  6550.   AL            = return code passed by child process (0 if child terminated
  6551.                   by Int 20H, Int 21H Function 00H, or Int 27H)
  6552.  
  6553. Notes:
  6554.  
  6555.   ■ This function will yield the return code of a child process only once. A
  6556.     subsequent call without an intervening EXEC (Int 21H Function 4BH) will
  6557.     not necessarily return any valid information.
  6558.  
  6559.   ■ This function does not set the carry flag to indicate an error. If no
  6560.     previous child process has been executed, the values returned in AL and
  6561.     AH are undefined.
  6562.  
  6563. Example:
  6564.  
  6565.   Get the return code and termination kind of child process that was
  6566.   previously executed with Int 21H Function 4BH (EXEC).
  6567.  
  6568.   retcode dw      ?               ; return code, termination type
  6569.           .
  6570.           .
  6571.           .
  6572.           mov     ah,4dh          ; function number
  6573.           int     21h             ; transfer to MS-DOS
  6574.           mov     retcode,ax      ; save child process info
  6575.           .
  6576.           .
  6577.           .
  6578.  
  6579.  
  6580. ────────────────────────────────────────────────────────────────────────────
  6581. Int 21H                                                                [2.0]
  6582. Function 4EH (78)
  6583. Find first file
  6584. ────────────────────────────────────────────────────────────────────────────
  6585.  
  6586.   Given a file specification in the form of an ASCIIZ string, searches the
  6587.   default or specified directory on the default or specified drive for the
  6588.   first matching file.
  6589.  
  6590. Call with:
  6591.  
  6592.   AH            = 4EH
  6593.   CX            = search attribute (bits may be combined)
  6594.  
  6595.                   Bit(s)    Significance (if set)
  6596.                   0         read-only
  6597.                   1         hidden
  6598.                   2         system
  6599.                   3         volume label
  6600.                   4         directory
  6601.                   5         archive
  6602.                   6─15      reserved (0)
  6603.  
  6604.   DS:DX         = segment:offset of ASCIIZ pathname
  6605.  
  6606. Returns:
  6607.  
  6608.   If function successful (matching file found)
  6609.  
  6610.   Carry flag    = clear
  6611.  
  6612.   and search results returned in current disk transfer area as follows:
  6613.  
  6614.   Byte(s)            Description
  6615.   00H─14H            reserved (0)
  6616.   15H                attribute of matched file or directory
  6617.   16H─17H            file time
  6618.                      bits 00H─04H = 2-second increments (0─29)
  6619.                      bits 05H─0AH = minutes (0─59)
  6620.                      bits 0BH─0FH = hours (0─23)
  6621.   18H─19H            file date
  6622.                      bits 00H─04H = day (1─31)
  6623.                      bits 05H─08H = month (1─12)
  6624.                      bits 09H─0FH = year (relative to 1980)
  6625.   1AH─1DH            file size
  6626.   1EH─2AH            ASCIIZ filename and extension
  6627.  
  6628.   If function unsuccessful (no matching files)
  6629.  
  6630.   Carry flag    = set
  6631.   AX            = error code
  6632.  
  6633. Notes:
  6634.  
  6635.   ■ This function assumes that the DTA has been previously set by the
  6636.     program with Int 21H Function 1AH to point to a buffer of adequate
  6637.     size.
  6638.  
  6639.   ■ The * and ? wildcard characters are allowed in the filename. If wildcard
  6640.     characters are present, this function returns only the first matching
  6641.     filename.
  6642.  
  6643.   ■ If the attribute is 0, only ordinary files are found. If the volume
  6644.     label attribute bit is set, only volume labels will be returned (if any
  6645.     are present). Any other attribute or combination of attributes (hidden,
  6646.     system, and directory) results in those files and all normal files being
  6647.     matched.
  6648.  
  6649. Example:
  6650.  
  6651.   Find the first .COM file in the directory \MYDIR on drive C.
  6652.  
  6653.   fname   db      'C:\MYDIR\*.COM',0
  6654.  
  6655.   dbuff   db      43 dup (0)      ; receives search results
  6656.           .
  6657.           .
  6658.           .
  6659.                                   ; set DTA address
  6660.           mov     ah,1ah          ; function number
  6661.           mov     dx,seg dbuff    ; result buffer address
  6662.           mov     ds,dx
  6663.           mov     dx,offset dbuff
  6664.           int     21h             ; transfer to MS-DOS
  6665.  
  6666.                                   ; search for first match
  6667.           mov     ah,4eh          ; function number
  6668.           mov     cx,0            ; normal attribute
  6669.           mov     dx,seg fname    ; address of filename
  6670.           mov     ds,dx
  6671.           mov     dx,offset fname
  6672.           int     21h             ; transfer to MS-DOS
  6673.           jc      error           ; jump if no match
  6674.           .
  6675.           .
  6676.           .
  6677.  
  6678.  
  6679. ────────────────────────────────────────────────────────────────────────────
  6680. Int 21H                                                                [2.0]
  6681. Function 4FH (79)
  6682. Find next file
  6683. ────────────────────────────────────────────────────────────────────────────
  6684.  
  6685.   Assuming a previous successful call to Int 21H Function 4EH, finds the
  6686.   next file in the default or specified directory on the default or
  6687.   specified drive that matches the original file specification.
  6688.  
  6689. Call with:
  6690.  
  6691.   AH            = 4FH
  6692.  
  6693.   Assumes DTA points to working buffer used by previous successful Int 21H
  6694.   Function 4EH or 4FH.
  6695.  
  6696. Returns:
  6697.  
  6698.   If function successful (matching file found)
  6699.  
  6700.   Carry flag    = clear
  6701.  
  6702.   and search results returned in current disk transfer area as described for
  6703.   Int 21H Function 4EH
  6704.  
  6705.   If function unsuccessful (no more matching files)
  6706.  
  6707.   Carry flag    = set
  6708.   AX            = error code
  6709.  
  6710. Notes:
  6711.  
  6712.   ■ Use of this call assumes that the original file specification passed to
  6713.     Int 21H Function 4EH contained one or more * or ? wildcard characters.
  6714.  
  6715.   ■ When this function is called, the current disk transfer area (DTA) must
  6716.     contain information from a previous successful call to Int 21H Function
  6717.     4EH or 4FH.
  6718.  
  6719. Example:
  6720.  
  6721.   Continuing the search operation in the example for Int 21H Function 4EH,
  6722.   find the next .COM file (if any) in the directory \MYDIR on drive C.
  6723.  
  6724.   fname   db      'C:\MYDIR\*.COM',0
  6725.  
  6726.   dbuff   db      43 dup (0)      ; receives search results
  6727.           .
  6728.           .
  6729.           .
  6730.                                   ; search for next match
  6731.           mov     ah,4fh          ; function number
  6732.           int     21h             ; transfer to MS-DOS
  6733.           jc      error           ; jump if no more files
  6734.           .
  6735.           .
  6736.           .
  6737.  
  6738.  
  6739. ────────────────────────────────────────────────────────────────────────────
  6740. Int 21H
  6741. Function 50H (80)
  6742. Reserved
  6743. ────────────────────────────────────────────────────────────────────────────
  6744.  
  6745.  
  6746. ────────────────────────────────────────────────────────────────────────────
  6747. Int 21H
  6748. Function 51H (81)
  6749. Reserved
  6750. ────────────────────────────────────────────────────────────────────────────
  6751.  
  6752.  
  6753. ────────────────────────────────────────────────────────────────────────────
  6754. Int 21H
  6755. Function 52H (82)
  6756. Reserved
  6757. ────────────────────────────────────────────────────────────────────────────
  6758.  
  6759.  
  6760. ────────────────────────────────────────────────────────────────────────────
  6761. Int 21H
  6762. Function 53H (83)
  6763. Reserved
  6764. ────────────────────────────────────────────────────────────────────────────
  6765.  
  6766.  
  6767. ────────────────────────────────────────────────────────────────────────────
  6768. Int 21H                                                                [2.0]
  6769. Function 54H (84)
  6770. Get verify flag
  6771. ────────────────────────────────────────────────────────────────────────────
  6772.  
  6773.   Obtains the current value of the system verify (read-after-write) flag.
  6774.  
  6775. Call with:
  6776.  
  6777.   AH            = 54H
  6778.  
  6779. Returns:
  6780.  
  6781.   AL            = current verify flag value
  6782.                   00H if verify off
  6783.                   01H if verify on
  6784.  
  6785. Notes:
  6786.  
  6787.   ■ Because read-after-write verification slows disk operations, the default
  6788.     state of the system verify flag is OFF.
  6789.  
  6790.   ■ The state of the system verify flag can be changed through a call to Int
  6791.     21H Function 2EH or by the MS-DOS commands VERIFY ON and VERIFY OFF.
  6792.  
  6793. Example:
  6794.  
  6795.   Obtain the state of the system verify flag.
  6796.  
  6797.           .
  6798.           .
  6799.           .
  6800.           mov     ah,54h          ; function number
  6801.           int     21h             ; transfer to MS-DOS
  6802.           cmp     al,01h          ; check verify state
  6803.           je      label1          ; jump if verify on
  6804.                                   ; else assume verify off
  6805.           .
  6806.           .
  6807.           .
  6808.  
  6809.  
  6810. ────────────────────────────────────────────────────────────────────────────
  6811. Int 21H
  6812. Function 55H (85)
  6813. Reserved
  6814. ────────────────────────────────────────────────────────────────────────────
  6815.  
  6816.  
  6817. ────────────────────────────────────────────────────────────────────────────
  6818. Int 21H                                                                [2.0]
  6819. Function 56H (86)
  6820. Rename file
  6821. ────────────────────────────────────────────────────────────────────────────
  6822.  
  6823.   Renames a file and/or moves its directory entry to a different directory
  6824.   on the same disk. In MS-DOS version 3.0 and later, this function can also
  6825.   be used to rename directories.
  6826.  
  6827. Call with:
  6828.  
  6829.   AH            = 56H
  6830.   DS:DX         = segment:offset of current ASCIIZ pathname
  6831.   ES:DI         = segment:offset of new ASCIIZ pathname
  6832.  
  6833. Returns:
  6834.  
  6835.   If function successful
  6836.  
  6837.   Carry flag    = clear
  6838.  
  6839.   If function unsuccessful
  6840.  
  6841.   Carry flag    = set
  6842.   AX            = error code
  6843.  
  6844. Notes:
  6845.  
  6846.   ■ The function fails if:
  6847.  
  6848.     ∙ any element of the pathname does not exist.
  6849.  
  6850.     ∙ a file with the new pathname already exists.
  6851.  
  6852.     ∙ the current pathname specification contains a different disk drive
  6853.       than does the new pathname.
  6854.  
  6855.     ∙ the file is being moved to the root directory, and the root directory
  6856.       is full.
  6857.  
  6858.     ∙ [3.0+] the program is running on a network and the user has
  6859.       insufficient access rights to either the existing file or the new
  6860.       directory.
  6861.  
  6862.   ■ The * and ? wildcard characters are not allowed in either the current or
  6863.     new pathname specifications.
  6864.  
  6865. Example:
  6866.  
  6867.   Change the name of the file MYFILE.DAT in the directory \MYDIR on drive C
  6868.   to MYTEXT.DAT. At the same time, move the file to the directory \SYSTEM on
  6869.   the same drive.
  6870.  
  6871.   oldname db      'C:\MYDIR\MYFILE.DAT',0
  6872.  
  6873.   newname db      'C:\SYSTEM\MYTEXT.DAT',0
  6874.           .
  6875.           .
  6876.           .
  6877.           mov     ah,56h          ; function number
  6878.           mov     dx,seg oldname  ; old filename address
  6879.           mov     ds,dx
  6880.           mov     dx,offset oldname
  6881.           mov     di,seg newname  ; new filename address
  6882.           mov     es,di
  6883.           mov     di,offset newname
  6884.           int     21h             ; transfer to MS-DOS
  6885.           jc      error           ; jump if rename failed
  6886.           .
  6887.           .
  6888.           .
  6889.  
  6890.  
  6891. ────────────────────────────────────────────────────────────────────────────
  6892. Int 21H                                                                [2.0]
  6893. Function 57H (87)
  6894. Get or set file date and time
  6895. ────────────────────────────────────────────────────────────────────────────
  6896.  
  6897.   Obtains or modifies the date and time stamp in a file's directory entry.
  6898.  
  6899. Call with:
  6900.  
  6901.   If getting date and time
  6902.  
  6903.   AH            = 57H
  6904.   AL            = 00H
  6905.   BX            = handle
  6906.  
  6907.   If setting date and time
  6908.  
  6909.   AH            = 57H
  6910.   AL            = 01H
  6911.   BX            = handle
  6912.   CX            = time
  6913.                   bits 00H─04H = 2-second increments (0─29)
  6914.                   bits 05H─0AH = minutes (0─59)
  6915.                   bits 0BH─0FH = hours (0─23)
  6916.   DX            = date
  6917.                   bits 00H─04H = day (1─31)
  6918.                   bits 05H─08H = month (1─12)
  6919.                   bits 09H─0FH = year (relative to 1980)
  6920.  
  6921. Returns:
  6922.  
  6923.   If function successful
  6924.  
  6925.   Carry flag    = clear
  6926.  
  6927.   and, if called with AL = 00H
  6928.  
  6929.   CX            = time
  6930.   DX            = date
  6931.  
  6932.   If function unsuccessful
  6933.  
  6934.   Carry flag    = set
  6935.   AX            = error code
  6936.  
  6937. Notes:
  6938.  
  6939.   ■ The file must have been previously opened or created via a successful
  6940.     call to Int 21H Function 3CH, 3DH, 5AH, 5BH, or 6CH.
  6941.  
  6942.   ■ If the 16-bit date for a file is set to zero, that file's date and time
  6943.     are not displayed on directory listings.
  6944.  
  6945.   ■ A date and time set with this function will prevail, even if the file is
  6946.     modified afterwards before the handle is closed.
  6947.  
  6948. Example:
  6949.  
  6950.   Get the date that the file MYFILE.DAT was created or last modified, and
  6951.   then decompose the packed date into its constituent parts in the variables
  6952.   month, day, and year.
  6953.  
  6954.   fname   db      'MYFILE.DAT',0
  6955.  
  6956.   month   dw      0
  6957.   day     dw      0
  6958.   year    dw      0
  6959.           .
  6960.           .
  6961.           .
  6962.                                   ; first open the file
  6963.           mov     ah,3dh          ; function number
  6964.           mov     al,0            ; read-only mode
  6965.           mov     dx,seg fname    ; filename address
  6966.           mov     ds,dx
  6967.           mov     dx,offset fname
  6968.           int     21h             ; transfer to MS-DOS
  6969.           jc      error           ; jump if open failed
  6970.  
  6971.                                   ; get file date/time
  6972.           mov     bx,ax           ; copy handle to BX
  6973.           mov     ah,57h          ; function number
  6974.           mov     al,0            ; 0 = get subfunction
  6975.           int     21h             ; transfer to MS-DOS
  6976.           jc      error           ; jump if function failed
  6977.  
  6978.           mov     day,dx          ; decompose date
  6979.           and     day,01fh        ; isolate day
  6980.           mov     cl,5
  6981.           shr     dx,cl
  6982.           mov     month,dx        ; isolate month
  6983.           and     month,0fh
  6984.           mov     cl,4
  6985.           shr     dx,cl           ; isolate year
  6986.           and     dx,03fh         ; relative to 1980
  6987.           add     dx,1980         ; correct to real year
  6988.           mov     year,dx         ; save year
  6989.  
  6990.                                   ; now close file,
  6991.                                   ; handle still in BX
  6992.           mov     ah,3eh          ; function number
  6993.           int     21h             ; transfer to MS-DOS
  6994.           jc      error           ; jump if close failed
  6995.           .
  6996.           .
  6997.           .
  6998.  
  6999.  
  7000. ────────────────────────────────────────────────────────────────────────────
  7001. Int 21H                                                                [3.0]
  7002. Function 58H (88)
  7003. Get or set allocation strategy
  7004. ────────────────────────────────────────────────────────────────────────────
  7005.  
  7006.   Obtains or changes the code indicating the current MS-DOS strategy for
  7007.   allocating memory blocks.
  7008.  
  7009. Call with:
  7010.  
  7011.   If getting strategy code
  7012.  
  7013.   AH            = 58H
  7014.   AL            = 00H
  7015.  
  7016.   If setting strategy code
  7017.  
  7018.   AH            = 58H
  7019.   AL            = 01H
  7020.   BX            = desired strategy code
  7021.  
  7022.                   00H = first fit
  7023.                   01H = best fit
  7024.                   02H = last fit
  7025.  
  7026. Returns:
  7027.  
  7028.   If function successful
  7029.  
  7030.   Carry flag    = clear
  7031.  
  7032.   and, if called with AL = 00H
  7033.  
  7034.   AX            = current strategy code
  7035.  
  7036.   If function unsuccessful
  7037.  
  7038.   Carry flag    = set
  7039.   AX            = error code
  7040.  
  7041. Notes:
  7042.  
  7043.   ■ The memory allocation strategies are:
  7044.  
  7045.     ∙ First fit: MS-DOS searches the available memory blocks from low
  7046.       addresses to high addresses, assigning the first one large enough to
  7047.       satisfy the block allocation request.
  7048.  
  7049.     ∙ Best fit: MS-DOS searches all available memory blocks and assigns the
  7050.       smallest available block that will satisfy the request, regardless of
  7051.       its position.
  7052.  
  7053.     ∙ Last fit: MS-DOS searches the available memory blocks from high
  7054.       addresses to low addresses, assigning the highest one large enough to
  7055.       satisfy the block allocation request.
  7056.  
  7057.   ■ The default MS-DOS memory allocation strategy is First Fit (code 0).
  7058.  
  7059. Example:
  7060.  
  7061.   Save the code indicating the current memory allocation strategy in the
  7062.   variable strat, then change the system's memory allocation strategy to
  7063.   "best fit."
  7064.  
  7065.   strat   dw      0               ; previous strategy code
  7066.           .
  7067.           .
  7068.           .
  7069.                                   ; get current strategy
  7070.           mov     ah,58h          ; function number
  7071.           mov     al,0            ; 0 = get strategy
  7072.           int     21h             ; transfer to MS-DOS
  7073.           jc      error           ; jump if function failed
  7074.           mov     strat,ax        ; save strategy code
  7075.  
  7076.                                   ; now set new strategy
  7077.           mov     ah,58h          ; function number
  7078.           mov     al,1            ; 1 = set strategy
  7079.           mov     bx,1            ; 1 = best fit
  7080.           int     21h             ; transfer to MS-DOS
  7081.           jc      error           ; jump if function failed
  7082.           .
  7083.           .
  7084.           .
  7085.  
  7086.  
  7087. ────────────────────────────────────────────────────────────────────────────
  7088. Int 21H                                                                [3.0]
  7089. Function 59H (89)
  7090. Get extended error information
  7091. ────────────────────────────────────────────────────────────────────────────
  7092.  
  7093.   Obtains detailed error information after a previous unsuccessful Int 21H
  7094.   function call, including the recommended remedial action.
  7095.  
  7096. Call with:
  7097.  
  7098.   AH            = 59H
  7099.   BX            = 00H
  7100.  
  7101. Returns:
  7102.  
  7103.   AX            = extended error code
  7104.  
  7105.                   01H       function number invalid
  7106.                   02H       file not found
  7107.                   03H       path not found
  7108.                   04H       too many open files
  7109.                   05H       access denied
  7110.                   06H       handle invalid
  7111.                   07H       memory control blocks destroyed
  7112.                   08H       insufficient memory
  7113.                   09H       memory block address invalid
  7114.                   0AH (10)  environment invalid
  7115.                   0BH (11)  format invalid
  7116.                   0CH (12)  access code invalid
  7117.                   0DH (13)  data invalid
  7118.                   0EH (14)  unknown unit
  7119.                   0FH (15)  disk drive invalid
  7120.                   10H (16)  attempted to remove current directory
  7121.                   11H (17)  not same device
  7122.                   12H (18)  no more files
  7123.                   13H (19)  disk write-protected
  7124.                   14H (20)  unknown unit
  7125.                   15H (21)  drive not ready
  7126.                   16H (22)  unknown command
  7127.                   17H (23)  data error (CRC)
  7128.                   18H (24)  bad request structure length
  7129.                   19H (25)  seek error
  7130.                   1AH (26)  unknown media type
  7131.                   1BH (27)  sector not found
  7132.                   1CH (28)  printer out of paper
  7133.                   1DH (29)  write fault
  7134.                   1EH (30)  read fault
  7135.                   1FH (31)  general failure
  7136.                   20H (32)  sharing violation
  7137.                   21H (33)  lock violation
  7138.                   22H (34)  disk change invalid
  7139.                   23H (35)  FCB unavailable
  7140.                   24H (36)  sharing buffer exceeded
  7141.                   25H─31H   reserved
  7142.                   32H (50)  unsupported network request
  7143.                   33H (51)  remote machine not listening
  7144.                   34H (52)  duplicate name on network
  7145.                   35H (53)  network name not found
  7146.                   36H (54)  network busy
  7147.                   37H (55)  device no longer exists on network
  7148.                   38H (56)  netBIOS command limit exceeded
  7149.                   39H (57)  error in network adapter hardware
  7150.                   3AH (58)  incorrect response from network
  7151.                   3BH (59)  unexpected network error
  7152.                   3CH (60)  remote adapter incompatible
  7153.                   3DH (61)  print queue full
  7154.                   3EH (62)  not enough space for print file
  7155.                   3FH (63)  print file canceled
  7156.                   40H (64)  network name deleted
  7157.                   41H (65)  network access denied
  7158.                   42H (66)  incorrect network device type
  7159.                   43H (67)  network name not found
  7160.                   44H (68)  network name limit exceeded
  7161.                   45H (69)  netBIOS session limit exceeded
  7162.                   46H (70)  file sharing temporarily paused
  7163.                   47H (71)  network request not accepted
  7164.                   48H (72)  print or disk redirection paused
  7165.                   49H─4FH   reserved
  7166.                   50H (80)  file already exists
  7167.                   51H (81)  reserved
  7168.                   52H (82)  cannot make directory
  7169.                   53H (83)  fail on Int 24H (critical error)
  7170.                   54H (84)  too many redirections
  7171.                   55H (85)  duplicate redirection
  7172.                   56H (86)  invalid password
  7173.                   57H (87)  invalid parameter
  7174.                   58H (88)  network device fault
  7175.                   59H (89)  function not supported by network
  7176.                   5AH (90)  required system component not installed
  7177.  
  7178.   BH            = error class
  7179.  
  7180.                   01H       if out of resource (such as storage or handles)
  7181.                   02H       if not error, but temporary situation (such as
  7182.                             locked region in file) that can be expected to
  7183.                             end
  7184.                   03H       if authorization problem
  7185.                   04H       if internal error in system software
  7186.                   05H       if hardware failure
  7187.                   06H       if system software failure not the fault of the
  7188.                             active process (such as missing configuration
  7189.                             files)
  7190.                   07H       if application program error
  7191.                   08H       if file or item not found
  7192.                   09H       if file or item of invalid type or format
  7193.                   0AH (10)  if file or item locked
  7194.                   0BH (11)  if wrong disk in drive, bad spot on disk, or
  7195.                             storage medium problem
  7196.                   0CH (12)  if item already exists
  7197.                   0DH (13)  unknown error
  7198.  
  7199.   BL            = recommended action
  7200.  
  7201.                   01H       retry reasonable number of times, then prompt
  7202.                             user to select abort or ignore
  7203.                   02H       retry reasonable number of times with delay
  7204.                             between retries, then prompt user to select
  7205.                             abort or ignore
  7206.                   03H       get corrected information from user (typically
  7207.                             caused by incorrect filename or drive
  7208.                             specification)
  7209.                   04H       abort application with cleanup (i.e., terminate
  7210.                             the program in as orderly a manner as possible:
  7211.                             releasing locks, closing files, etc.)
  7212.                   05H       perform immediate exit without cleanup
  7213.                   06H       ignore error
  7214.                   07H       retry after user intervention to remove cause of
  7215.                             error
  7216.  
  7217.   CH            = error locus
  7218.  
  7219.                   01H       unknown
  7220.                   02H       block device (disk or disk emulator)
  7221.                   03H       network
  7222.                   04H       serial device
  7223.                   05H       memory
  7224.  
  7225.   and, for MS-DOS 3.0 and later,
  7226.  
  7227.   ES:DI         = ASCIIZ volume label of disk to insert, if AX = 0022H
  7228.                   (invalid disk change)
  7229.  
  7230. Notes:
  7231.  
  7232.   ■ This function may be called after any other Int 21H function call that
  7233.     returned an error status, in order to obtain more detailed information
  7234.     about the error type and the recommended action. If the previous Int 21H
  7235.     function call had no error, 0000H is returned in register AX. This
  7236.     function may also be called during the execution of a critical-error
  7237.     (Int 24H) handler.
  7238.  
  7239.   ■ The contents of registers CL, DX, SI, DI, BP, DS, and ES are destroyed
  7240.     by this function.
  7241.  
  7242.   ■ Note that extended error codes 13H─1FH (19─31) and 34 (22H) correspond
  7243.     exactly to the error codes 0─0CH (0─12) and 0FH (15) returned by Int
  7244.     24H.
  7245.  
  7246.   ■ You should not code your programs to recognize only specific error
  7247.     numbers if you wish to ensure upward compatibility, because new error
  7248.     codes are added in each version of MS-DOS.
  7249.  
  7250. Example:
  7251.  
  7252.   Attempt to open the file named NOSUCH.DAT using a file control block; if
  7253.   the open request fails, get the extended error code.
  7254.  
  7255.   myfcb   db      0               ; drive = default
  7256.           db      'NOSUCH  '      ; filename, 8 chars
  7257.           db      'DAT'           ; extension, 3 chars
  7258.           db      25 dup (0)      ; remainder of FCB
  7259.           .
  7260.           .
  7261.           .
  7262.   label1:                         ; open the file
  7263.           mov     ah,0fh          ; function number
  7264.           mov     dx,seg myfcb    ; address of FCB
  7265.           mov     ds,dx
  7266.           mov     dx,offset myfcb
  7267.           int     21h             ; transfer to MS-DOS
  7268.           or      al,al           ; check open status
  7269.           jz      success         ; jump if opened OK
  7270.  
  7271.                                   ; open failed, get
  7272.                                   ; extended error info
  7273.           mov     ah,59h          ; function number
  7274.           xor     bx,bx           ; BX must = 0
  7275.           int     21h             ; transfer to MS-DOS
  7276.           or      ax,ax           ; double check for error
  7277.           jz      success         ; jump if no error
  7278.  
  7279.           cmp     bl,2            ; should we retry?
  7280.           jle     label1          ; yes, jump
  7281.           jmp     error           ; no, give up
  7282.           .
  7283.           .
  7284.           .
  7285.  
  7286.  
  7287. ────────────────────────────────────────────────────────────────────────────
  7288. Int 21H                                                                [3.0]
  7289. Function 5AH (90)
  7290. Create temporary file
  7291. ────────────────────────────────────────────────────────────────────────────
  7292.  
  7293.   Creates a file with a unique name, in the current or specified directory
  7294.   on the default or specified disk drive, and returns a handle that can be
  7295.   used by the program for subsequent access to the file. The name generated
  7296.   for the file is also returned in a buffer specified by the program.
  7297.  
  7298. Call with:
  7299.  
  7300.   AH            = 5AH
  7301.   CX            = attribute (bits may be combined)
  7302.  
  7303.                   Bit(s)    Significance (if set)
  7304.                   0         read-only
  7305.                   1         hidden
  7306.                   2         system
  7307.                   3─4       reserved (0)
  7308.                   5         archive
  7309.                   6─15      reserved (0)
  7310.  
  7311.   DS:DX         = segment:offset of ASCIIZ path
  7312.  
  7313. Returns:
  7314.  
  7315.   If function successful
  7316.  
  7317.   Carry flag    = clear
  7318.   AX            = handle
  7319.   DS:DX         = segment:offset of complete ASCIIZ pathname
  7320.  
  7321.   If function unsuccessful
  7322.  
  7323.   Carry flag    = set
  7324.   AX            = error code
  7325.  
  7326. Notes:
  7327.  
  7328.   ■ The ASCIIZ path supplied to this function should be followed by at least
  7329.     13 additional bytes of buffer space. MS-DOS adds a backslash (\) to the
  7330.     supplied path, if necessary, then appends a null-terminated filename
  7331.     that is a function of the current time.
  7332.  
  7333.   ■ Files created with this function are not automatically deleted when the
  7334.     calling program terminates.
  7335.  
  7336.   ■ The function fails if
  7337.  
  7338.     ∙ any element of the pathname does not exist.
  7339.  
  7340.     ∙ the file is being created in the root directory, and the root
  7341.       directory is full.
  7342.  
  7343.   ■ See also Int 21H Functions 3CH, 5BH, and 6CH, which provide
  7344.     additional facilities for creating files.
  7345.  
  7346.   ■ [3.0+] If the program is running on a network, the file is created and
  7347.     opened for read/write access in compatibility sharing mode.
  7348.  
  7349. Example:
  7350.  
  7351.   Create a temporary file with a unique name and normal attribute in
  7352.   directory \TEMP of drive C. Note that you must allow room for MS-DOS to
  7353.   append the generated filename to the supplied path. The complete file
  7354.   specification should be used to delete the temporary file before your
  7355.   program terminates.
  7356.  
  7357.   fname   db      'C:\TEMP\'      ; pathname for temp file
  7358.           db      13 dup (0)      ; receives filename
  7359.  
  7360.   fhandle dw      ?               ; file handle
  7361.           .
  7362.           .
  7363.           .
  7364.           mov     ah,5ah          ; function number
  7365.           mov     cx,0            ; normal attribute
  7366.           mov     dx,seg fname    ; address of pathname
  7367.           mov     ds,dx
  7368.           mov     dx,offset fname
  7369.           int     21h             ; transfer to MS-DOS
  7370.           jc      error           ; jump if create failed
  7371.           mov     fhandle,ax      ; save file handle
  7372.           .
  7373.           .
  7374.           .
  7375.  
  7376.  
  7377. ────────────────────────────────────────────────────────────────────────────
  7378. Int 21H                                                                [3.0]
  7379. Function 5BH (91)
  7380. Cre te new file
  7381. ────────────────────────────────────────────────────────────────────────────
  7382.  
  7383.   Given an ASCIIZ pathname, creates a file in the designated or default
  7384.   directory on the designated or default drive, and returns a handle that
  7385.   can be used by the program for subsequent access to the file. If a file
  7386.   with the same name already exists, the function fails.
  7387.  
  7388. Call with:
  7389.  
  7390.   AH            = 5BH
  7391.   CX            = attribute (bits may be combined)
  7392.  
  7393.                   Bit(s)    Significance (if set)
  7394.                   0         read-only
  7395.                   1         hidden
  7396.                   2         system
  7397.                   3         volume label
  7398.                   4         reserved (0)
  7399.                   5         archive
  7400.                   6─15      reserved (0)
  7401.  
  7402.   DS:DX         = segment:offset of ASCIIZ pathname
  7403.  
  7404. Returns:
  7405.  
  7406.   If function successful
  7407.  
  7408.   Carry flag    = clear
  7409.   AX            = handle
  7410.  
  7411.   If function unsuccessful
  7412.  
  7413.   Carry flag    = set
  7414.   AX            = error code
  7415.  
  7416. Notes:
  7417.  
  7418.   ■ The function fails if:
  7419.  
  7420.     ∙ any element of the specified path does not exist.
  7421.  
  7422.     ∙ a file with the identical pathname (i.e., the same filename and
  7423.       extension in the same location in the directory structure) already
  7424.       exists.
  7425.  
  7426.     ∙ the file is being created in the root directory, and the root
  7427.       directory is full.
  7428.  
  7429.     ∙ [3.0+] the program is running on a network, and the user has
  7430.       insufficient access rights to the directory that will contain the
  7431.       file.
  7432.  
  7433.   ■ The file is usually given a normal attribute (0) when it is created, and
  7434.     is opened for both read and write operations. The attribute can
  7435.     subsequently be modified with Int 21H Function 43H.
  7436.  
  7437.   ■ See also Int 21H Functions 3CH, 5AH, and 6CH, which provide
  7438.     alternative ways of creating files.
  7439.  
  7440.   ■ This function may be used to implement semaphores in a network or
  7441.     multitasking environment. If the function succeeds, the program has
  7442.     acquired the semaphore. To release the semaphore, the program simply
  7443.     deletes the file.
  7444.  
  7445. Example:
  7446.  
  7447.   Create and open a file named MYFILE.DAT in the directory \MYDIR on drive
  7448.   C; MS-DOS returns an error if a file with the same name already exists in
  7449.   that location.
  7450.  
  7451.   fname   db      'C:\MYDIR\MYFILE.DAT',0
  7452.  
  7453.   fhandle dw      ?               ; file handle
  7454.           .
  7455.           .
  7456.           .
  7457.           mov     ah,5bh          ; function number
  7458.           xor     cx,cx           ; normal attribute
  7459.           mov     dx,seg fname    ; filename address
  7460.           mov     ds,dx
  7461.           mov     dx,offset fname
  7462.           int     21h             ; transfer to MS-DOS
  7463.           jc      error           ; jump if create failed
  7464.           mov     fhandle,ax      ; save file handle
  7465.           .
  7466.           .
  7467.           .
  7468.  
  7469.  
  7470. ────────────────────────────────────────────────────────────────────────────
  7471. Int 21H                                                                [3.0]
  7472. Function 5CH (92)
  7473. Lock or unlock file region
  7474. ────────────────────────────────────────────────────────────────────────────
  7475.  
  7476.   Locks or unlocks the specified region of a file. This function is not
  7477.   available unless the file-sharing module (SHARE.EXE) is loaded.
  7478.  
  7479. Call with:
  7480.  
  7481.   AH            = 5CH
  7482.   AL            = 00H       if locking region
  7483.                   01H       if unlocking region
  7484.  
  7485.   BX            = handle
  7486.   CX            = high part of region offset
  7487.   DX            = low part of region offset
  7488.   SI            = high part of region length
  7489.   DI            = low part of region length
  7490.  
  7491. Returns:
  7492.  
  7493.   If function successful
  7494.  
  7495.   Carry flag    = clear
  7496.  
  7497.   If function unsuccessful
  7498.  
  7499.   Carry flag    = set
  7500.   AX            = error code
  7501.  
  7502. Notes:
  7503.  
  7504.   ■ This function is useful for file and record synchronization in a
  7505.     multitasking environment or network. Access to the file as a whole is
  7506.     controlled by the attribute and file-sharing parameters passed in open
  7507.     or create calls and by the file's attributes, which are stored in its
  7508.     directory entry.
  7509.  
  7510.   ■ The beginning location in the file to be locked or unlocked is supplied
  7511.     as a positive double precision integer, which is a byte offset into the
  7512.     file. The length of the region to be locked or unlocked is similarly
  7513.     supplied as a positive double precision integer.
  7514.  
  7515.   ■ For every call to lock a region of a file, there must be a subsequent
  7516.     unlock call with exactly the same file offset and length.
  7517.  
  7518.   ■ Locking beyond the current end of file is not an error.
  7519.  
  7520.   ■ Duplicate handles created with Int 21H Function 45H, or handles
  7521.     redirected to the file with Int 21H Function 46H, are allowed access to
  7522.     locked regions within the same process.
  7523.  
  7524.   ■ Programs that are loaded with the EXEC call (Int 21H Function 4BH)
  7525.     inherit the handles of their parent but not any active locks.
  7526.  
  7527.   ■ If a process terminates without releasing active locks on a file, the
  7528.     result is undefined. Therefore, programs using this function should
  7529.     install their own Int 23H and Int 24H handlers so that they cannot be
  7530.     terminated unexpectedly.
  7531.  
  7532. Example:
  7533.  
  7534.   Assume that a file was previously opened and that its handle was saved in
  7535.   the variable fhandle. Lock a 4096 byte region of the file, starting at
  7536.   32,768 bytes from the beginning of the file, so that it cannot be accessed
  7537.   by other programs.
  7538.  
  7539.   fhandle dw      ?               ; file handle
  7540.           .
  7541.           .
  7542.           .
  7543.           mov     ah,5ch          ; function number
  7544.           mov     al,0            ; subfunction 0 = lock
  7545.           mov     bx,fhandle      ; file handle
  7546.           mov     cx,0            ; upper part of offset
  7547.           mov     dx,32768        ; lower part of offset
  7548.           mov     si,0            ; upper part of length
  7549.           mov     di,4096         ; lower part of length
  7550.           int     21h             ; transfer to MS-DOS
  7551.           jc      error           ; jump if lock failed
  7552.           .
  7553.           .
  7554.           .
  7555.  
  7556.  
  7557. ────────────────────────────────────────────────────────────────────────────
  7558. Int 21H
  7559. Function 5DH (93)
  7560. Reserved
  7561. ────────────────────────────────────────────────────────────────────────────
  7562.  
  7563.  
  7564. ────────────────────────────────────────────────────────────────────────────
  7565. Int 21H                                                                [3.1]
  7566. Function 5EH (94) Subfunction 00H
  7567. Get machine name
  7568. ────────────────────────────────────────────────────────────────────────────
  7569.  
  7570.   Returns the address of an ASCIIZ (null-terminated) string identifying the
  7571.   local computer. This function call is only available when Microsoft
  7572.   Networks is running.
  7573.  
  7574. Call with:
  7575.  
  7576.   AH            = 5EH
  7577.   AL            = 00H
  7578.   DS:DX         = segment:offset of buffer to receive string
  7579.  
  7580. Returns:
  7581.  
  7582.   If function successful
  7583.  
  7584.   Carry flag    = clear
  7585.  
  7586.   CH            = 00H       if name not defined
  7587.                   <> 00H    if name defined
  7588.  
  7589.   CL            = netBIOS name number (if CH <> 0)
  7590.   DX:DX         = segment:offset of identifier (if CH <> 0 )
  7591.  
  7592.   If function unsuccessful
  7593.  
  7594.   Carry flag    = set
  7595.   AX            = error code
  7596.  
  7597. Notes:
  7598.  
  7599.   ■ The computer identifier is a 15-byte string, padded with spaces and
  7600.     terminated with a null (00H) byte.
  7601.  
  7602.   ■ The effect of this call is unpredictable if the file-sharing support
  7603.     module is not loaded.
  7604.  
  7605. Example:
  7606.  
  7607.   Get the machine name of the local computer into the buffer named mname.
  7608.  
  7609.   mname   db      16 dup (?)
  7610.           .
  7611.           .
  7612.           .
  7613.           mov     ax,5e00h        ; function & subfunction
  7614.           mov     dx,seg mname    ; address of buffer
  7615.           mov     ds,dx
  7616.           mov     dx,offset mname
  7617.           int     21h             ; transfer to MS-DOS
  7618.           jc      error           ; jump if function failed
  7619.  
  7620.           or      ch,ch           ; make sure name exists
  7621.           jz      error           ; jump if no name defined
  7622.           .
  7623.           .
  7624.           .
  7625.  
  7626.  
  7627. ────────────────────────────────────────────────────────────────────────────
  7628. Int 21H                                                                [3.1]
  7629. Function 5EH (94) Subfunction 02H
  7630. Set printer setup string
  7631. ────────────────────────────────────────────────────────────────────────────
  7632.  
  7633.   Specifies a string to be sent in front of all files directed to a
  7634.   particular network printer, allowing users at different network nodes to
  7635.   specify individualized operating modes on the same printer. This function
  7636.   call is only available when Microsoft Networks is running.
  7637.  
  7638. Call with:
  7639.  
  7640.   AH            = 5EH
  7641.   AL            = 02H
  7642.   BX            = redirection list index
  7643.   CX            = length of setup string
  7644.   DS:SI         = segment:offset of setup string
  7645.  
  7646. Returns:
  7647.  
  7648.   If function successful
  7649.  
  7650.   Carry flag    = clear
  7651.  
  7652.   If function unsuccessful
  7653.  
  7654.   Carry flag    = set
  7655.  
  7656.   AX            = error code
  7657.  
  7658. Notes:
  7659.  
  7660.   ■ The redirection list index passed in register BX is obtained with
  7661.     Function 5FH Subfunction 02H (Get Redirection List Entry).
  7662.  
  7663.   ■ See also Function 5EH Subfunction 03H, which may be used to obtain the
  7664.     existing setup string for a particular network printer.
  7665.  
  7666. Example:
  7667.  
  7668.   Initialize the setup string for the printer designated by redirection list
  7669.   index 2 so that the device is put into boldface mode before printing a
  7670.   file requested by this network node.
  7671.  
  7672.   setup   db      01bh,045h       ; selects boldface mode
  7673.           .
  7674.           .
  7675.           .
  7676.           mov     ax,5e02h        ; function & subfunction
  7677.           mov     bx,2            ; redirection list index 2
  7678.           mov     cx,2            ; length of setup string
  7679.           mov     si,seg setup    ; address of setup string
  7680.           mov     ds,si
  7681.           mov     si,offset setup
  7682.           int     21h             ; transfer to MS-DOS
  7683.           jc      error           ; jump if function failed
  7684.           .
  7685.           .
  7686.           .
  7687.  
  7688.  
  7689. ────────────────────────────────────────────────────────────────────────────
  7690. Int 21H                                                                [3.1]
  7691. Function 5EH (94) Subfunction 03H
  7692. Get printer setup string
  7693. ────────────────────────────────────────────────────────────────────────────
  7694.  
  7695.   Obtains the printer setup string for a particular network printer. This
  7696.   function call is only available when Microsoft Networks is running.
  7697.  
  7698. Call with:
  7699.  
  7700.   AH            = 5EH
  7701.   AL            = 03H
  7702.   BX            = redirection list index
  7703.   ES:DI         = segment:offset of buffer to receive setup string
  7704.  
  7705. Returns:
  7706.  
  7707.   If function successful
  7708.  
  7709.   Carry flag    = clear
  7710.   CX            = length of printer setup string
  7711.   ES:DI         = address of buffer holding setup string
  7712.  
  7713.   If function unsuccessful
  7714.  
  7715.   Carry flag    = set
  7716.   AX            = error code
  7717.  
  7718. Notes:
  7719.  
  7720.   ■ The redirection list index passed in register BX is obtained with
  7721.     Function 5FH Subfunction 02H (Get Redirection List Entry).
  7722.  
  7723.   ■ See also Int 21H Function 5EH Subfunction 02H, which is used to specify
  7724.     a setup string for a network printer.
  7725.  
  7726. Example:
  7727.  
  7728.   Get the setup string for this network node associated with the printer
  7729.   designated by redirection list index 2.
  7730.  
  7731.   setup   db      64 dup (?)      ; receives setup string
  7732.           .
  7733.           .
  7734.           .
  7735.           mov     ax,5e03h        ; function & subfunction
  7736.           mov     bx,2            ; redirection list index 2
  7737.           mov     di,seg setup    ; address of buffer
  7738.           mov     es,di
  7739.           mov     di,offset setup
  7740.           int     21h             ; transfer to MS-DOS
  7741.           jc      error           ; jump if function failed
  7742.           .
  7743.           .
  7744.           .
  7745.  
  7746.  
  7747. ────────────────────────────────────────────────────────────────────────────
  7748. Int 21H                                                                [3.1]
  7749. Function 5FH (95) Subfunction 02H
  7750. Get redirection list entry
  7751. ────────────────────────────────────────────────────────────────────────────
  7752.  
  7753.   Allows inspection of the system redirection list, which associates local
  7754.   logical names with network files, directories, or printers. This function
  7755.   call is only available when Microsoft Networks is running and the
  7756.   file-sharing module (SHARE.EXE) has been loaded.
  7757.  
  7758. Call with:
  7759.  
  7760.   AH            = 5FH
  7761.   AL            = 02H
  7762.   BX            = redirection list index
  7763.   DS:SI         = segment:offset of 16-byte buffer to receive local device
  7764.                   name
  7765.   ES:DI         = segment:offset of 128-byte buffer to receive network name
  7766.  
  7767. Returns:
  7768.  
  7769.   If function successful
  7770.  
  7771.   Carry flag    = clear
  7772.   BH            = device status flag
  7773.  
  7774.                   bit 0     = 0 if device valid
  7775.                             = 1 if not valid
  7776.  
  7777.   BL            = device type
  7778.  
  7779.                   03H       if printer
  7780.                   04H       if drive
  7781.  
  7782.   CX            = stored parameter value
  7783.   DX            = destroyed
  7784.   BP            = destroyed
  7785.   DS:SI         = segment:offset of ASCIIZ local device name
  7786.   ES:DI         = segment:offset of ASCIIZ network name
  7787.  
  7788.   If function unsuccessful
  7789.  
  7790.   Carry flag    = set
  7791.   AX            = error code
  7792.  
  7793. Note:
  7794.  
  7795.   ■ The parameter returned in CX is a value that was previously passed to
  7796.     MS-DOS in register CX with Int 21H Function 5FH Subfunction 03H
  7797.     (Redirect Device). It represents data that is private to the
  7798.     applications which store and retrieve it and has no meaning to MS-DOS.
  7799.  
  7800. Example:
  7801.  
  7802.   Get the local and network names for the device specified by the first
  7803.   redirection list entry.
  7804.  
  7805.   local   db      16 dup (?)      ; receives local device name
  7806.  
  7807.   network db      128 dup (?)     ; receives network name
  7808.           .
  7809.           .
  7810.           .
  7811.           mov     ax,5f02h        ; function & subfunction
  7812.           mov     bx,0            ; redirection list entry 0
  7813.           mov     si,seg local    ; local name buffer addr
  7814.           mov     ds,si
  7815.           mov     si,offset local
  7816.           mov     di,seg network  ; network name buffer addr
  7817.           mov     es,di
  7818.           mov     di,offset network
  7819.           int     21h             ; transfer to MS-DOS
  7820.           jc      error           ; jump if call failed
  7821.  
  7822.           or      bh,bh           ; check device status
  7823.           jnz     error           ; jump if device not valid
  7824.           .
  7825.           .
  7826.           .
  7827.  
  7828.  
  7829. ────────────────────────────────────────────────────────────────────────────
  7830. Int 21H                                                                [3.1]
  7831. Function 5FH (95) Subfunction 03H
  7832. Redirect device
  7833. ────────────────────────────────────────────────────────────────────────────
  7834.  
  7835.   Establishes redirection across the network by associating a local device
  7836.   name with a network name. This function call is only available when
  7837.   Microsoft Networks is running and the file-sharing module (SHARE.EXE) has
  7838.   been loaded.
  7839.  
  7840. Call with:
  7841.  
  7842.   AH            = 5FH
  7843.   AL            = 03H
  7844.   BL            = device type
  7845.  
  7846.                   03H       if printer
  7847.                   04H       if drive
  7848.  
  7849.   CX            = parameter to save for caller
  7850.   DS:SI         = segment:offset of ASCIIZ local device name
  7851.   ES:DI         = segment:offset of ASCIIZ network name, followed by ASCIIZ
  7852.                   password
  7853.  
  7854. Returns:
  7855.  
  7856.   If function successful
  7857.  
  7858.   Carry flag    = clear
  7859.  
  7860.   If function unsuccessful
  7861.  
  7862.   Carry flag    = set
  7863.   AX            = error code
  7864.  
  7865. Notes:
  7866.  
  7867.   ■ The local name can be a drive designator (a letter followed by a colon,
  7868.     such as "D:"), a printer name, or a null string. Printer names must be
  7869.     one of the following: PRN, LPT1, LPT2, or LPT3. If a null string
  7870.     followed by a password is used, MS-DOS attempts to grant access to the
  7871.     network directory with the specified password.
  7872.  
  7873.   ■ The parameter passed in CX can be retrieved by later calls to Int 21H
  7874.     Function 5FH Subfunction 02H. It represents data that is private to the
  7875.     applications which store and retrieve it and has no meaning to MS-DOS.
  7876.  
  7877. Example:
  7878.  
  7879.   Redirect the local drive E to the directory \FORTH on the server named
  7880.   LMI, using the password FRED.
  7881.  
  7882.   locname db      'E:',0          ; local drive
  7883.  
  7884.   netname db      '\\LMI\FORTH',0
  7885.           db      'FRED',0
  7886.           .
  7887.           .
  7888.           .
  7889.           mov     ax,5f03h        ; function & subfunction
  7890.           mov     bl,4            ; code 4 = disk drive
  7891.           mov     si,seg locname  ; address of local name
  7892.           mov     ds,si
  7893.           mov     si,offset locname
  7894.           mov     di,seg netname  ; address of network name
  7895.           mov     es,di
  7896.           mov     di,offset netname
  7897.           int     21h             ; transfer to MS-DOS
  7898.           jc      error           ; jump if redirect failed
  7899.           .
  7900.           .
  7901.           .
  7902.  
  7903.  
  7904. ────────────────────────────────────────────────────────────────────────────
  7905. Int 21H                                                                [3.1]
  7906. Function 5FH (95) Subfunction 04H
  7907. Cancel device redirection
  7908. ────────────────────────────────────────────────────────────────────────────
  7909.  
  7910.   Cancels a previous redirection request by removing the association of a
  7911.   local device name with a network name. This function call is only
  7912.   available when Microsoft Networks is running and the file-sharing module
  7913.   (SHARE.EXE) has been loaded.
  7914.  
  7915. Call with:
  7916.  
  7917.   AH            = 5FH
  7918.   AL            = 04H
  7919.   DS:SI         = segment:offset of ASCIIZ local device name
  7920.  
  7921. Returns:
  7922.  
  7923.   If function successful
  7924.  
  7925.   Carry flag    = clear
  7926.  
  7927.   If function unsuccessful
  7928.  
  7929.   Carry flag    = set
  7930.   AX            = error code
  7931.  
  7932. Note:
  7933.  
  7934.   ■ The supplied name can be a drive designator (a letter followed by a
  7935.     colon, such as "D:"), a printer name, or a string starting with two
  7936.     backslashes (\\). Printer names must be one of the following: PRN, LPT1,
  7937.     LPT2, or LPT3. If the string with two backslashes is used, the
  7938.     connection between the local machine and the network directory is
  7939.     terminated.
  7940.  
  7941. Example:
  7942.  
  7943.   Cancel the redirection of local drive E to the network server.
  7944.  
  7945.   locname db      'E:',0
  7946.           .
  7947.           .
  7948.           .         mov     ax,5f04h        ; function & subfunction
  7949.           mov     si,seg locname  ; address of local name
  7950.           mov     ds,si
  7951.           mov     si,offset locname
  7952.           int     21h             ; transfer to MS-DOS
  7953.           jc      error           ; jump if cancel failed
  7954.           .
  7955.           .
  7956.           .
  7957.  
  7958.  
  7959. ────────────────────────────────────────────────────────────────────────────
  7960. Int 21H
  7961. Function 60H (96)
  7962. Reserved
  7963. ────────────────────────────────────────────────────────────────────────────
  7964.  
  7965.  
  7966. ────────────────────────────────────────────────────────────────────────────
  7967. Int 21H
  7968. Function 61H (97)
  7969. Reserved
  7970. ────────────────────────────────────────────────────────────────────────────
  7971.  
  7972.  
  7973. ────────────────────────────────────────────────────────────────────────────
  7974. Int 21H                                                                [3.0]
  7975. Function 62H (98)
  7976. Get PSP address
  7977. ────────────────────────────────────────────────────────────────────────────
  7978.  
  7979.   Obtains the segment (paragraph) address of the program segment prefix
  7980.   (PSP) for the currently executing program.
  7981.  
  7982. Call with:
  7983.  
  7984.   AH            = 62H
  7985.  
  7986. Returns:
  7987.  
  7988.   BX            = segment address of program segment prefix
  7989.  
  7990. Notes:
  7991.  
  7992.   ■ Before a program receives control from MS-DOS, its program segment
  7993.     prefix is set up to contain certain vital information, such as:
  7994.  
  7995.     ∙ the segment address of the program's environment block
  7996.  
  7997.     ∙ the command line originally entered by the user
  7998.  
  7999.     ∙ the original contents of the terminate, Ctrl-C, and critical-error
  8000.       handler vectors
  8001.  
  8002.     ∙ the top address of available RAM
  8003.  
  8004.   ■ The segment address of the PSP is normally passed to the program in
  8005.     registers DS and ES when it initially receives control from MS-DOS. This
  8006.     function allows a program to conveniently recover the PSP address at any
  8007.     point during its execution, without having to save it at program entry.
  8008.  
  8009. Example:
  8010.  
  8011.   Get the segment base of the program segment prefix, then copy the command
  8012.   tail from the PSP into the local buffer named buff.
  8013.  
  8014.   ctail   equ     080H            ; PSP offset, command tail
  8015.  
  8016.   buff    db      80 dup (?)      ; copy of command tail
  8017.           .
  8018.           .
  8019.           .
  8020.                                   ; get PSP address
  8021.           mov     ah,62H          ; function number
  8022.           int     21h             ; transfer to MS-DOS
  8023.  
  8024.                                   ; copy command tail
  8025.           mov     ds,bx           ; PSP segment to DS
  8026.           mov     si,offset ctail ; offset of command tail
  8027.           mov     di,seg buff     ; local buffer address
  8028.           mov     es,di
  8029.           mov     di,offset buff
  8030.           mov     cl,[si]         ; length of command tail
  8031.           inc     cl              ; include count byte
  8032.           xor     ch,ch
  8033.           cld
  8034.           rep movsb               ; copy to local buffer
  8035.           .
  8036.           .
  8037.           .
  8038.  
  8039.  
  8040. ────────────────────────────────────────────────────────────────────────────
  8041. Int 21H                                                          [2.25 only]
  8042. Function 63H (99)
  8043. Get DBCS lead byte table
  8044. ────────────────────────────────────────────────────────────────────────────
  8045.  
  8046.   Obtains the address of the system table of legal lead byte ranges for
  8047.   double-byte character sets (DBCS), or sets or obtains the interim console
  8048.   flag. Int 21H Function 63H is available only in MS-DOS version 2.25; it
  8049.   is not supported in MS-DOS versions 3.0 and later.
  8050.  
  8051. Call with:
  8052.  
  8053.   AH            = 63H
  8054.   AL            = subfunction
  8055.  
  8056.                   00H       if getting address of DBCS lead byte table
  8057.                   01H       if setting or clearing interim console flag
  8058.                   02H       if obtaining value of interim console flag
  8059.  
  8060.   If AL = 01H
  8061.  
  8062.   DL            = 00H       if clearing interim console flag
  8063.                   01H       if setting interim console flag
  8064.  
  8065. Returns:
  8066.  
  8067.   If function successful
  8068.  
  8069.   Carry flag    = clear
  8070.  
  8071.   and, if called with AL = 00H
  8072.  
  8073.   DS:SI         = segment:offset of DBCS lead byte table
  8074.  
  8075.   or, if called with AL = 02H
  8076.  
  8077.   DL            = value of interim console flag
  8078.  
  8079.   If function unsuccessful
  8080.  
  8081.   Carry flag    = set
  8082.   AX            = error code
  8083.  
  8084. Notes:
  8085.  
  8086.   ■ The DBCS lead byte table consists of a variable number of two byte
  8087.     entries, terminated by two null (00H) bytes. Each pair defines the
  8088.     beginning and ending value for a range of lead bytes. The value of a
  8089.     legal lead byte is always in the range 80─0FFH.
  8090.  
  8091.   ■ Entries in the lead byte table must be in ascending order. If no legal
  8092.     lead bytes are defined in a given system, the table consists only of the
  8093.     two null bytes.
  8094.  
  8095.   ■ If the interim console flag is set, Int 21H Functions 07H (Unfiltered
  8096.     Character Input), 08H (Character Input without Echo), and 0BH
  8097.     (Keyboard Status) will support interim characters.
  8098.  
  8099.   ■ Unlike most other MS-DOS services, this function call does not
  8100.     necessarily preserve any registers except SS:SP.
  8101.  
  8102.   ■ [4.0] The address of the DBCS lead byte table can also be obtained with
  8103.     Int 21H Function 65H.
  8104.  
  8105.  
  8106. ────────────────────────────────────────────────────────────────────────────
  8107. Int 21H
  8108. Function 64H (100)
  8109. Reserved
  8110. ────────────────────────────────────────────────────────────────────────────
  8111.  
  8112.  
  8113. ────────────────────────────────────────────────────────────────────────────
  8114. Int 21H                                                                [3.3]
  8115. Function 65H (101)
  8116. Get extended country information
  8117. ────────────────────────────────────────────────────────────────────────────
  8118.  
  8119.   Obtains information about the specified country and/or code page.
  8120.  
  8121. Call with:
  8122.  
  8123.   AH            = 65H
  8124.   AL            = subfunction
  8125.                   01H = Get General Internationalization Information
  8126.                   02H = Get Pointer to Uppercase Table
  8127.                   04H = Get Pointer to Filename Uppercase Table
  8128.                   06H = Get Pointer to Collating Table
  8129.                   07H = Get Pointer to Double-Byte Character Set (DBCS)
  8130.                   Vector (MS-DOS versions 4.0 and later)
  8131.  
  8132.   BX            = code page of interest (-1 = active CON device)
  8133.   CX            = length of buffer to receive information (must be >= 5)
  8134.   DX            = country ID (-1 = default)
  8135.   ES:DI         = address of buffer to receive information
  8136.  
  8137. Returns:
  8138.  
  8139.   If function successful
  8140.  
  8141.   Carry flag    = clear
  8142.  
  8143.   and requested data placed in calling program's buffer
  8144.  
  8145.   If function unsuccessful
  8146.  
  8147.   Carry flag    = set
  8148.   AX            = error code
  8149.  
  8150. Notes:
  8151.  
  8152.   ■ The information returned by this function is a superset of the
  8153.     information returned by Int 21H Function 38H.
  8154.  
  8155.   ■ This function may fail if either the country code or the code page
  8156.     number is invalid, or if the code page does not match the country code.
  8157.  
  8158.   ■ The function fails if the specified buffer length is less than five
  8159.     bytes. If the buffer to receive the information is at least five bytes
  8160.     long but is too short for the requested information, the data is
  8161.     truncated and no error is returned.
  8162.  
  8163.   ■ The format of the data returned by Subfunction 01H is:
  8164.  
  8165.     Byte(s)        Contents
  8166.     00H            information ID code (1)
  8167.     01H─02H        length of following buffer
  8168.     03H─04H        country ID
  8169.     05H─06H        code page number
  8170.     07H─08H        date format
  8171.  
  8172.                    0 = USA         m d y
  8173.                    1 = Europe      d m y
  8174.                    2 = Japan       y m d
  8175.  
  8176.     09H─0DH        ASCIIZ currency symbol
  8177.     0EH─0FH        ASCIIZ thousands separator
  8178.     10H─11H        ASCIIZ decimal separator
  8179.     12H─13H        ASCIIZ date separator
  8180.     14H─15H        ASCIIZ time separator
  8181.     16H            currency format flags
  8182.  
  8183.                    bit 0           =>0 if currency symbol precedes value
  8184.                                    =>1 if currency symbol follows value
  8185.                    bit 1           =>0 if no space between value and
  8186.                                    currency symbol
  8187.                                    =>1 if one space between value and
  8188.                                    currency symbol
  8189.                    bit 2           =>0 if currency symbol and decimal are
  8190.                                    separate
  8191.                                    =>1 if currency symbol replaces decimal
  8192.                                    separator
  8193.  
  8194.     17H            number of digits after decimal in currency
  8195.     18H            time format
  8196.  
  8197.                    bit 0           = 0 if 12-hour clock
  8198.                                    = 1 if 24-hour clock
  8199.  
  8200.     19H─1CH        case-map routine call address
  8201.     1DH─1EH        ASCIIZ data list separator
  8202.     1FH─28H        reserved
  8203.  
  8204.   ■ The format of the data returned by Subfunctions 02H, 04H, 06H, and 07H
  8205.     is:
  8206.  
  8207.     Byte(s)        Contents
  8208.     00H            information ID code (2, 4, or 6)
  8209.     01H─05H        double-word pointer to table
  8210.  
  8211.   ■ The uppercase and filename uppercase tables are a maximum of 130 bytes
  8212.     long. The first two bytes contain the size of the table; the following
  8213.     bytes contain the uppercase equivalents, if any, for character codes
  8214.     80H─FFH. The main use of these tables is to map accented or otherwise
  8215.     modified vowels to their plain vowel equivalents. Text translated with
  8216.     the help of this table can be sent to devices that do not support the
  8217.     IBM graphics character set, or used to create filenames that do not
  8218.     require a special keyboard configuration for entry.
  8219.  
  8220.   ■ The collating table is a maximum of 258 bytes long. The first two bytes
  8221.     contain the table length, and the subsequent bytes contain the values to
  8222.     be used for the corresponding character codes (0─FFH) during a sort
  8223.     operation. This table maps uppercase and lowercase ASCII characters to
  8224.     the same collating codes so that sorts will be case-insensitive, and it
  8225.     maps accented vowels to their plain vowel equivalents.
  8226.  
  8227.   ■ [4.0+] Subfunction 07H returns a pointer to a variable length table of
  8228.     that defines ranges for double-byte character set (DBCS) lead bytes. The
  8229.     table is terminated by a pair of zero bytes, unless it must be truncated
  8230.     to fit in the buffer, and has the following format:
  8231.  
  8232.             dw      length
  8233.             db      start1,end1
  8234.             db      start2,end2
  8235.             .
  8236.             .
  8237.             .
  8238.             db      0,0
  8239.  
  8240.     For example:
  8241.  
  8242.             dw      4
  8243.             db      81h,9fh
  8244.             db      0e0h,0fch
  8245.             db      0,0
  8246.  
  8247.   ■ In some cases a truncated translation table may be presented to the
  8248.     program by MS-DOS. Applications should always check the length at the
  8249.     beginning of the table, to make sure it contains a translation code for
  8250.     the particular character of interest.
  8251.  
  8252. Examples:
  8253.  
  8254.   Obtain the extended country information associated with the default
  8255.   country and code page 437.
  8256.  
  8257.   buffer  db      41 dup (0)      ; receives country info
  8258.           .
  8259.           .
  8260.           .
  8261.           mov     ax,6501h        ; function & subfunction
  8262.           mov     bx,437          ; code page
  8263.           mov     cx,41           ; buffer length
  8264.           mov     dx,-1           ; default country
  8265.           mov     di,seg buffer   ; buffer address
  8266.           mov     es,di
  8267.           mov     di,offset buffer
  8268.           int     21h             ; transfer to MS-DOS
  8269.           jc      error           ; jump if function failed
  8270.           .
  8271.           .
  8272.           .
  8273.  
  8274.   In this case, MS-DOS filled the following extended country information
  8275.   into the buffer:
  8276.  
  8277.   buffer  db      1               ; info ID code
  8278.           dw      38              ; length of following buffer
  8279.           dw      1               ; country ID (USA)
  8280.           dw      437             ; code page number
  8281.           dw      0               ; date format
  8282.           db      '$',0,0,0,0     ; currency symbol
  8283.           db      ',',0           ; thousands separator
  8284.           db      '.',0           ; decimal separator
  8285.           db      '-',0           ; date separator
  8286.           db      ':',0           ; time separator
  8287.           db      0               ; currency format flags
  8288.           db      2               ; digits in currency
  8289.           db      0               ; time format
  8290.           dd      026ah:176ch     ; case map entry point
  8291.           db      ',',0           ; data list separator
  8292.           db      10 dup (0)      ; reserved
  8293.  
  8294.   Obtain the pointer to the uppercase table associated with the default
  8295.   country and code page 437.
  8296.  
  8297.   buffer  db      5 dup (0)       ; receives pointer info
  8298.           .
  8299.           .
  8300.           .
  8301.           mov     ax,6502h        ; function number
  8302.           mov     bx,437          ; code page
  8303.           mov     cx,5            ; length of buffer
  8304.           mov     dx,-1           ; default country
  8305.           mov     di,seg buffer   ; buffer address
  8306.           mov     es,di
  8307.           mov     di,offset buffer
  8308.           int     21h             ; transfer to MS-DOS
  8309.           jc      error           ; jump if function failed
  8310.           .
  8311.           .
  8312.           .
  8313.  
  8314.   In this case, MS-DOS filled the following values into the buffer:
  8315.  
  8316.   buffer  db      2               ; info ID code
  8317.           dw      0204h           ; offset of uppercase table
  8318.           dw      1140h           ; segment of uppercase table
  8319.  
  8320.   and the table at 1140:0204H contains the following data:
  8321.  
  8322.               0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  0123456789ABCDEF
  8323.   1140:0200              80 00 80 9A 45 41 8E 41 8F 80 45 45      ....EA.A..EE
  8324.   1140:0210  45 49 49 49 8E 8F 90 92 92 4F 99 4F 55 55 59 99  EIII.....O.OUUY.
  8325.   1140:0220  9A 9B 9C 9D 9E 9F 41 49 4F 55 A5 A5 A6 A7 A8 A9  ......AIOU......
  8326.   1140:0230  AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9  ................
  8327.   1140:0240  BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9  ................
  8328.   1140:0250  CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9  ................
  8329.   1140:0260  DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9  ................
  8330.   1140:0270  EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9  ................
  8331.   1140:0280  FA FB FC FD FE FF                                ......
  8332.  
  8333.  
  8334. ────────────────────────────────────────────────────────────────────────────
  8335. Int 21H                                                                [3.3]
  8336. Function 66H (102)
  8337. Get or set code page
  8338. ────────────────────────────────────────────────────────────────────────────
  8339.  
  8340.   Obtains or selects the current code page.
  8341.  
  8342. Call with:
  8343.  
  8344.   AH            = 66H
  8345.   AL            = subfunction
  8346.                   01H = Get Code Page
  8347.                   02H = Select Code Page
  8348.   BX            = code page to select, if AL = 02H
  8349.  
  8350. Returns:
  8351.  
  8352.   If function successful
  8353.  
  8354.   Carry flag    = clear
  8355.  
  8356.   and, if called with AL = 01H
  8357.  
  8358.   BX            = active code page
  8359.   DX            = default code page
  8360.  
  8361.   If function unsuccessful
  8362.  
  8363.   Carry flag    = set
  8364.   AX            = error code
  8365.  
  8366. Note:
  8367.  
  8368.   ■ When the Select Code Page subfunction is used, MS-DOS gets the new code
  8369.     page from the COUNTRY.SYS file. The device must be previously prepared
  8370.     for code page switching with the appropriate DEVICE= directive in the
  8371.     CONFIG.SYS file and NLSFUNC and MODE CP PREPARE commands (placed in the
  8372.     AUTOEXEC.BAT file, usually).
  8373.  
  8374. Example:
  8375.  
  8376.   Force the active code page to be the same as the system's default code
  8377.   page, that is, restore the code page that was active when the system was
  8378.   first booted.
  8379.  
  8380.           .
  8381.           .
  8382.           .
  8383.                                   ; get current and
  8384.                                   ; default code page
  8385.           mov     ax,6601h        ; function number
  8386.           int     21h             ; transfer to MS-DOS
  8387.           jc      error           ; jump if function failed
  8388.  
  8389.                                   ; set code page
  8390.           mov     bx,dx           ; active = default
  8391.           mov     ax,6602h        ; function number
  8392.           int     21h             ; transfer to MS-DOS
  8393.           jc      error           ; jump if function failed
  8394.           .
  8395.           .
  8396.           .
  8397.  
  8398.  
  8399. ────────────────────────────────────────────────────────────────────────────
  8400. Int 21H                                                                [3.3]
  8401. Function 67H (103)
  8402. Set handle count
  8403. ────────────────────────────────────────────────────────────────────────────
  8404.  
  8405.   Sets the maximum number of files and devices that may be opened
  8406.   simultaneously using handles by the current process.
  8407.  
  8408. Call with:
  8409.  
  8410.   AH            = 67H
  8411.   BX            = number of desired handles
  8412.  
  8413. Returns:
  8414.  
  8415.   If function successful
  8416.  
  8417.   Carry flag    = clear
  8418.  
  8419.   If function unsuccessful
  8420.  
  8421.   Carry flag    = set
  8422.   AX            = error code
  8423.  
  8424. Notes:
  8425.  
  8426.   ■ This function call controls the size of the table that relates handle
  8427.     numbers for the current process to MS-DOS's internal, global table for
  8428.     all of the open files and devices in the system. The default table is
  8429.     located in the reserved area of the process's PSP and is large enough
  8430.     for 20 handles.
  8431.  
  8432.   ■ The function fails if the requested number of handles is greater than 20
  8433.     and there is not sufficient free memory in the system to allocate a new
  8434.     block to hold the enlarged table.
  8435.  
  8436.   ■ If the number of handles requested is larger than the available entries
  8437.     in the system's global table for file and device handles (controlled by
  8438.     the FILES entry in CONFIG.SYS), no error is returned. However, a
  8439.     subsequent attempt to open a file or device, or create a new file, will
  8440.     fail if all the entries in the system's global file table are in use,
  8441.     even if the requesting process has not used up all its own handles.
  8442.  
  8443. Example:
  8444.  
  8445.   Set the maximum handle count for the current process to thirty, so that
  8446.   the process can have as many as 30 files or devices opened simultaneously.
  8447.   (Five of the handles are already assigned to the standard devices when the
  8448.   process starts up.) Note that a FILES=30 (or greater value) entry in the
  8449.   CONFIG.SYS file would also be required for the process to successfully
  8450.   open 30 files or devices.
  8451.  
  8452.           .
  8453.           .
  8454.           .
  8455.           mov     ah,67h          ; function number
  8456.           mov     bx,30           ; maximum number of handles
  8457.           int     21h             ; transfer to MS-DOS
  8458.           jc      error           ; jump if function failed
  8459.           .
  8460.           .
  8461.           .
  8462.  
  8463.  
  8464. ────────────────────────────────────────────────────────────────────────────
  8465. Int 21H                                                                [3.3]
  8466. Function 68H (104)
  8467. Commit file
  8468. ────────────────────────────────────────────────────────────────────────────
  8469.  
  8470.   Forces all data in MS-DOS's internal buffers associated with a specified
  8471.   handle to be physically written to the device. If the handle refers to a
  8472.   file, and the file has been modified, the time and date stamp and file
  8473.   size in the file's directory entry are updated.
  8474.  
  8475. Call with:
  8476.  
  8477.   AH            = 68H
  8478.   BX            = handle
  8479.  
  8480. Returns:
  8481.  
  8482.   If function successful
  8483.  
  8484.   Carry flag    = clear
  8485.  
  8486.   If function unsuccessful
  8487.  
  8488.   Carry flag    = set
  8489.   AX            = error code
  8490.  
  8491. Notes:
  8492.  
  8493.   ■ The effect of this function is equivalent to closing and reopening a
  8494.     file, or to duplicating a handle for the file with Int 21H Function
  8495.     45H and then closing the duplicate. However, this function has the
  8496.     advantage that it will not fail due to lack of handles, and the
  8497.     application does not risk losing control of the file in multitasking or
  8498.     network environments.
  8499.  
  8500.   ■ If this function is requested for a handle associated with a character
  8501.     device, a success flag is returned, but there is no other effect.
  8502.  
  8503. Example:
  8504.  
  8505.   Assume that the file MYFILE.DAT has been previously opened and that the
  8506.   handle for that file is stored in the variable fhandle. Call the Commit
  8507.   File function to ensure that any data in MS-DOS's internal buffers
  8508.   associated with the handle is written out to disk and that the directory
  8509.   and file allocation table are up to date.
  8510.  
  8511.   fname   db      'MYFILE.DAT',0  ; ASCIIZ filename
  8512.   fhandle dw      ?               ; file handle
  8513.           .
  8514.           .
  8515.           .
  8516.           mov     ah,68h          ; function number
  8517.           mov     bx,fhandle      ; file handle
  8518.           int     21h             ; transfer to MS-DOS
  8519.           jc      error           ; jump if commit failed
  8520.           .
  8521.           .
  8522.           .
  8523.  
  8524.  
  8525. ────────────────────────────────────────────────────────────────────────────
  8526. Int 21H
  8527. Function 69H (105)
  8528. Reserved
  8529. ────────────────────────────────────────────────────────────────────────────
  8530.  
  8531.  
  8532. ────────────────────────────────────────────────────────────────────────────
  8533. Int 21H
  8534. Function 6AH (106)
  8535. Reserved
  8536. ────────────────────────────────────────────────────────────────────────────
  8537.  
  8538.  
  8539. ────────────────────────────────────────────────────────────────────────────
  8540. Int 21H
  8541. Function 6BH (107)
  8542. Reserved
  8543. ────────────────────────────────────────────────────────────────────────────
  8544.  
  8545.  
  8546. ────────────────────────────────────────────────────────────────────────────
  8547. Int 21H                                                                [4.0]
  8548. Function 6CH (108)
  8549. Extended open file
  8550. ────────────────────────────────────────────────────────────────────────────
  8551.  
  8552.   Given an ASCIIZ pathname, opens, creates or replaces a file in the
  8553.   designated or default directory on the designated or default disk drive.
  8554.   Returns a handle that can be used by the program for subsequent access to
  8555.   the file.
  8556.  
  8557. Call with:
  8558.  
  8559.   AH            = 6CH
  8560.   AL            = 00H
  8561.   BX            = open mode
  8562.  
  8563.                   Bit(s)    Significance
  8564.                   0─2       access type
  8565.                             000 = read-only
  8566.                             001 = write-only
  8567.                             010 = read/write
  8568.                   3         reserved (0)
  8569.                   4─6       sharing mode
  8570.                             000 = compatibility
  8571.                             001 = deny read/write (deny all)
  8572.                             010 = deny write
  8573.                             011 = deny read
  8574.                             100 = deny none
  8575.                   7         inheritance
  8576.                             0 = child process inherits handle
  8577.                             1 = child does not inherit handle
  8578.                   8─12      reserved (0)
  8579.                   13        critical error handling
  8580.                             0 = execute Int 24H
  8581.                             1 = return error to process
  8582.                   14        write-through
  8583.                             0 = writes may be buffered and deferred
  8584.                             1 = physical write at request time
  8585.                   15        reserved (0)
  8586.  
  8587.   CX            = file attribute (bits may be combined; ignored if open)
  8588.  
  8589.                   Bit(s)    Significance (if set)
  8590.                   0         read-only
  8591.                   1         hidden
  8592.                   2         system
  8593.                   3         volume label
  8594.                   4         reserved (0)
  8595.                   5         archive
  8596.                   6─15      reserved (0)
  8597.  
  8598.   DX            = open flag
  8599.  
  8600.                   Bits      Significance
  8601.                   0─3       action if file exists
  8602.                             0000 = fail
  8603.                             0001 = open file
  8604.                             0010 = replace file
  8605.                   4─7       action if file doesn't exist
  8606.                             0000 = fail
  8607.                             0001 = create file
  8608.                   8─15      reserved (0)
  8609.  
  8610.   DS:SI         = segment:offset of ASCIIZ pathname
  8611.  
  8612. Returns:
  8613.  
  8614.   If function successful
  8615.  
  8616.   Carry flag    = clear
  8617.   AX            = handle
  8618.   CX            = action taken
  8619.                   1 = file existed and was opened
  8620.                   2 = file did not exist and was created
  8621.                   3 = file existed and was replaced
  8622.  
  8623.   If function failed
  8624.  
  8625.   Carry flag    = set
  8626.   AX            = error code
  8627.  
  8628. Notes:
  8629.  
  8630.   ■ The function fails if:
  8631.  
  8632.     ∙ any element of the pathname does not exist.
  8633.  
  8634.     ∙ the file is being created in the root directory and the root directory
  8635.       is full.
  8636.  
  8637.     ∙ the file is being created and a file with the same name and the
  8638.       read-only attribute already exists in the specified directory.
  8639.  
  8640.     ∙ the program is running on a network and the user running the program
  8641.       has insufficient access rights.
  8642.  
  8643.   ■ A file is usually given a normal (0) attribute when it is created. The
  8644.     file's attribute can subsequently be modified with Int 21H Function
  8645.     43H.
  8646.  
  8647.   ■ This function combines the capabilities of Int 21H Functions 3CH, 3DH,
  8648.     and 5BH. It was added to MS-DOS for compatibility with the DosOpen
  8649.     function of OS/2.
  8650.  
  8651. Example:
  8652.  
  8653.   Create the file MYFILE.DAT, if it does not already exist, in directory
  8654.   \MYDIR on drive C, and save the handle for subsequent access to the file.
  8655.  
  8656.   fname   db      'C:\MYDIR\MYFILE.DAT',0
  8657.  
  8658.   fhandle dw      ?
  8659.           .
  8660.           .
  8661.           .
  8662.           mov     ax,6c00h        ; function number
  8663.           mov     bx,4042h        ; read/write, deny none,
  8664.                                   ; write-through mode
  8665.           xor     cx,cx           ; normal attribute
  8666.           mov     dx,0010h        ; create if doesn't exist,
  8667.                                   ; fail if exists
  8668.           mov     si,seg fname    ; address of pathname
  8669.           mov     ds,si
  8670.           mov     si,offset fname
  8671.           int     21h             ; transfer to MS-DOS
  8672.           jc      error           ; jump if open failed
  8673.           mov     fhandle,ax      ; save file handle
  8674.           .
  8675.           .
  8676.           .
  8677.  
  8678.  
  8679. ────────────────────────────────────────────────────────────────────────────
  8680. Int 22H                                                                [1.0]
  8681. Terminate handler address
  8682. ────────────────────────────────────────────────────────────────────────────
  8683.  
  8684.   The machine interrupt vector for Int 22H (memory locations 0000:0088H
  8685.   through 0000:008BH) contains the address of the routine that receives
  8686.   control when the currently executing program terminates via Int 20H, Int
  8687.   27H, or Int 21H Functions 00H, 31H, or 4CH. The address in this vector
  8688.   is also copied into offsets 0AH through 0DH of the program segment prefix
  8689.   (PSP) when a program is loaded but before it begins executing, and is
  8690.   restored from the PSP (in case it was modified by the application) as part
  8691.   of MS-DOS's termination handling.
  8692.  
  8693.   This interrupt should never be issued directly.
  8694.  
  8695.  
  8696. ────────────────────────────────────────────────────────────────────────────
  8697. Int 23H                                                                [1.0]
  8698. Ctrl-C handler address
  8699. ────────────────────────────────────────────────────────────────────────────
  8700.  
  8701.   The machine interrupt vector for Int 23H (memory locations 0000:008CH
  8702.   though 0000:008FH) contains the address of the routine which receives
  8703.   control when a Ctrl-C is detected during any character I/O function and,
  8704.   if the Break flag is ON, during most other MS-DOS function calls. The
  8705.   address in this vector is also copied into locations 0EH through 11H of
  8706.   the program segment prefix (PSP) when a program is loaded but before it
  8707.   begins executing, and is restored from the PSP (in case it was modified by
  8708.   the application) as part of MS-DOS's termination handling.
  8709.  
  8710.   This interrupt should never be issued directly.
  8711.  
  8712. Notes:
  8713.  
  8714.   ■ The initialization code for an application can use Int 21H Function
  8715.     25H to reset the Interrupt 23H vector to point to its own routine for
  8716.     Ctrl-C handling. In this way, the program can avoid being terminated
  8717.     unexpectedly as the result of the user's entry of a Ctrl-C or
  8718.     Ctrl-Break.
  8719.  
  8720.   ■ When a Ctrl-C is detected and the program's Int 23H handler receives
  8721.     control, all registers are set to their values at the point of the
  8722.     original function call. The handler can then do any of the following:
  8723.  
  8724.     ∙ Set a local flag for later inspection by the application, or take any
  8725.       other appropriate action, and perform an IRET. All registers must be
  8726.       preserved. The MS-DOS function in progress will be restarted from
  8727.       scratch and will proceed to completion, control finally returning to
  8728.       the application in the normal manner.
  8729.  
  8730.     ∙ Take appropriate action and then perform a RET FAR to give control
  8731.       back to MS-DOS. The state of the carry flag is used by MS-DOS to
  8732.       determine what action to take. If the carry flag is set, the
  8733.       application will be terminated; if the carry flag is clear, the
  8734.       application will continue in the normal manner.
  8735.  
  8736.     ∙ Retain control by transferring to an error-handling routine within the
  8737.       application and then resume execution or take other appropriate
  8738.       action, never performing a RET FAR or IRET to end the
  8739.       interrupt-handling sequence. This option will cause no harm to the
  8740.       system.
  8741.  
  8742.   ■ Any MS-DOS function call may be used within the body of an Int 23H
  8743.     handler.
  8744.  
  8745. Example:
  8746.  
  8747.   See Chapter 5.
  8748.  
  8749.  
  8750. ────────────────────────────────────────────────────────────────────────────
  8751. Int 24H                                                                [1.0]
  8752. Critical-error handler address
  8753. ────────────────────────────────────────────────────────────────────────────
  8754.  
  8755.   The machine interrupt vector for Int 24H (memory locations 0000:0090H
  8756.   through 0000:0093H) contains the address of the routine that receives
  8757.   control when a critical error (usually a hardware error) is detected. This
  8758.   address is also copied into locations 12H through 15H of the program
  8759.   segment prefix (PSP) when a program is loaded but before it begins
  8760.   executing, and is restored from the PSP (in case it was modified by the
  8761.   application) as part of MS-DOS's termination handling.
  8762.  
  8763.   This interrupt should never be issued directly.
  8764.  
  8765. Notes:
  8766.  
  8767.   ■ On entry to the critical-error interrupt handler, bit 7 of register AH
  8768.     is clear (0) if the error was a disk I/O error; otherwise, it is set
  8769.     (1). BP:SI contains the address of a device-driver header from which
  8770.     additional information can be obtained. Interrupts are disabled. The
  8771.     registers will be set up for a retry operation, and an error code will
  8772.     be in the lower half of the DI register, with the upper half undefined.
  8773.  
  8774.     The lower byte of DI contains:
  8775.  
  8776.     00H            write-protect error
  8777.     01H            unknown unit
  8778.     02H            drive not ready
  8779.     03H            unknown command
  8780.     04H            data error (CRC)
  8781.     05H            bad request structure length
  8782.     06H            seek error
  8783.     07H            unknown media type
  8784.     08H            sector not found
  8785.     09H            printer out of paper
  8786.     0AH            write fault
  8787.     0BH            read fault
  8788.     0CH            general failure
  8789.     0DH            reserved
  8790.     0EH            reserved
  8791.     0FH            invalid disk change (MS-DOS version 3 only)
  8792.  
  8793.     Note that these are the same error codes returned by the device driver
  8794.     in the request header. Also, upon entry, the stack is set up as shown in
  8795.     Figure 8-8, page 149.
  8796.  
  8797.   ■ When a disk I/O error occurs, MS-DOS automatically retries the operation
  8798.     before issuing a critical-error Int 24H. The number of retries varies
  8799.     in different versions of MS-DOS, but is typically in the range three to
  8800.     five.
  8801.  
  8802.   ■ Int 24H handlers must preserve the SS, SP, DS, ES, BX, CX, and DX
  8803.     registers. Only Int 21H Functions 01H─0CH and 59H can be used by an
  8804.     Int 24H handler; other function calls will destroy the MS-DOS stack and
  8805.     its ability to retry or ignore an error.
  8806.  
  8807.   ■ When the Int 24H handler issues an IRET, it should return an action code
  8808.     in AL that will be interpreted by DOS as follows:
  8809.  
  8810.     0              ignore the error
  8811.     1              retry the operation
  8812.     2              terminate the program
  8813.     3              [3.0+] fail the function call in progress
  8814.  
  8815.   ■ If the Int 24H handler returns control directly to the application
  8816.     program rather than to MS-DOS, it must restore the program's registers,
  8817.     removing all but the last three words from the stack, and issue an IRET.
  8818.     Control returns to the instruction immediately following the function
  8819.     call that caused the error. This option leaves MS-DOS in an unstable
  8820.     state until a call to an Int 21H function higher than Function 0CH is
  8821.     made.
  8822.  
  8823. Example:
  8824.  
  8825.   See Chapter 8.
  8826.  
  8827.  
  8828. ────────────────────────────────────────────────────────────────────────────
  8829. Int 25H                                                                [1.0]
  8830. Absolute disk read
  8831. ────────────────────────────────────────────────────────────────────────────
  8832.  
  8833.   Provides a direct linkage to the MS-DOS BIOS module to read data from a
  8834.   logical disk sector into memory.
  8835.  
  8836. Call with:
  8837.  
  8838.   For access to partitions <= 32 MB
  8839.  
  8840.   AL            = drive number (0 = A, 1 = B, etc)
  8841.   CX            = number of sectors to read
  8842.   DX            = starting sector number
  8843.   DS:BX         = segment:offset of buffer
  8844.  
  8845.   For access to partitions > 32 MB (MS-DOS 4.0 and later)
  8846.  
  8847.   AL            = drive number (0 = A, 1 = B, etc)
  8848.   CX            = -1
  8849.   DS:BX         = segment:offset of parameter block (see Notes)
  8850.  
  8851. Returns:
  8852.  
  8853.   If function successful
  8854.  
  8855.   Carry flag    = clear
  8856.  
  8857.   If function unsuccessful
  8858.  
  8859.   Carry flag    = set
  8860.   AX            = error code (see Notes)
  8861.  
  8862. Notes:
  8863.  
  8864.   ■ All registers except the segment registers may be destroyed.
  8865.  
  8866.   ■ When this function returns, the CPU flags originally pushed on the stack
  8867.     by the INT 25H instruction are still on the stack. The stack must be
  8868.     cleared by a POPF or ADD SP,2 to prevent uncontrolled stack growth and
  8869.     to make accessible any other values that were pushed on the stack before
  8870.    tthe call to INT 25H.
  8871.  
  8872.   ■ Logical sector numbers are obtained by numbering each disk sector
  8873.     sequentially from cylinder 0, head 0, sector 1, and continuing until the
  8874.     last sector on the disk is counted. The head number is incremented
  8875.     before the track number. Logically adjacent sectors may not be
  8876.     physically adjacent, due to interleaving that occurs at the
  8877.     device-adapter level for some disk types.
  8878.  
  8879.   ■ The error code is interpreted as follows: The lower byte (AL) is the
  8880.     same error code that is returned in the lower byte of DI when an Int 24H
  8881.     is issued. The upper byte (AH) contains:
  8882.  
  8883.     01H            if bad command
  8884.     02H            if bad address mark
  8885.     04H            if requested sector not found
  8886.     08H            if direct memory access (DMA) failure
  8887.     10H            if data error (bad CRC)
  8888.     20H            if controller failed
  8889.     40H            if seek operation failed
  8890.     80H            if attachment failed to respond
  8891.  
  8892.   ■ [4.0+] When accessing partitions larger than 32 MB under MS-DOS version
  8893.     4, this function uses a parameter block with the following format:
  8894.  
  8895.     Bytes          Description
  8896.     00H─03H        32-bit sector number
  8897.     04H─05H        number of sectors to read
  8898.     06H─07H        offset of buffer
  8899.     08H─09H        segment of buffer
  8900.  
  8901. Example:
  8902.  
  8903.   Read logical sector 1 of drive A into the memory area named buff. (On most
  8904.   MS-DOS floppy disks, this sector contains the beginning of the file
  8905.   allocation table.)
  8906.  
  8907.   buff    db      512 dup (?)     ; receives data from disk
  8908.           .
  8909.           .
  8910.           .
  8911.           mov     al,0            ; drive A
  8912.           mov     cx,1            ; number of sectors
  8913.           mov     dx,1            ; beginning sector number
  8914.           mov     bx,seg buff     ; buffer address
  8915.           mov     ds,bx
  8916.           mov     bx,offset buff
  8917.           int     25h             ; request disk read
  8918.           jc      error           ; jump if read failed
  8919.           add     sp,2            ; clear stack
  8920.           .
  8921.           .
  8922.           .
  8923.  
  8924.  
  8925. ────────────────────────────────────────────────────────────────────────────
  8926. Int 26H                                                                [1.0]
  8927. Absolute disk write
  8928. ────────────────────────────────────────────────────────────────────────────
  8929.  
  8930.   Provides a direct linkage to the MS-DOS BIOS module to write data from
  8931.   memory to a logical disk sector.
  8932.  
  8933. Call with:
  8934.  
  8935.   For access to partitions <= 32 MB
  8936.  
  8937.   AL            = drive number (0 = A, 1 = B, etc)
  8938.   CX            = number of sectors to write
  8939.   DX            = starting sector number
  8940.   DS:BX         = segment:offset of buffer
  8941.  
  8942.   For access to partitions > 32 MB (MS-DOS 4.0 and later)
  8943.  
  8944.   AL            = drive number (0 = A, 1 = B, etc)
  8945.   CX            = -1
  8946.   DS:BX         = segment:offset of parameter block (see Notes)
  8947.  
  8948. Returns:
  8949.  
  8950.   If function successful
  8951.  
  8952.   Carry flag    = clear
  8953.  
  8954.   If function unsuccessful
  8955.  
  8956.   Carry flag    = set
  8957.   AX            = error code (see Notes)
  8958.  
  8959. Notes:
  8960.  
  8961.   ■ All registers except the segment registers may be destroyed.
  8962.  
  8963.   ■ When this function returns, the CPU flags originally pushed onto the
  8964.     stack by the INT 26H instruction are still on the stack. The stack must
  8965.     be cleared by a POPF or ADD SP,2 to prevent uncontrolled stack growth
  8966.     and to make accessible any other values that were pushed on the stack
  8967.     before the call to INT 26H.
  8968.  
  8969.   ■ Logical sector numbers are obtained by numbering each disk sector
  8970.     sequentially from cylinder 0, head 0, sector 1, and continuing until the
  8971.     last sector on the disk is counted. The head number is incremented
  8972.     before the track number. Logically adjacent sectors may not be
  8973.     physically adjacent, due to interleaving that occurs at the
  8974.     device-adapter level for some disk types.
  8975.  
  8976.   ■ The error code is interpreted as follows: The lower byte (AL) is the
  8977.     same error code that is returned in the lower byte of DI when an Int
  8978.     24H is issued. The upper byte (AH) contains:
  8979.  
  8980.     01H            if bad command
  8981.     02H            if bad address mark
  8982.     03H            if write-protect fault
  8983.     04H            if requested sector not found
  8984.     08H            if direct memory access (DMA) failure
  8985.     10H            if data error (bad CRC)
  8986.     20H            if controller failed
  8987.     40H            if seek operation failed
  8988.     80H            if attachment failed to respond
  8989.  
  8990.   ■ [4.0+] When accessing partitions larger than 32 MB under MS-DOS version
  8991.     4, this function uses a parameter block with the following format:
  8992.  
  8993.     Bytes          Description
  8994.     00H─03H        32-bit sector number
  8995.     04H─05H        number of sectors to read
  8996.     06H─07H        offset of buffer
  8997.     08H─09H        segment of buffer
  8998.  
  8999. Example:
  9000.  
  9001.   Write the contents of the memory area named buff into logical sector 3 of
  9002.   drive C.
  9003.  
  9004.   Warning: Verbatim use of the following code could damage the file system
  9005.   on your fixed disk. There is, unfortunately, no way to provide a really
  9006.   safe example of this function.
  9007.  
  9008.   buff    db      512 dup (?)     ; contains data for write
  9009.           .
  9010.           .
  9011.           .
  9012.           mov     al,2            ; drive C
  9013.           mov     cx,1            ; number of sectors
  9014.           mov     dx,3            ; beginning sector number
  9015.           mov     bx,seg buff     ; buffer address
  9016.           mov     ds,bx
  9017.           mov     bx,offset buff
  9018.           int     26h             ; request disk write
  9019.           jc      error           ; jump if write failed
  9020.           add     sp,2            ; clear stack
  9021.           .
  9022.           .
  9023.           .
  9024.  
  9025.  
  9026. ────────────────────────────────────────────────────────────────────────────
  9027. Int 27H                                                                [1.0]
  9028. Terminate and stay resident
  9029. ────────────────────────────────────────────────────────────────────────────
  9030.  
  9031.   Terminates execution of the currently executing program, but reserves part
  9032.   or all of its memory so that it will not be overlaid by the next transient
  9033.   program to be loaded. MS-DOS then takes the following actions:
  9034.  
  9035.   ■ File buffers are flushed and any open handles for files or devices owned
  9036.     by the process are closed.
  9037.  
  9038.   ■ The termination handler vector (Int 22H) is restored from PSP:000AH.
  9039.  
  9040.   ■ The Ctrl-C handler vector (Int 23H) is restored from PSP:000EH.
  9041.  
  9042.   ■ [2.0+] The critical-error handler vector (Int 24H) is restored from
  9043.     PSP:0012H.
  9044.  
  9045.   ■ Control is transferred to the termination handler.
  9046.  
  9047.   If the program is returning to COMMAND.COM, control transfers to the
  9048.   resident portion and the transient portion is reloaded if necessary. If a
  9049.   batch file is in progress, the next line of the file is fetched and
  9050.   interpreted; otherwise a prompt is issued for the next user command.
  9051.  
  9052. Call with:
  9053.  
  9054.   DX            = offset of the last byte plus one (relative to the program
  9055.                   segment prefix)
  9056.                   of program to be protected
  9057.   CS            = segment of program segment prefix
  9058.  
  9059. Returns:
  9060.  
  9061.   Nothing
  9062.  
  9063. Notes:
  9064.  
  9065.   ■ This function call is typically used to allow user-written utilities,
  9066.     drivers, or interrupt handlers to be loaded as ordinary .COM or .EXE
  9067.     programs, then remain resident. Subsequent entrance to the code is via a
  9068.     hardware or software interrupt.
  9069.  
  9070.   ■ This function attempts to set the initial memory allocation block to the
  9071.     length in bytes specified in register DX. If other memory blocks have
  9072.     been requested by the application via Int 21H Function 48H, they will
  9073.     not be released by this function.
  9074.  
  9075.   ■ Other methods of performing a final exit are:
  9076.  
  9077.     ∙ Int 20H
  9078.  
  9079.     ∙ Int 21H Function 00H
  9080.  
  9081.     ∙ Int 21H Function 31H
  9082.  
  9083.     ∙ Int 21H Function 4CH
  9084.  
  9085.   ■ This function should not be called by .EXE programs that are loaded at
  9086.     the high end of the transient program area (i.e., linked with the /HIGH
  9087.     switch), because doing so reserves the memory normally used by the
  9088.     transient part of COMMAND.COM. If COMMAND.COM cannot be reloaded, the
  9089.     system will fail.
  9090.  
  9091.   ■ This function does not work correctly when DX contains values in the
  9092.     range 0FFF1H─0FFFFH. In this case, MS-DOS discards the high bit of the
  9093.     value in DX, resulting in the reservation of 32 KB less memory than was
  9094.     requested by the program.
  9095.  
  9096.   ■ [2.0+] Int 21H Function 31H should be used in preference to this
  9097.     function, because it supports return codes, allows larger amounts of
  9098.     memory to be reserved, and does not require CS to contain the segment of
  9099.     the program segment prefix.
  9100.  
  9101.   ■ [3.0+] If the program is running on a network, it should remove all
  9102.     locks it has placed on file regions before terminating.
  9103.  
  9104. Example:
  9105.  
  9106.   Terminate and stay resident, reserving enough memory to contain the entire
  9107.   program.
  9108.  
  9109.           .
  9110.           .
  9111.           .
  9112.           mov     dx,offset pend  ; DX = bytes to reserve
  9113.           int     27h             ; terminate, stay resident
  9114.           .
  9115.           .
  9116.           .
  9117.   pend    equ     $               ; offset, end of program
  9118.  
  9119.           end
  9120.  
  9121.  
  9122. ────────────────────────────────────────────────────────────────────────────
  9123. Int 28H
  9124. Reserved
  9125. ────────────────────────────────────────────────────────────────────────────
  9126.  
  9127.  
  9128. ────────────────────────────────────────────────────────────────────────────
  9129. Int 29H
  9130. Reserved
  9131. ────────────────────────────────────────────────────────────────────────────
  9132.  
  9133.  
  9134. ────────────────────────────────────────────────────────────────────────────
  9135. Int 2AH
  9136. Reserved
  9137. ────────────────────────────────────────────────────────────────────────────
  9138.  
  9139.  
  9140. ────────────────────────────────────────────────────────────────────────────
  9141. Int 2BH
  9142. Reserved
  9143. ────────────────────────────────────────────────────────────────────────────
  9144.  
  9145.  
  9146. ────────────────────────────────────────────────────────────────────────────
  9147. Int 2CH
  9148. Reserved
  9149. ────────────────────────────────────────────────────────────────────────────
  9150.  
  9151.  
  9152. ────────────────────────────────────────────────────────────────────────────
  9153. Int 2DH
  9154. Reserved
  9155. ────────────────────────────────────────────────────────────────────────────
  9156.  
  9157.  
  9158. ────────────────────────────────────────────────────────────────────────────
  9159. Int 2EH
  9160. Reserved
  9161. ────────────────────────────────────────────────────────────────────────────
  9162.  
  9163.  
  9164. ────────────────────────────────────────────────────────────────────────────
  9165. Int 2FH                                                                [3.0]
  9166. Multiplex interrupt
  9167. ────────────────────────────────────────────────────────────────────────────
  9168.  
  9169.   Provides a general-purpose avenue of communication with another process or
  9170.   with MS-DOS extensions, such as the print spooler, ASSIGN, SHARE, and
  9171.   APPEND. The multiplex number in register AH specifies the process or
  9172.   extension being communicated with. The range 00H─BFH is reserved for
  9173.   MS-DOS; applications may use the range C0H─FFH.
  9174.  
  9175.  
  9176. ────────────────────────────────────────────────────────────────────────────
  9177. Int 2FH                                                                [3.0]
  9178. Function 01H
  9179. Print spooler
  9180. ────────────────────────────────────────────────────────────────────────────
  9181.  
  9182.   Submits a file to the print spooler, removes a file from the print
  9183.   spooler's queue of pending files, or obtains the status of the printer.
  9184.   The print spooler, which is contained in the file PRINT.COM, was first
  9185.   added to MS-DOS in version 2.0, but the application program interface to
  9186.   the spooler was not documented until MS-DOS version 3.
  9187.  
  9188. Call with:
  9189.  
  9190.   AH            = 01H
  9191.   AL            = subfunction
  9192.                   00H = Get Installed State
  9193.                   01H = Submit File to be Printed
  9194.                   02H = Remove File from Print Queue
  9195.                   03H = Cancel All Files in Queue
  9196.                   04H = Hold Print Jobs for Status Read
  9197.                   05H = Release Hold
  9198.   DS:DX         = segment:offset of packet (Subfunction 01H)
  9199.                   segment:offset of ASCIIZ pathname (Subfunction 02H)
  9200.  
  9201. Returns:
  9202.  
  9203.   If function successful
  9204.  
  9205.   Carry flag    = clear
  9206.  
  9207.   and, if called with AL = 00H
  9208.  
  9209.   AL            = print spooler state
  9210.  
  9211.                   00H       if not installed, ok to install
  9212.                   01H       if not installed, not ok to install
  9213.                   FFH       if installed
  9214.  
  9215.   or, if called with AL = 04H
  9216.  
  9217.   DX            = error count
  9218.   DS:SI         = segment:offset of print queue file list
  9219.  
  9220.   If function unsuccessful
  9221.  
  9222.   Carry flag    = set
  9223.   AX            = error code
  9224.  
  9225. Notes:
  9226.  
  9227.   ■ The packet passed to Subfunction 01H consists of five bytes. The first
  9228.     byte contains the level, which should be 00H for current versions of
  9229.     MS-DOS. The following four bytes contain the segment:offset of an ASCIIZ
  9230.     pathname, which may not include wildcard characters. If the specified
  9231.     file exists, it is added to the print queue.
  9232.  
  9233.   ■ The * and ? wildcard characters may be included in a pathname passed to
  9234.     Subfunction 02H, making it possible to delete multiple files from the
  9235.     print queue with one call.
  9236.  
  9237.   ■ The address returned by Subfunction 04H points to a list of 64-byte
  9238.     entries, each containing an ASCIIZ pathname. The first pathname in the
  9239.     list is the file currently being printed. The last entry in the list is
  9240.     a null string (a single 00H byte).
  9241.  
  9242.  
  9243. ────────────────────────────────────────────────────────────────────────────
  9244. Int 2FH                                                                [3.2]
  9245. Function 02H
  9246. ASSIGN
  9247. ────────────────────────────────────────────────────────────────────────────
  9248.  
  9249.   Returns a code indicating whether the resident portion of the ASSIGN
  9250.   utility has been loaded.
  9251.  
  9252. Call with:
  9253.  
  9254.   AH            = 02H
  9255.   AL            = subfunction
  9256.                   00H = Get Installed State
  9257.  
  9258. Returns:
  9259.  
  9260.   If function successful
  9261.  
  9262.   Carry flag    = clear
  9263.   AL            = ASSIGN installed status
  9264.  
  9265.                   00H       if not installed, ok to install
  9266.                   01H       if not installed, not ok to install
  9267.                   FFH       if installed
  9268.  
  9269.   If function unsuccessful
  9270.  
  9271.   Carry flag    = set
  9272.   AX            = error code
  9273.  
  9274.  
  9275. ────────────────────────────────────────────────────────────────────────────
  9276. Int 2FH                                                                [3.2]
  9277. Function 10H (16)
  9278. SHARE
  9279. ────────────────────────────────────────────────────────────────────────────
  9280.  
  9281.   Returns a code indicating whether the SHARE.EXE file-sharing module has
  9282.   been loaded.
  9283.  
  9284. Call with:
  9285.  
  9286.   AH            = 10H
  9287.   AL            = subfunction
  9288.                   00H = Get Installed State
  9289.  
  9290. Returns:
  9291.  
  9292.   If function successful
  9293.  
  9294.   Carry flag    = clear
  9295.   AL            = SHARE installed status
  9296.  
  9297.                   00H       if not installed, ok to install
  9298.                   01H       if not installed, not ok to install
  9299.                   FFH       if installed
  9300.  
  9301.   If function unsuccessful
  9302.  
  9303.   Carry flag    = set
  9304.   AX            = error code
  9305.  
  9306.  
  9307. ────────────────────────────────────────────────────────────────────────────
  9308. Int 2FH                                                                [3.3]
  9309. Function B7H (183)
  9310. APPEND
  9311. ────────────────────────────────────────────────────────────────────────────
  9312.  
  9313.   Allows an application to test whether APPEND has been installed. If APPEND
  9314.   is resident, returns the APPEND version, state, and the path used to
  9315.   search for data files.
  9316.  
  9317. Call with:
  9318.  
  9319.   AH            = B7H
  9320.   AL            = subfunction
  9321.                   00H = Get Installed State
  9322.                   02H = Get Append Version (4.0)
  9323.                   04H = Get Append Path Pointer (4.0)
  9324.                   06H = Get Append Function State (4.0)
  9325.                   07H = Set Append Function State (4.0)
  9326.                   11H = Set Return Found Name State (4.0, see Note)
  9327.   BX            = APPEND state (if AL = 07H)
  9328.  
  9329.                   Bit(s)    Significance (if set)
  9330.                   0         APPEND enabled
  9331.                   1─12      Reserved (0)
  9332.                   13        /PATH switch active
  9333.                   14        /E switch active
  9334.                   15        /X switch active
  9335.  
  9336. Returns:
  9337.  
  9338.   If function successful
  9339.  
  9340.   Carry flag    = clear
  9341.  
  9342.   and, if called with AL = 00H
  9343.  
  9344.   AL            = APPEND installed status
  9345.  
  9346.                   00H       if not installed, ok to install
  9347.                   01H       if not installed, not ok to install
  9348.                   FFH       if installed
  9349.  
  9350.   or, if called with AL = 02H (MS-DOS 4.0)
  9351.  
  9352.   AX            = FFFFH if MS-DOS 4.0 APPEND
  9353.  
  9354.   or, if called with AL = 04H (MS-DOS 4.0)
  9355.  
  9356.   ES:DI         = segment:offset of active APPEND path
  9357.  
  9358.   or, if called with AL = 06H (MS-DOS 4.0)
  9359.  
  9360.   BX            = APPEND state (see above)
  9361.  
  9362.   If function unsuccessful
  9363.  
  9364.   Carry flag    = set
  9365.   AX            = error code
  9366.  
  9367. Note:
  9368.  
  9369.   ■ If the Return Found Name State is set with Subfunction 11H, the fully
  9370.     qualified filename is returned to the next application to call Int 21H
  9371.     Function 3DH, 43H, or 6CH. The name is placed at the same address as the
  9372.     ASCIIZ parameter string for the Int 21H function, so the application
  9373.     must be sure to provide a buffer of adequate size. The Return Found Name
  9374.     State is reset after APPEND processes one Int 21H function call.
  9375.  
  9376.  
  9377.  
  9378.