home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / misc2 / dosref20.lzh / CHAPTER.004 < prev    next >
Text File  |  1991-06-17  |  115KB  |  2,206 lines

  1.  
  2.    **  Programmer's  Technical  Reference  for  MSDOS  and  the  IBM  PC **
  3.                         ┌─────────────────────────────┐
  4.                         │ Shareware Version, 06/17/91 │
  5.                         │  Please Register Your Copy  │
  6.                         └─────────────────────────────┘
  7.                     Copyright (c) 1987, 1991 Dave Williams
  8.                  USA copyright TXG 392-616 ALL RIGHTS RESERVED
  9.                      ISBN 1-878830-02-3 (disk-based text)
  10.  
  11.  
  12.                            C H A P T E R    F O U R
  13.  
  14.                        DOS INTERRUPTS AND FUNCTION CALLS
  15.  
  16.        note: The registered version of this chapter is twice this size.
  17.  
  18.  
  19.  
  20. DOS REGISTERS├─────────────────────────────────────────────────────────────────
  21.  
  22.  DOS uses the following registers, pointers, and flags when it executes 
  23. interrupts and function calls:
  24. ┌───────────────────┬──────────┬───────────────────────────────────────────────┐
  25. │GENERAL REGISTERS  │ register │                  definition                   │
  26. │                   ├──────────┼───────────────────────────────────────────────┤
  27. │                   │    AX    │  accumulator (16 bit)                         │
  28. │                   │    AH    │  accumulator high-order byte (8 bit)          │
  29. │                   │    AL    │  accumulator low order byte (8 bit)           │
  30. │                   │    BX    │  base (16 bit)                                │
  31. │                   │    BH    │  base high-order byte (8 bit)                 │
  32. │                   │    BL    │  base low-order byte (8 bit)                  │
  33. │                   │    CX    │  count (16 bit)                               │
  34. │                   │    CH    │  count high order byte (8 bit)                │
  35. │                   │    CL    │  count low order byte (8 bit)                 │
  36. │                   │    DX    │  data (16 bit)                                │
  37. │                   │    DH    │  date high order byte (8 bit)                 │
  38. │                   │    DL    │  data low order byte (8 bit)                  │
  39. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  40. │SEGMENT REGISTERS  │ register │                  definition                   │
  41. │                   ├──────────┼───────────────────────────────────────────────┤
  42. │                   │    CS    │  code  segment (16 bit)                       │
  43. │                   │    DS    │  data  segment (16 bit)                       │
  44. │                   │    SS    │  stack segment (16 bit)                       │
  45. │                   │    ES    │  extra segment (16 bit)                       │
  46. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  47. │INDEX REGISTERS    │ register │                  definition                   │
  48. │                   ├──────────┼───────────────────────────────────────────────┤
  49. │                   │    DI    │  destination index (16 bit)                   │
  50. │                   │    SI    │  stack       index (16 bit)                   │
  51. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  52. │SEGMENT REGISTERS  │ register │                  definition                   │
  53. │                   ├──────────┼───────────────────────────────────────────────┤
  54. │                   │    CS    │  code  segment (16 bit)                       │
  55. │                   │    DS    │  data  segment (16 bit)                       │
  56. │                   │    SS    │  stack segment (16 bit)                       │
  57. │                   │    ES    │  extra segment (16 bit)                       │
  58. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  59. │INDEX REGISTERS    │ register │                  definition                   │
  60. │                   ├──────────┼───────────────────────────────────────────────┤
  61. │                   │    DI    │  destination index (16 bit)                   │
  62. │                   │    SI    │  stack       index (16 bit)                   │
  63. ├───────────────────┼──────────┼───────────────────────────────────────────────┤
  64. │POINTERS           │ register │                  definition                   │
  65. │                   ├──────────┼───────────────────────────────────────────────┤
  66. │                   │    SP    │  stack pointer (16 bit)                       │
  67. │                   │    BP    │  base pointer (16 bit)                        │
  68. │                   │    IP    │  instruction pointer (16 bit)                 │
  69. ├───────────────────┴──────────┴───────────────────────────────────────────────┤
  70. │FLAGS                   AF, CF, DF, IF, OF, PF, SF, TF, ZF                    │
  71. └──────────────────────────────────────────────────────────────────────────────┘
  72.  
  73.  These registers, pointers, and flags are "lowest common denominator" 8088-8086 
  74. CPU oriented. DOS makes no attempt to use any of the special or enhanced 
  75. instructions availible on the later CPUs which will execute 8088 code, such as 
  76. the 80186, 80286, 80386, or NEV V20, V30, V40, or V50.
  77.  
  78.  When DOS takes control after a function call, it switches to an internal 
  79. stack. Registers which are not used to return information (other than AX) are 
  80. preserved. The calling program's stack must be large enough to accomodate the 
  81. interrupt system - at least 128 bytes in addition to other interrupts. 
  82.  DOS actually maintains three stacks -
  83. stack 1: 384 bytes (in DOS 3.1)
  84.          for functions 00h and for 0Dh and up, and for ints 25h and 26h.
  85.  
  86. stack 2: 384 bytes (in DOS 3.1)
  87.          for function calls 01h through 0Ch.
  88.  
  89. stack 3: 48 bytes (in DOS 3.1)
  90.          for functions 0Dh and above. This stack is the initial stack used by
  91.          the int 21h handler before it decides which of the other two to use.
  92.          It is also used by function 59h (get extended error), and 01h to 0Ch if
  93.          they are called during an int 24h (critical error) handler. Functions
  94.          33h (get/set break flag), 50h (set process ID), 51h (get process ID)
  95.          and 62h (get PSP address) do not use any DOS stack under DOS 3.x
  96.          (under 2.x, 50h and 51h use stack number 2). 
  97.  
  98.  IBM and Microsoft made a change back in DOS 3.0 or 3.1 to reduce the size of
  99. DOS. They reduced the space allocated for scratch areas when interrupts are
  100. being processed. The default seems to vary with the DOS version and the
  101. machine, but 8 stack frames seems to ring a bell. That means that if you get
  102. more than 8 interrupts at the same time, clock, disk, printer spooler,
  103. keyboard, com port, etc., the system will crash. It seems to happen usually on
  104. a network. STACKS=16,256 means allow 16 interrupts to interrupt each other and
  105. allow 256 bytes for each for scratch area. Eight is marginal.
  106.  
  107.  DOS 3.2 does some different stack switching than previous versions. The
  108. interrupts which are switched are 02h, 08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 70h,
  109. 72h, 73h, 74h, 75h, 76h, and 77h. DOS 3.2 has a special check in the
  110. initialization code for a PCjr and don't enable stack switching on that machine.
  111.  
  112.  
  113.  
  114. INTERRUPTS├────────────────────────────────────────────────────────────────────
  115.  
  116.  Microsoft recommends that a program wishing to examine or set the contents of
  117. any interrupt vector use the DOS function calls 35h and 25h provided for those 
  118. purposes and avoid referencing the interrupt vector locations directly.
  119.  DOS reserves interrupt numbers 20h to 3Fh for its own use. This means absolute 
  120. memory locations 80h to 0FFh are reserved by DOS. The defined interrupts are as 
  121. follows with all values in hexadecimal.
  122.  
  123.  
  124. ┌─────────────────────────────────────────────────────────────────────────────┐
  125. │Interrupt 21h  Function Call Request                                         │
  126. └─────────────────────────────────────────────────────────────────────────────┘
  127. (0:0084h)
  128.  DOS provides a wide variety of function calls for character device I/O, file 
  129. management, memory management, date and time functions,execution of other 
  130. programs, and more. They are grouped as follows:
  131.  
  132.           call              description
  133.         00h             program terminate
  134.         01h-0Ch         character device I/O, CP/M compatibility format
  135.         0Dh-24h         file management,      CP/M compatibility format
  136.         25h-26h         nondevice functions,  CP/M compatibility format
  137.         27h-29h         file management,      CP/M compatibility format
  138.         2Ah-2Eh         nondevice functions,  CP/M compatibility format
  139.         2Fh-38h         extended functions
  140.         39h-3Bh         directory group
  141.         3Ch-46h         extended file management
  142.         47h             directory group
  143.         48h-4Bh         extended memory management
  144.         54h-57h         extended functions
  145.         5Eh-5Fh         networking
  146.         60h-62h         extended functions
  147.         63h-66h         enhanced foreign language support
  148.  
  149.  
  150. List of DOS services:   * = undocumented
  151.         00h     terminate program
  152.         01h     get keyboard input 
  153.         02h     display character to STDIO
  154.         03h     get character from STDAUX
  155.         04h     output character to STDAUX
  156.         05h     output character to STDPRN
  157.         06h     direct console I/O - keyboard to screen
  158.         07h     get char from std I/O without echo
  159.         08h     get char from std I/O without echo, checks for ^C
  160.         09h     display a string to STDOUT
  161.         0Ah     buffered keyboard input
  162.         0Bh     check STDIN status
  163.         0Ch     clear keyboard buffer and invoke keyboard function
  164.         0Dh     flush all disk buffers
  165.         0Eh     select disk
  166.         0Fh     open file with File Control Block
  167.         10h     close file opened with File Control Block
  168.         11h     search for first matching file entry
  169.         12h     search for next matching file entry
  170.         13h     delete file specified by File Control Block
  171.         14h     sequential read from file specified by File Control Block
  172.         15h     sequential write to file specified by File Control Block
  173.         16h     find or create firectory entry for file
  174.         17h     rename file specified by file control block
  175.         18h*    unknown
  176.         19h     return current disk drive
  177.         1Ah     set disk transfer area (DTA)
  178.         1Bh     get current disk drive FAT
  179.         1Ch     get disk FAT for any drive
  180.         1Dh*    unknown
  181.         1Eh*    unknown
  182.         1Fh*    read DOS disk block, default drive
  183.         20h*    unknown
  184.         21h     random read from file specified by FCB
  185.         22h     random write to file specified by FCB
  186.         23h     return number of records in file specified by FCB
  187.         24h     set relative file record size field for file specified by FCB
  188.         25h     set interrupt vector
  189.         26h     create new Program Segment Prefix (PSP)
  190.         27h     random file block read from file specified by FCB
  191.         28h     random file block write to file specified by FCB
  192.         29h     parse the command line for file name
  193.         2Ah     get the system date
  194.         2Bh     set the system date
  195.         2Ch     get the system time
  196.         2Dh     set the system time
  197.         2Eh     set/clear disk write VERIFY
  198.         2Fh     get the Disk Transfer Address (DTA)
  199.         30h     get DOS version number
  200.         31h     TSR, files opened remain open
  201.         32h*    read DOS Disk Block
  202.         33h     get or set Ctrl-Break
  203.         34h*    INDOS  Critical Section Flag
  204.         35h     get segment and offset address for an interrupt
  205.         36h     get free disk space
  206.         37h*    get/set option marking character (SWITCHAR)
  207.         38h     return country-dependent information
  208.         39h     create subdirectory
  209.         3Ah     remove subdirectory
  210.         3Bh     change current directory
  211.         3Ch     create and return file handle
  212.         3Dh     open file and return file handle
  213.         3Eh     close file referenced by file handle
  214.         3Fh     read from file referenced by file handle
  215.         40h     write to file referenced by file handle
  216.         41h     delete file
  217.         42h     move file pointer (move read-write pointer for file)
  218.         43h     set/return file attributes
  219.         44h     device IOCTL (I/O control) info
  220.         45h     duplicate file handle
  221.         46h     force a duplicate file handle
  222.         47h     get current directory
  223.         48h     allocate memory
  224.         49h     release allocated memory
  225.         4Ah     modify allocated memory
  226.         4Bh     load or execute a program
  227.         4Ch     terminate prog and return to DOS
  228.         4Dh     get return code of subprocess created by 4Bh
  229.         4Eh     find first matching file
  230.         4Fh     find next matching file
  231.         50h*    set new current Program Segment Prefix (PSP)
  232.         51h*    puts current PSP into BX
  233.         52h*    pointer to the DOS list of lists
  234.         53h*    translates BPB (Bios Parameter Block, see below)
  235.         54h     get disk verification status (VERIFY)
  236.         55h*    create PSP: similar to function 26h
  237.         56h     rename a file
  238.         57h     get/set file date and time
  239.         58h     get/set allocation strategy             (DOS 3.x)
  240.         59h     get extended error information
  241.         5Ah     create a unique filename
  242.         5Bh     create a DOS file
  243.         5Ch     lock/unlock file contents
  244.         5Dh*    network
  245.         5Eh*    network printer
  246.         5Fh*    network redirection   
  247.         60h*    parse pathname
  248.         61h*    unknown
  249.         62h     get program segment prefix (PSP)
  250.         63h*    get lead byte table                     (DOS 2.25)
  251.         64h*    unknown
  252.         65h     get extended country information        (DOS 3.3)
  253.         66h     get/set global code page table          (DOS 3.3)
  254.         67h     set handle count                        (DOS 3.3)
  255.         68h     commit file                             (DOS 3.3)
  256.         69h     disk serial number                      (DOS 4.0)
  257.         6Ah     unknown
  258.         6Bh     unknown
  259.         6Ch     extended open/create                    (DOS 4.0)
  260.  
  261.  
  262. CALLING THE DOS SERVICES├──────────────────────────────────────────────────────
  263.  
  264.  The DOS services are invoked by placing the number of the desired function in 
  265. register AH, subfunction in AL, setting the other registers to any specific 
  266. requirements of the function, and invoking int 21h. 
  267.  
  268.  On return, the requested service will be performed if possible. Most codes 
  269. will return an error; some return more information. Details are contained in 
  270. the listings for the individual functions. Extended error return may be 
  271. obtained by calling function 59h (see 59h).
  272.  
  273.  Register settings listed are the ones used by DOS. Some functions will return 
  274. with garbage values in unused registers. Do not test for values in unspecified 
  275. registers; your program may exhibit odd behavior.
  276.  
  277.  DS:DX pointers are the data segment register (DS) indexed to the DH and DL
  278. registers (DX). DX always contains the offset address, DS contains the segment 
  279. address.
  280.  
  281.  The File Control Block services (FCB services) were part of DOS 1.0. Since 
  282. the release of DOS 2.0, Microsoft has recommended that these services not be 
  283. used. A set of considerably more enhanced services (handle services) were 
  284. introduced with DOS 2.0. The handle services provide support for wildcards and 
  285. subdirectories, and enhanced error detection via function 59h.
  286.  
  287.  The data for the following calls was compiled from various Intel, Microsoft, 
  288. IBM, and other publications. There are many subtle differences between MSDOS 
  289. and PCDOS and between the individual versions. Differences between the 
  290. versions are noted as they occur.
  291.  
  292.  There are various ways of calling the DOS functions. For all methods, the
  293. function number is loaded into register AH, subfunctions and/or parameters are
  294. loaded into AL or other registers, and call int 21 by one of the following 
  295. methods:
  296.  A) call interrupt 21h directly  (the recommended procedure)
  297.  B) perform a long call to offset 50h in the program's PSP.
  298.      1) This method will not work under DOS 1.x
  299.      2) Though recommended by Microsoft for DOS 2.0, this method takes more
  300.         time and is no longer recommended.
  301.  C) place the function number in CL and perform an intrasegment call to 
  302.     location 05h in the current code segment. This location contains a long
  303.     call to the DOS function dispatcher. 
  304.      1) IBM recommends this method be used only when using existing programs 
  305.         written for different calling conventions. (such as converting CP/M
  306.         programs). This method should be avoided unless you have some specific
  307.         use for it.
  308.      2) AX is always destroyed by this method.
  309.      3) This method is valid only for functions 00h-24h.
  310.  
  311.  There are also various ways of exiting from a program. (assuming it is not
  312. intended to be a TSR). All methods except call 4Ch must ensure that the 
  313. segment register contains the segment address of the PSP.
  314.  A) Interrupt 21h, function 4Ch (Terminate with Result Code). This is the
  315.     "official" recommended method of returning to DOS.
  316.  B) Interrupt 21h, function 00h (Exit Program). This is the early style
  317.     int 21 function call. It simply calls int 20h.
  318.  C) Interrupt 20h (Exit).
  319.  D) A JMP instruction to offset 00h (int 20h vector) in the Program Segment
  320.     Prefix. This is just a roundabout method to call int 20h. This method
  321.     was set up in DOS 1.0 for ease of conversion for CP/M programs. It is no
  322.     longer recommended for use.
  323.  E) A JMP instruction to offset 05h (int 21 vector) in the Program Segment
  324.     Prefix, with AH set to 00h or 4Ch. This is another CP/M type function.
  325.  
  326.  
  327.  
  328.  
  329. INT 21H   DOS services
  330.           Function (hex)
  331.  
  332. * Indicates Functions not documented in the IBM DOS Technical Reference.
  333.  Note some functions have been documented in other Microsoft or licensed OEM
  334. documentation.
  335.  
  336.  
  337. Function  00h   Terminate Program
  338.       Ends program, updates, FAT, flushes buffers, restores registers
  339. entry   AH      00h
  340.         CS      segment address of PSP
  341. return  none
  342. note 1) Program must place the segment address of the PSP control block in CS 
  343.         before calling this function.                       
  344.      2) The terminate, ctrl-break,and critical error exit addresses (0Ah, 0Eh, 
  345.         12h) are restored to the values they had on entry to the terminating
  346.         program, from the values saved in the program segment prefix at 
  347.         locations PSP:000Ah, PSP:000Eh, and PSP:0012h. 
  348.      3) All file buffers are flushed and the handles opened by the process are 
  349.         closed. 
  350.      4) Any files that have changed in length and are not closed are not 
  351.         recorded properly in the directory. 
  352.      5) Control transfers to the terminate address.
  353.      6) This call performs exactly the same function as int 20h.
  354.      7) All memory used by the program is returned to DOS.
  355.  
  356.  
  357. Function  01h     Get Keyboard Input
  358.         Waits for char at STDIN (if nescessary), echoes to STDOUT
  359. entry   AH      01h
  360. return  AL      ASCII character from STDIN (8 bits)
  361. note 1) Checks char for Ctrl-C, if char is Ctrl-C, executes int 23h.
  362.      2) For function call 06h, extended ASCII codes require two function calls. 
  363.         The first call returns 00h as an indicator that the next call will be an
  364.         extended ASCII code.
  365.      3) Input and output are redirectable. If redirected, there is no way to 
  366.         detect EOF.
  367.  
  368.  
  369. Function  02h   Display Output
  370.       Outputs char in DL to STDOUT
  371. entry   AH      02h
  372.         DL      8 bit data (usually ASCII character)
  373. return  none
  374. note 1) If char is 08 (backspace) the cursor is moved 1 char to the left 
  375.         (nondestructive backspace).
  376.      2) If Ctrl-C is detected after input, int 23h is executed.
  377.      3) Input and output are redirectable. If redirected, there is no way to 
  378.         detect disk full.
  379.  
  380.  
  381. Function  03h   Auxiliary Input
  382.       Get (or wait until) character from STDAUX
  383. entry   AH      03h
  384. return  AL      char from auxiliary device
  385. note 1) AUX, COM1, COM2 is unbuffered and not interrupt driven
  386.      2) This function call does not return status or error codes. For greater 
  387.         control it is recommended that you use ROM BIOS routine (int 14h) or 
  388.         write an AUX device driver and use IOCTL.
  389.      3) At startup, PC-DOS initializes the first auxiliary port (COM1) to 2400 
  390.         baud, no parity, one stop bit, and an 8-bit word. MSDOS may differ.
  391.      4) If Ctrl-C is has been entered from STDIN, int 23h is executed.
  392.  
  393.  
  394. Function  04h   Auxiliary Output
  395.       Write character to STDAUX
  396. entry   AH      04h
  397.         DL      char to send to AUX
  398. return  none
  399. note 1) This function call does not return status or error codes. For greater 
  400.         control it is recommended that you use ROM BIOS routine (int 14h) or 
  401.         write an AUX device driver and use IOCTL.
  402.      2) If Ctrl-C is has been entered from STDIN, int 23h is executed.
  403.      3) Default is COM1 unless redirected by DOS.
  404.      4) If the device is busy, this function will wait until it is ready.
  405.  
  406.  
  407. Function  05h   Printer Output
  408.       Write character to STDPRN
  409. entry   AL      05h
  410.         DL      character to send
  411. return  none
  412. note 1) If Ctrl-C is has been entered from STDIN, int 23h is executed.
  413.      2) Default is PRN or LPT1 unless redirected with the MODE command.
  414.      3) If the printer is busy, this function will wait until it is ready.
  415.      
  416.  
  417. Function  06h   Direct Console I/O
  418.       Get character from STDIN; echo character to STDOUT
  419. entry   AH      06h
  420.         DL      0FFh for console input, or 00h-0FEh for console output
  421. return  ZF      set   (1) = no character
  422.                 clear (0) = character recieved
  423.         AL      character
  424. note 1) Extended ASCII codes require two function calls. The first call returns
  425.         00h to indicate the next call will return an extended code.
  426.      2) If DL is not 0FFh, DL is assumed to have a valid character that is 
  427.         output to STDOUT. 
  428.      3) This function does not check for Ctrl-C or Ctrl-PrtSc.
  429.      4) Does not echo input to screen
  430.      5) If I/O is redirected, EOF or disk full cannot be detected.
  431.  
  432.  
  433. Function  07h   Direct Console Input Without Echo         (does not check BREAK)
  434.       Get or wait for char at STDIN, returns char in AL
  435. entry   AH      07h
  436. return  AL      character from standard input device
  437. note 1) Extended ASCII codes require two function calls. The first call returns
  438.         00h to indicate the next call will return an extended code.
  439.      2) No checking for Ctrl-C or Ctrl-PrtSc is done.
  440.      3) Input is redirectable.
  441.  
  442.  
  443. Function  08h   Console Input Without Echo                (checks BREAK)
  444.       Get or Wait for char at STDIN, return char in AL
  445. entry   AH      08h
  446. return  AL      char from standard input device
  447. note 1) Char is checked for ctrl-C. If ctrl-C is detected, executes int 23h.
  448.      2) For function call 08h, extended ASCII characters require two function 
  449.         calls. The first call returns 00h to signify an extended ASCII code. 
  450.         The next call returns the actual code.
  451.      3) Input is redirectable. If redirected, there is no way to check EOF.
  452.  
  453.  
  454. Function  09h   Print String
  455.       Outputs Characters in the Print String to the STDOUT
  456. entry   AH      09h
  457.         DS:DX   pointer to the Character String to be displayed
  458. return  none                                                       
  459. note 1) The character string in memory must be terminated by a $ (24h)
  460.         The $ is not displayed.
  461.      2) Output to STDOUT is the same as function call 02h.
  462.  
  463.  
  464. Function  0Ah   Buffered Keyboard Input
  465.       Reads characters from STDIN and places them in the buffer beginning
  466.       at the third byte.
  467. entry   AH      0Ah
  468.         DS:DX   pointer to an input buffer
  469. return  none
  470. note 1) Min buffer size = 1, max = 255
  471.      2) Char is checked for ctrl-C. If ctrl-C is detected, executes int 23h.
  472.      3) Format of buffer DX:
  473.         byte       contents
  474.          1      Maximum number of chars the buffer will take, including CR.
  475.                 Reading STDIN and filling the buffer continues until a carriage
  476.                 return (<Enter> or 0Dh) is read. If the buffer fills to one less
  477.                 than the maximum number the buffer can hold, each additional 
  478.                 number read is ignored and ASCII 7 (BEL) is output to the 
  479.                 display until a carriage return is read. (you must set this
  480.                 value)
  481.          2      Actual number of characters received, excluding the carriage
  482.                 return, which is always the last character. (the function sets
  483.                 this value)
  484.          3-n    Characters received are placed into the buffer starting here.
  485.                 Buffer must be at least as long as the number in byte 1.
  486.      4) Input is redirectable. If redirected, there is no way to check EOF.
  487.      5) The string may be edited with the standard DOS editing commands as it
  488.         is being entered.
  489.      6) Extended ASCII characters are stored as 2 bytes, the first byte being 
  490.         zero.
  491.  
  492.  
  493. Function  0Bh   Check Standard Input (STDIN) status
  494.       Checks for character availible at STDIN 
  495. entry   AH      0Bh
  496. return  AL      0FFh    if a character is availible from STDIN
  497.                 00h     if no character is availible from STDIN
  498. note 1) Checks for Ctrl-C. If Ctrl-C is detected, int 23h is executed
  499.      2) Input can be redirected.
  500.      3) Checks for character only, it is not read into the application
  501.      4) IBM reports that this call does not work properly under the DOSSHELL
  502.         program in DOS 4.00 and 4.01. DOSSHELL will return all zeroes. This
  503.         function works correctly from the command line or application.
  504.  
  505.  
  506. Function  0Ch   Clear Keyboard Buffer & Invoke a Keyboard Function       (FCB)
  507.       Dumps buffer, executes function in AL (01h,06h,07h,08h,0Ah only)
  508. entry   AH      0Ch
  509.         AL      function number (must be 01h, 06h, 07h, 08h, or 0Ah)
  510. return  AL      00h     buffer was flushed, no other processing performed
  511.                 other   any other value has no meaning
  512. note 1) Forces system to wait until a character is typed. 
  513.      2) Flushes all typeahead input, then executes function specified by AL (by
  514.         moving it to AH and repeating the int 21 call).
  515.      3) If AL contains a value not in the list above, the keyboard buffer is
  516.         flushed and no other action is taken.
  517.  
  518.  
  519. Function  0Dh   Disk Reset
  520.       Flushes all currently open file buffers to disk
  521. entry   AH      0Dh
  522. return          none
  523. note 1) Does not close files. Does not update directory entries; files changed
  524.         in size but not closed are not properly recorded in the directory
  525.      2) Sets DTA address to DS:0080h
  526.      3) Should be used before a disk change, Ctrl-C handlers, and to flush
  527.         the buffers to disk.
  528.      
  529.  
  530. Function  0Eh   Select Disk
  531.       Sets the drive specified in DL (if valid) as the default drive
  532. entry   AL      0Eh
  533.         DL      new default drive number (0=A:,1=B:,2=C:,etc.)
  534. return  AL      total number of logical drives (not nescessarily physical)
  535. note 1) For DOS 1.x and 2.x, the minimum value for AL is 2.
  536.      2) For DOS 3.x and 4.x, the minimum value for AL is 5.
  537.      3) The drive number returned is not nescessarily a valid drive.
  538.      4) For DOS 1.x: 16 logical drives are availible, A-P.
  539.         For DOS 2.x: 63 logical drives are availible. (Letters are only used for
  540.                      the first 26 drives. If more than 26 logical drives are
  541.                      used, further drive letters will be other ASCII characters
  542.                      ie {,], etc.
  543.         For DOS 3.x: 26 logical drives are availible, A-Z.
  544.         For DOS 4.x: 26 logical drives are availible, A-Z.
  545.  
  546.  
  547. Function  0Fh   Open Disk File                                            (FCB)
  548.       Searches current directory for specified filename and opens it
  549. entry   AH      0Fh
  550.         DS:DX   pointer to an unopened FCB
  551. return  AL      00h     if file found
  552.                 0FFh    if file not not found
  553. note 1) If the drive code was 0 (default drive) it is changed to the actual 
  554.         drive used (1=A:,2=B:,3=C:, etc). This allows changing the default drive
  555.         without interfering with subsequent operations on this file. 
  556.      2) The current block field (FCB bytes C-D, offset 0Ch) is set to zero. 
  557.      3) The size of the record to be worked with (FCB bytes E-F, offset 0Eh) is
  558.         set to the system default of 80h. The size of the file (offset 10h) and
  559.         the date (offset 14h) are set from information obtained in the root
  560.         directory. You can change the default value for the record size (FCB
  561.         bytes E-F) or set the random record size and/or current record field.
  562.         Perform these actions after the open but before any disk operations.
  563.      4) The file is opened in compatibility mode. 
  564.      5) Microsoft recommends handle function call 3Dh be used instead.
  565.      6) This call is also used by the APPEND command in DOS 3.2+
  566.      7) Before performing a sequential disk operation on the file, you must 
  567.         set the Current Record field (offset 20h). Before performing a random 
  568.         disk operation on the file, you must set the Relative Record field
  569.         (offset 21h). If the default record size of 128 bytes is incorrect, set
  570.         it to the correct value.
  571.  
  572.  
  573. Function  10h  Close File                                              (FCB)
  574.      Closes a File After a File Write 
  575. entry   AH      10h
  576.         DS:DX   pointer to an opened FCB
  577. return  AL      00h     if the file is found and closed
  578.                 0FFh    if the file is not found in the current directory
  579. note 1) This function call must be done on open files that are no longer needed,
  580.         and after file writes to insure all directory information is updated. 
  581.      2) If the file is not found in its correct position in the current 
  582.         directory, it is assumed that the diskette was changed and AL returns 
  583.         0FFh. This error return is reportedly not completely reliable with DOS
  584.         version 2.x.
  585.      3) If found, the directory is updated to reflect the status in the FCB, the
  586.         buffers to that file are flushed, and AL returns 00h.
  587.  
  588.  
  589. Function  11h   Search For First Matching Entry                           (FCB)
  590.       Searches current disk & directory for first matching filename
  591. entry   AH      11h
  592.         DS:DX   pointer to address of FCB
  593. return  AL      00h     successful match
  594.                 0FFh    no matching filename found
  595. note 1) The FCB may contain the wildcard character ? under Dos 2.x, and ? or * 
  596.         under 3.x and 4.x.
  597.      2) The original FCB at DS:DX contains information to continue the search
  598.         with function 12h, and should not be modified.
  599.      3) If a matching filename is found, AL returns 00h and the locations at the
  600.         Disk Transfer Address are set as follows:
  601.         a) If the FCB provided for searching was an extended FCB, then the first
  602.            byte at the disk transfer address is set to 0FFh followed by 5 bytes
  603.            of zeroes, then the attribute byte from the search FCB, then the 
  604.            drive number used (1=A, 2=B, etc) then the 32 bytes of the directory
  605.            entry. Thus, the disk transfer address contains a valid unopened FCB
  606.            with the same search attributes as the search FCB.
  607.         b) If the FCB provided for searching was a standard FCB, then the first 
  608.            byte is set to the drive number used (1=A,2=b,etc), and the next 32 
  609.            bytes contain the matching directory entry. Thus, the disk transfer 
  610.            address contains a valid unopened normal FCB.
  611.      4) If an extended FCB is used, the following search pattern is used:
  612.         a) If the FCB attribute byte is zero, only normal file entries are 
  613.            found. Entries for volume label, subdirectories, hidden or system 
  614.            files, are not returned.
  615.         b) If the attribute byte is set for hidden or system files, or 
  616.            subdirectory entries, it is to be considered as an inclusive search.
  617.            All normal file entries plus all entries matching the specified 
  618.            attributes are returned. To look at all directory entries except the
  619.            volume label, the attribute byte may be set to hidden + system + 
  620.            directory (all 3 bits on).
  621.         c) If the attribute field is set for the volume label, it is considered
  622.            an exclusive search, and ONLY the volume label entry is returned.
  623.      5) This call is also used by the APPEND command in DOS 3.2+
  624.  
  625.  
  626. Function  12h   Search For Next Entry Using FCB                          (FCB)
  627.       Search for next matching filename
  628. entry   AH      12h 
  629.         DS:DX   pointer to the unopened FCB specified from the previous Search
  630.                 First (11h) or Search Next (12h)
  631. return  AL      00h     if matching filename found
  632.                 0FFh    if matching filename was not found
  633. note 1) After a matching filename has been found using function call 11h, 
  634.         function 12h may be called to find the next match to an ambiguous 
  635.         request. For DOS 2.x, ?'s are allowed in the filename. For DOS 3.x 
  636.         and 4.x, global (*) filename characters are allowed.
  637.      2) The DTA contains info from the previous Search First or Search Next. 
  638.      3) All of the FCB except for the name/extension field is used to keep 
  639.         information nescessary for continuing the search, so no disk operations 
  640.         may be performed with this FCB between a previous function 11h or 12h 
  641.         call and this one.
  642.      4) If the file is found, an FCB is created at the DTA address and set up to
  643.         open or delete it.
  644.  
  645.  
  646. Function  13h   Delete File Via FCB                                       (FCB)
  647.       Deletes file specified in FCB from current directory
  648. entry   AH      13h
  649.         DS:DX   pointer to address of FCB
  650. return  AL      00h     file deleted
  651.                 0FFh    if file not found or was read-only
  652. note 1) All matching current directory entries are deleted. The global filename 
  653.         character "?" is allowed in the filename.
  654.      2) Will not delete files with read-only attribute set
  655.      3) Close open files before deleting them.
  656.      4) Requires Network Access Rights
  657.  
  658.  
  659. Function  14h   Sequential Disk File Read                                 (FCB)
  660.       Reads record sequentially from disk via FCB
  661. entry   AH  14h
  662.         DS:DX   pointer to an opened FCB
  663. return  AL      00h     successful read
  664.                 01h     end of file (no data read)
  665.                 02h     Data Transfer Area too small for record size specified
  666.                         or segment overflow
  667.                 03h     partial record read, EOF found
  668. note 1) The record size is set to the value at offset 0Eh in the FCB.
  669.      2) The record pointed to by the Current Block (offset 0Ch) and the Current
  670.         Record (offset 20h) fields is loaded at the DTA, then the Current Block
  671.         and Current Record fields are incremented.
  672.      3) The record is read into memory at the current DTA address as specified 
  673.         by the most recent call to function 1Ah. If the size of the record and
  674.         location of the DTA are such that a segment overflow or wraparound would
  675.         occur, the error return is set to AL=02h
  676.      4) If a partial record is read at the end of the file, it is passed to the
  677.         requested size with zeroes and the error return is set to AL=03h.
  678.  
  679.  
  680. Function  15h   Sequential Disk Write                                     (FCB)
  681.       Writes record specified by FCB sequentially to disk
  682. entry   AH      15h
  683.         DS:DX   pointer to address of FCB 
  684. return  AL      00h     successful write
  685.                 01h     diskette full, write canceled
  686.                 02h     disk transfer area (DTA) too small or segment wrap
  687. note 1) The data to write is obtained from the disk transfer area
  688.      2) The record size is set to the value at offset 0Eh in the FCB.
  689.      3) This service cannot write to files set as read-only
  690.      4) The record pointed to by the Current Block (offset 0Ch) and the Current
  691.         Record (offset 20h) fields is loaded at the DTA, then the Current Block
  692.         and Current Record fields are incremented.
  693.      5) If the record size is less than a sector, the data in the DTA is written
  694.         to a buffer; the buffer is written to disk when it contains a full 
  695.         sector of data, the file is closed, or a Reset Disk (function 0Dh) is
  696.         issued.
  697.      6) The record is written to disk at the current DTA address as specified 
  698.         by the most recent call to function 1Ah. If the size of the record and
  699.         location of the DTA are such that a segment overflow or wraparound would
  700.         occur, the error return is set to AL=02h
  701.  
  702.  
  703. Function  16h   Create A Disk File                                        (FCB)
  704.       Search and open or create directory entry for file
  705. entry   AH      16h
  706.         DS:DX   pointer to an FCB
  707. return  AL      00h     successful creation
  708.                 0FFh    no room in directory
  709. note 1) If a matching directory entry is found, the file is truncated to zero
  710.         bytes.
  711.      2) If there is no matching filename, a filename is created.
  712.      3) This function calls function 0Fh (Open File) after creating or 
  713.         truncating a file.
  714.      4) A hidden file can be created by using an extended FCB with the attribute
  715.         byte (offset FCB-1) set to 2.
  716.  
  717.  
  718. Function  17h   Rename File Specified by File Control Block              (FCB)
  719.       Renames file in current directory
  720. entry   AH      17h
  721.         DS:DX   pointer to an FCB (see note 4)
  722. return  AL      00h     successfully renamed
  723.                 0FFh    file not found or filename already exists
  724. note 1) This service cannot rename read-only files
  725.      2) The "?" wildcard may be used.
  726.      3) If the "?" wildcard is used in the second filename, the corresponding 
  727.         letters in the filename of the directory entry are not changed.
  728.      4) The FCB must have a drive number, filename, and extension in the usual
  729.         position, and a second filename starting 6 bytes after the first, at 
  730.         offset 11h.
  731.      5) The two filenames cannot have the same name.
  732.      6) FCB contains new name starting at byte 17h.
  733.  
  734.  
  735. Function  18h  Internal to DOS
  736.  *   Unknown
  737. entry   AH      18h
  738. return  AL      0
  739.  
  740.  
  741. Function  19h   Get Current Disk Drive
  742.       Return designation of current default disk drive
  743. entry   AH      19h
  744. return  AL      current default drive (0=A, 1=B,etc.)  
  745. note    Some other DOS functions use 0 for default, 1=A, 2=B, etc.
  746.  
  747.  
  748. Function  1Ah   Set Disk Transfer Area Address (DTA) 
  749.       Sets DTA address to the address specified in DS:DX
  750. entry   AH      1Ah
  751.         DS:DX   pointer to buffer
  752. return  none
  753. note 1) The default DTA is 128 bytes at offset 80h in the PSP. DOS uses the 
  754.         DTA for all file I/O. 
  755.      2) Registers are unchanged.
  756.      3) No error codes are returned.
  757.      2) Disk transfers cannot wrap around from the end of the segment to the 
  758.         beginning or overflow into another segment.
  759.  
  760.  
  761. Function  1Bh   Get Current Drive File Allocation Table Information
  762.       Returns information from the FAT on the current drive
  763. entry   AH      1Bh
  764. exit    AL      number of sectors per allocation unit (cluster)
  765.         DS:BX   address of the current drive's media descriptor byte
  766.         CX      number of bytes per sector
  767.         DX      number of allocation units (clusters) for default drive
  768. note 1) Save DS before calling this function.
  769.      2) This call returned a pointer to the FAT in DOS 1.x. Beginning with
  770.         DOS 2.00, it returns a pointer only to the table's ID byte.
  771.      3) IBM recommends programmers avoid this call and use int 25h instead.
  772.  
  773.  
  774. Function  1Ch   Get File Allocation Table Information for Specific Device 
  775.       Returns information on specified drive
  776. entry   AH      1Ch
  777.         DL      drive number (1=A, 2=B, 3=C, etc)
  778. return  AL      number of sectors per allocation unit (cluster)
  779.         DS:BX   address of media descriptor byte for drive in DL
  780.         CX      sector size in bytes
  781.         DX      number of allocation units (clusters)
  782. note 1) DL = 0 for default.
  783.      2) Save DS before calling this function.
  784.      3) Format of media-descriptor byte:
  785.         bits:   0       0   (clear)   not double sided
  786.                         1   (set)     double sided
  787.                 1       0   (clear)   not 8 sector
  788.                         1   (set)     8 sector
  789.                 2       0   (clear)   nonremovable device
  790.                         1   (set)     removable device
  791.                 3-7     always set (1)
  792.      4) This call returned a pointer to the FAT in DOS 1.x. Beginning with
  793.         DOS 2.00, it returns a pointer only to the table's ID byte.
  794.      5) IBM recommends programmers avoid this call and use int 25h instead.
  795.  
  796.  
  797. Function  1Dh   Not Documented by Microsoft
  798.  *    Unknown
  799. entry   AH      1Dh
  800. return  AL      0
  801.  
  802.  
  803. Function  1Eh   Not Documented by Microsoft
  804.  *    Unknown
  805. entry   AH      1Eh
  806. return  AL      0
  807. note    Apparently does nothing
  808.  
  809.  
  810. Function  1Fh Get Default Drive Parameter Block 
  811.  *  Same as function call 32h (below), except that the table is accessed from 
  812.     the default drive
  813. entry   AH      1Fh
  814.         other registers unknown
  815. return  AL      00h     no error
  816.                 0FFh    error
  817.         DS:BX   points to DOS Disk Parameter Block for default drive.
  818. note 1) Unknown vector returned in ES:BX.
  819.      2) For DOS 2.x and 3.x, this just invokes function 32h (undocumented, 
  820.         Read DOS Disk Block) with DL=0
  821.  
  822.  
  823. Function  20h  Unknown
  824.  *   Internal - does nothing? 
  825. entry   AH      20h
  826. return  AL      0
  827.  
  828.  
  829. Function  21h  Random Read from File Specified by File Control Block     (FCB)
  830.      Reads one record as specified in the FCB into the current DTA.
  831. entry   AH      21h
  832.         DS:DX   address of the opened FCB
  833. return  AL      00h     successful read operation
  834.                 01h     end of file (EOF), no data read
  835.                 02h     DTA too small for the record size specified
  836.                 03h     end of file (EOF), partial data read
  837. note 1) The current block and current record fields are set to agree with the
  838.         random record field. Then the record addressed by these fields is read
  839.         into memory at the current Disk Transfer Address.
  840.      2) The current file pointers are NOT incremented this function.
  841.      3) If the DTA is larger than the file, the file is padded to the requested
  842.         length with zeroes.
  843.  
  844.  
  845. Function  22h  Random Write to File Specified by FCB                      (FCB)
  846.      Writes one record as specified in the FCB to the current DTA
  847. entry   AH      22h
  848.         DS:DX   address of the opened FCB
  849. return  AL      00h     successful write operation
  850.                 01h     disk full; no data written (write was canceled)
  851.                 02h     DTA too small for the record size specified (write was
  852.                         canceled)
  853. note 1) This service cannot write to read-only files.
  854.      2) The record pointed to by the Current Block (offset 0Ch) and the Current
  855.         Record (offset 20h) fields is loaded at the DTA, then the Current Block
  856.         and Current Record fields are incremented.
  857.      3) If the record size is less than a sector, the data in the DTA is written
  858.         to a buffer; the buffer is written to disk when it contains a full 
  859.         sector of data, the file is closed, or a Reset Disk (function 0Dh) is
  860.         issued.
  861.      4) The current file pointers are NOT incremented this function.
  862.      5) The record is written to disk at the current DTA address as specified 
  863.         by the most recent call to function 1Ah. If the size of the record and
  864.         location of the DTA are such that a segment overflow or wraparound would
  865.         occur, the error return is set to AL=02h
  866.  
  867.  
  868. Function  23h  Get File Size                                             (FCB)
  869.      Searches current subdirectory for matching file, returns size in FCB
  870. entry   AH      23h
  871.         DS:DX   address of an unopened FCB
  872. return  AL      00h file found
  873.                 0FFh file not found
  874. note 1) Record size field (offset 0Eh) must be set before invoking this function
  875.      2) The disk directory is searched for the matching entry. If a matching
  876.         entry is found, the random record field is set to the number of records
  877.         in the file. If the value of the Record Size field is not an even
  878.         divisor of the file size, the value set in the relative record field is 
  879.         rounded up. This gives a returned value larger than the actual file size
  880.      3) This call is used by the APPEND command in DOS 3.2+
  881.  
  882.  
  883. Function  24h  Set Relative Record Field                                  (FCB)
  884.      Set random record field specified by an FCB
  885. entry   AH      24h
  886.         DS:DX   address of an opened FCB
  887. return  Random Record Field of FCB is set to be same as Current Block
  888.         and Current Record.
  889. note 1) You must invoke this function before performing random file access.
  890.      2) The relative record field of FCB (offset 21h) is set to be same as the
  891.         Current Block (offset 0Ch) and Current Record (offset 20h).
  892.      3) No error codes are returned.
  893.      4) The FCB must already be opened.
  894.  
  895.  
  896. Function  25h  Set Interrupt Vector
  897.      Sets the address of the code DOS is to perform each time the specified
  898.      interrupt is invoked.
  899. entry   AH      25h
  900.         AL      int number to reassign the handler to
  901.         DS:DX   address of new interrupt vector
  902. return  none
  903. note 1) Registers are unchanged.
  904.      2) No error codes are returned.
  905.      3) The interrupt vector table for the interrupt number specified in AL
  906.         is set to the address contained in DS:DX. Use function 35h (Get Vector)
  907.         to get the contents of the interrupt vector and save it for later use.
  908.      4) When you use function 25 to set an interrupt vector, DOS 3.2 doesn't
  909.         point the actual interrupt vector to what you requested. Instead, it
  910.         sets the interrupt vector to point to a routine inside DOS, which does
  911.         this:
  912.                 1. Save old stack pointer
  913.                 2. Switch to new stack pointer allocated from DOS's stack pool
  914.                 3. Call your routine
  915.                 4. Restore old stack pointer
  916.         The purpose for this was to avoid possible stack overflows when there
  917.         are a large number of active interrupts. IBM was concerned (this was an
  918.         IBM change, not Microsoft) that on a Token Ring network there would be
  919.         a lot of interrupts going on, and applications that hadn't allocated
  920.         very much stack space would get clobbered. 
  921.  
  922.  
  923. Function  26h  Create New Program Segment Prefix (PSP)
  924.      This service copies the current program-segment prefix to a new memory 
  925.      location for the creation of a new program or overlay. Once the new PSP is
  926.      in place, a DOS program can read a DOS COM or overlay file into the memory 
  927.      location immediately following the new PSP and pass control to it.
  928. entry   AH      26h
  929.         DX      segment number for the new PSP
  930. return  none
  931. note 1) Microsoft recommends you use the newer DOS service 4Bh (EXEC) instead.
  932.      2) The entire 100h area at location 0 in the current PSP is copied into
  933.         location 0 of the new PSP. The memory size information at location 6
  934.         in the new segment is updated and the current termination, ctrl-break,
  935.         and critical error addresses from interrupt vector table entries for
  936.         ints 22h, 23h, and 24 are saved in the new program segment starting at
  937.         0Ah. They are restored from this area when the program terminates.
  938.      3) Current PSP is copied to specified segment
  939.                    
  940.  
  941. Function  27h  Random Block Read From File Specified by FCB
  942.      Similar to 21h (Random Read) except allows multiple files to be read.
  943. entry   AH      27h
  944.         CX      number of records to be read
  945.         DS:DX   address of an opened FCB
  946. return  AL      00h     successful read
  947.                 01h     end of file, no data read
  948.                 02h     DTA too small for record size specified (read canceled)
  949.                 03h     end of file
  950.         CX      actual number of records read (includes partial if AL=03h)
  951. note 1) The record size is specified in the FCB. The service updates the Current
  952.         Block (offset 0Ch) and Current Record (offset 20h) fields to the next
  953.         record not read.
  954.      2) If CX contained 0 on entry, this is a NOP.
  955.      3) If the DTA is larger than the file, the file is padded to the requested
  956.         length with zeroes.
  957.      4) This function assumes that the FCB record size field (0Eh) is correctly
  958.         set. If not set by the user, the default is 128 bytes.
  959.      5) The record is written to disk at the current DTA address as specified 
  960.         by the most recent call to function 1Ah. If the size of the record and
  961.         location of the DTA are such that a segment overflow or wraparound would
  962.         occur, the error return is set to AL=02h
  963.  
  964.  
  965. Function  28h  Random Block Write to File Specified in FCB
  966.      Similar to 27h (Random Write) except allows multiple files to be read.
  967. entry   AH      28h
  968.         CX      number of records to write
  969.         DS:DX   address of an opened FCB
  970. return  AL      00h     successful write
  971.                 01h     disk full, no data written
  972.                 02h     DTA too small for record size specified (write canceled)
  973.         CX      number of records written
  974. note 1) The record size is specified in the FCB.
  975.      2) This service allocates disk clusters as required.
  976.      3) This function assumes that the FCB Record Size field (offset 0Eh) is
  977.         correctly set. If not set by the user, the default is 128 bytes.
  978.      4) The record size is specified in the FCB. The service updates the Current
  979.         Block (offset 0Ch) and Current Record (offset 20h) fields to the next
  980.         record not read.
  981.      5) The record is written to disk at the current DTA address as specified 
  982.         by the most recent call to function 1Ah. If the size of the record and
  983.         location of the DTA are such that a segment overflow or wraparound would
  984.         occur, the error return is set to AL=02h
  985.      6) If called with CX=0, no records are written, but the FCB's File Size
  986.         entry (offset 1Ch) is set to the size specified by the FCB's Relative 
  987.         Record field (offset 21h).
  988.  
  989.  
  990. Function  29h  Parse the Command Line for Filename
  991.      Parses a text string into the fields of a File Control Block
  992. entry   AH      29h
  993.         DS:SI   pointer to string to parse
  994.         ES:DI   pointer to memory buffer to fill with unopened FCB
  995.         AL      bit mask to control parsing
  996.                 bit 0 = 0: parsing stops if file seperator found
  997.                         1: causes service to scan past leading chars such as
  998.                            blanks. Otherwise assumes the filename begins in
  999.                            the first byte
  1000.                     1 = 0: drive number in FCB set to default (0) if string
  1001.                            contains no drive number
  1002.                         1: drive number in FCB not changed
  1003.                     2 = 0: filename in FCB set to 8 blanks if no filename in 
  1004.                            string
  1005.                         1: filename in FCB not changed if string does not 
  1006.                            contain a filename
  1007.                     3 = 0: extension in FCB set to 3 blanks if no extension in 
  1008.                            string
  1009.                         1: extension left unchanged
  1010.                     4-7    must be zero
  1011. return  AL      00h     no wildcards in name or extension
  1012.                 01h     wildcards appeared in name or extension
  1013.                 0FFh    invalid drive specifier
  1014.         DS:SI   pointer to the first byte after the parsed string
  1015.         ES:DI   pointer to a buffer filled with the unopened FCB
  1016. note 1) If the * wildcard characters are found in the command line, this service
  1017.         will replace all subsequent chars in the FCB with question marks.
  1018.      2) This service uses the characters as filename separators
  1019.         DOS 1       : ; . , + / [ ] = " TAB SPACE
  1020.         DOS 2,3     : ; . , + = TAB SPACE
  1021.      3) This service uses the characters
  1022.         : ; . , + < > | / \ [ ] = " TAB SPACE
  1023.         or any control characters as valid filename separators
  1024.      4) A filename cannot contain a filename terminator. If one is encountered,
  1025.         all processing stops. The handle functions will allow use of some of
  1026.         these characters.
  1027.      5) If no valid filename was found on the command line, ES:DI +1 points
  1028.         to a blank (ASCII 32).
  1029.      6) This function cannot be used with filespecs which include a path
  1030.      7) Parsing is in the form D:FILENAME.EXT. If one is found, a corresponding
  1031.         unopened FCB is built at ES:DI
  1032.  
  1033.  
  1034. Function  2Ah  Get Date
  1035.      Returns day of the week, year, month, and date
  1036. entry   AH      2Ah
  1037. return  CX      year    (1980-2099)
  1038.         DH      month   (1-12)
  1039.         DL      day     (1-31)
  1040.         AL      weekday 00h     Sunday
  1041.                         01h     Monday
  1042.                         02h     Tuesday
  1043.                         03h     Wednesday
  1044.                         04h     Thursday
  1045.                         05h     Friday
  1046.                         06h     Saturday
  1047. note 1) Date is adjusted automatically if clock rolls over to the next day,
  1048.         and takes leap years and number of days in each month into account.
  1049.      2) Although DOS cannot set an invalid date, it can read one, such as
  1050.         1/32/80, etc.
  1051.      3) DesQview also accepts CX = 4445h and DX = 5351h, i.e. 'DESQ' as valid
  1052.      4) DOS will accept CH=0 (midnight) as a valid time, but if a file's time
  1053.         is set to exactly midnight the time will not be displayed by the DIR
  1054.         command.
  1055.  
  1056.  
  1057. Function  2Bh  Set Date
  1058.      set current system date
  1059. entry   AH      2Bh
  1060.         CX      year    (1980-2099)
  1061.         DH      month   (1-12)
  1062.         DL      day     (1-31)
  1063. return  AL      00h     no error (valid date)
  1064.                 0FFh    invalid date specified
  1065. note 1) On entry, CX:DX must have a valid date in the same format as returned 
  1066.         by function call 2Ah
  1067.      2) DOS 3.3 also sets CMOS clock
  1068.  
  1069.  
  1070. Function  2Ch  Get Time
  1071.      Get current system time from CLOCK$ driver
  1072. entry   AH      2Ch
  1073. return  CH      hours   (0-23)
  1074.         CL      minutes (0-59)
  1075.         DH      seconds (0-59)
  1076.         DL      hundredths of a second (0-99)
  1077. note 1) Time is updated every 5/100 second.
  1078.      2) The date and time are in binary format
  1079.  
  1080.  
  1081. Function  2Dh  Set Time
  1082.      Sets current system time
  1083. entry   AH      2Dh
  1084.         CH      hours   (0-23)
  1085.         CL      minutes (0-59)
  1086.         DH      seconds (0-59)
  1087.         DL      hundredths of seconds (0-99)
  1088. return  AL      00h     if no error
  1089.                 0FFh    if bad value sent to routine
  1090. note 1) DOS 3.3 also sets CMOS clock
  1091.      2) CX and DX must contain a valid time in binary
  1092.  
  1093.  
  1094. Function  2Eh  Set/Reset Verify Switch
  1095.      Set verify flag                                                     
  1096. entry   AH      2Eh
  1097.         AL      00      to turn verify off (default)
  1098.                 01      to turn verify on
  1099. return  none
  1100. note 1) This is the call invoked by the DOS VERIFY command
  1101.      2) Setting of the verify switch can be obtained by calling call 54h
  1102.      3) This call is not supported on network drives
  1103.      4) DOS checks this flag each time it accesses a disk
  1104.  
  1105.  
  1106. Function  2Fh  Get Disk Transfer Address (DTA)
  1107.      Returns current disk transfer address used by all DOS read/write operations
  1108. entry   AH      2Fh
  1109. return  ES:BX   address of DTA
  1110. note 1) The DTA is set by function call 1Ah
  1111.      2) Default DTA address is a 128 byte buffer at offset 80h in that program's
  1112.         Program Segment Prefix
  1113.  
  1114.  
  1115. Function  30h  Get DOS Version Number
  1116.      Return DOS version and/or user number
  1117. entry   AH      30h
  1118. return  AH      minor version number  (i.e., DOS 2.10 returns AX = 0A02h)
  1119.         AL      major version number
  1120.         BH      OEM ID number
  1121.                 00h     IBM
  1122.                 16h     DEC    (others not known)
  1123.         BL:CX   24-bit user serial number
  1124. note 1) If AL returns a major version number of zero, the DOS version is 
  1125.         below 1.28 for MSDOS and below 2.00 for PCDOS.
  1126.      2) IBM PC-DOS always returns 0000h in BX and CX. 
  1127.      3) OS/2 v1.0 Compatibility Box returns a value of 10 for major version.
  1128.      4) Due to the OS/2 return and the fact that some European versions of DOS
  1129.         carry higher version numbers than IBM's DOS, utilities which check
  1130.         for a DOS version should not abort if a higher version than required
  1131.         is found unless some specific problems are known.
  1132.  
  1133.  
  1134. Function  31h  Terminate Process and Stay Resident
  1135.      KEEP, or TSR
  1136. entry   AH      31h
  1137.  
  1138.         AL      exit code
  1139.         DX      program memory requirement in 16 byte paragraphs
  1140. return  AX      return code (retrieveable by function 4Dh)
  1141. note 1) Files opened by the application are not closed when this call is made
  1142.      2) Memory can be used more efficiently if the block containing the copy of
  1143.         the DOS environment is deallocated before terminating. This can be done
  1144.         by loading ES with the segment contained in 2Ch of the PSP and issuing
  1145.         function call 49h (Free Allocated Memory).
  1146.      3) Unlike int 27h, more than 64k may be made resident with this call
  1147.      
  1148.  
  1149. Function  32h  Read DOS Disk Block
  1150.  *   Retrieve the pointer to the drive parameter block for a drive 
  1151. entry   AH      32h
  1152.         DL      drive (0=default, 1=A:, etc.). 
  1153. return  AL      00h     if drive is valid
  1154.                 0FFh    if drive is not valid
  1155.         DS:BX   pointer to DOS Drive Parameter Table. Format of block:
  1156.                 Bytes   Type        Value
  1157.                 00h     byte    Drive: 0=A:, 1=B:, etc.
  1158.                 01h     byte    Unit within drive (0, 1, 2, etc.)
  1159.                 02h-03h word    Bytes per sector
  1160.                 04h     byte    Sectors per cluster - 1
  1161.                 05h     byte    Cluster to sector shift (i.e., how far to shift-
  1162.                                 left the bytes/sector to get bytes/cluster)
  1163.                 06h-07h word    Number of reserved (boot) sectors
  1164.                 08h     byte    Number of FATs
  1165.                 09h-0Ah word    Number of root directory entries
  1166.                 0Bh-0Ch word    Sector # of 1st data. Should be same as # of 
  1167.                                 sectors/track.
  1168.                 0Dh-0Eh word    # of clusters + 1 (=last cluster #)
  1169.                 0Fh     byte    Sectors for FAT
  1170.                 10h-11h word    First sector of root directory
  1171.                 12h-15h dword   Address of device driver header for this drive
  1172.                 16h     byte    Media Descriptor Byte for this drive
  1173.                 17h     byte    0FFh indicates block must be rebuilt
  1174.                                 (DOS 3.x) 00h indicates block device has 
  1175.                                 been accessed
  1176.                 18h-1Bh dword   address of next DOS Disk Block (0FFFFh means 
  1177.                                 last in chain)
  1178.                 22h     byte    Current Working Directory (2.0 only) (64 bytes)
  1179. note 1) Use [BX+0D] to find no. of clusters (>1000H, 16-bit FAT; if not, 12-bit
  1180.         (exact dividing line is probably a little below 1000h to allow for
  1181.         bad sectors, EOF markers, etc.)
  1182.      2) Short article by C.Petzold, PC Magazine  Vol.5,no.8, and the article
  1183.         "Finding Disk Parameters" in the May 1986 issue of PC Tech Journal.
  1184.      3) This call is mostly supported in OS/2 1.0's DOS Compatibility Box. The
  1185.         dword at 12h will not return the address of the next device driver when
  1186.         in the Compatibility Box.
  1187.      4) used by CHKDSK
  1188.  
  1189.  
  1190. Function  33h  Control-Break Check
  1191.      Get or set control-break checking at CON
  1192. entry   AH      33h
  1193.         AL      00h     to test for break checking
  1194.                 01h     to set break checking
  1195.                         DL      00h     to disable break checking
  1196.                                 01h     to enable break checking
  1197.                 02h     internal, called by PRINT.COM (DOS 3.1)
  1198.                 03h     unknown
  1199.                 04h     unknown
  1200.                 05h     boot drive (DOS 4.0+)
  1201. return  DL      00h     if break=off 
  1202.                 01h     if break=on
  1203.                 (if AL=05h) boot drive, A=1, B=2, etc)
  1204.         AL      0FFh    error
  1205.  
  1206.  
  1207. Function  34h  Return INDOS Flag
  1208.  *   Returns ES:BX pointing to Critical Section Flag, byte indicating whether 
  1209.      it is safe to interrupt DOS.
  1210. entry   AH      34h
  1211. return  ES:BX   points to DOS "critical section flag"
  1212. note 1) If byte is 0, it is safe to interrupt DOS. This was mentioned in some
  1213.         documentation by Microsoft on a TSR standard, and PC Magazine reports
  1214.         it functions reliably under DOS versions 2.0 through 3.3. Chris 
  1215.         Dunford (of CED fame) and a number of anonymous messages on the BBSs
  1216.         indicate it may not be totally reliable.
  1217.      2) The byte at ES:BX+1 is used by the Print program for this same purpose,
  1218.         so it's probably safer to check the WORD at ES:BX.
  1219.      3) Reportedly, examination of DOS 2.10 code in this area indicates that the
  1220.         byte immediately following this "critical section flag" must be 00h to
  1221.         permit the PRINT.COM interrupt to be called. For DOS 3.0 and 3.1 (except
  1222.         Compaq DOS 3.0), the byte before the "critical section flag" must be
  1223.         zero; for Compaq DOS 3.0, the byte 01AAh before it must be zero.
  1224.      4) In DOS 3.10 this reportedly changed to word value, with preceding byte.
  1225.      5) This call is supported in OS/2 1.0's DOS Compatibility Box
  1226.      6) Gordon Letwin of Microsoft discussed this call on ARPAnet in 1984. He
  1227.         stated:
  1228.         a) this is not supported under any version of the DOS
  1229.         b) it usually works under DOS 2, but there may be circumstances
  1230.            when it doesn't (general disclaimer, don't know of a specific
  1231.            circumstance)
  1232.         c) it will usually not work under DOS 3 and DOS 3.1; the DOS is
  1233.            considerably restructured and this flag takes on additional
  1234.            meanings and uses
  1235.         d) it will fail catastrophically under DOS 4.0 and forward.
  1236.            Obviously this information is incorrect since the call works fine
  1237.            through DOS 3.3. Microsoft glasnost?
  1238.  
  1239.  
  1240. Function  35h  Get Vector
  1241.      Get interrupt vector 
  1242. entry   AH      35h
  1243.         AL      interrupt number (hexadecimal)
  1244. return  ES:BX   address of interrupt vector
  1245. note    Use function call 25h to set the interrupt vectors
  1246.  
  1247.  
  1248. Function  36h  Get Disk Free Space
  1249.      get information on specified drive
  1250. entry   AH      36h
  1251.         DL      drive number (0=default, 1=A:, 2=B:, etc)
  1252. return  AX      number of sectors per cluster 
  1253.                 0FFFFh means drive specified in DL is invalid
  1254.         BX      number of availible clusters
  1255.         CX      bytes per sector
  1256.         DX      clusters per drive
  1257. note 1) Mult AX * CX * BX for free space on disk
  1258.      2) Mult AX * CX * DX for total disk space
  1259.      3) Function 36h returns an incorrect value after an ASSIGN command. Prior 
  1260.         to ASSIGN, the DX register contains 0943h on return, which is the free
  1261.         space in clusters on the HC diskette. After ASSIGN, even with no 
  1262.         parameters, 0901h is returned in the DX register; this is an incorrect 
  1263.         value. Similar results occur with DD diskettes on a PC-XT or a PC-AT.
  1264.         This occurs only when the disk is not the default drive. Results are as
  1265.         expected when the drive is the default drive. Therefore, the 
  1266.         circumvention is to make the desired drive the default drive prior to 
  1267.         issuing this function call.
  1268.      4) Int 21h, function call 36h returns an incorrect value after an ASSIGN 
  1269.         command. Prior to ASSIGN, the DX register contains 0943h on return, 
  1270.         which is the free space in clusters on the HC diskette. After ASSIGN, 
  1271.         even with no parameters, 0901h is returned in the DX register; this is 
  1272.         an incorrect value. Similar results occur with DD diskettes on a PC-XT 
  1273.         or a PC-AT. This occurs only when the disk is not the default drive.
  1274.         Results are as expected when the drive is the default drive. Therefore,
  1275.         the circumvention is to make the desired drive the default drive prior 
  1276.         to issuing this function call.
  1277.      5) This function supercedes functions 1Bh and 1Ch.
  1278.  
  1279.  
  1280. Function  37h  SWITCHAR / AVAILDEV
  1281.  *   Get/set option marking character (is usually "/"), and device type
  1282. entry   AH      37h
  1283.         AL      00h     read switch character (returns current character in DL)
  1284.                 01h     set character in DL as new switch character
  1285.       (DOS 2.x) 02h     read device availability (as set by function AL=3) into
  1286.                         DL. A 0 means devices that devices must be accessed in 
  1287.                         file I/O calls by /dev/device. A non-zero value means 
  1288.                         that devices are accessible at every level of the 
  1289.                         directory tree (e.g., PRN is the printer and not a file 
  1290.                         PRN).
  1291.                         AL=2 to return flag in DL, AL=3 to set from DL (0 = set,
  1292.                         1 = not set).
  1293.       (DOS 2.x) 03h     get device availability, where:
  1294.         DL      00h     means /dev/ must precede device names
  1295.                 01h     means /dev/ need not precede device names
  1296. return  DL      switch character (if AL=0 or 1)
  1297.                 device availability flag (if AL=2 or 3)
  1298.         AL      0FFh    the value in AL was not in the range 0-3.
  1299. note 1) Functions 2 & 3 appear not to be implemented for DOS 3.x.
  1300.      2) It is documented on page 4.324 of the MS-DOS (version 2) Programmer's
  1301.         Utility Pack (Microsoft - published by Zenith).  
  1302.      3) Works on all versions of IBM PC-DOS from 2.0 through 3.3.1.
  1303.      4) The SWITCHAR is the character used for "switches" in DOS command 
  1304.         arguments (defaults to '/', as in "DIR/P"). '-' is popular to make a 
  1305.         system look more like UNIX; if the SWITCHAR is anything other than '/',
  1306.         then '/' may be used instead of '\' for pathnames 
  1307.      5) Ignored by XCOPY, PKARC, LIST
  1308.      6) SWITCHAR may not be set to any character used in a filename
  1309.      7) In DOS 3.x you can still read the "AVAILDEV" byte with subfunction 02h 
  1310.         but it always returns 0FFh even if you try to change it to 0 with
  1311.         subfunction 03h.
  1312.      8) AVAILDEV=0 means that devices must be referenced in an imaginary
  1313.         subdirectory "\dev" (similar to UNIX's /dev/*); a filename "PRN.DAT"
  1314.         can be created on disk and manipulated like any other. If AVAILDEV != 0
  1315.         then device names are recognized anywhere (this is the default):
  1316.         "PRN.DAT" is synonymous with "PRN:". 
  1317.      9) These functions reportedly are not supported in the same fashion in 
  1318.         various implementations of DOS. 
  1319.     10) used by DOS 3.3 CHKDSK, BASIC, DEBUG
  1320.  
  1321.  
  1322. Function  38h   Return Country Dependent Information
  1323.                 (PCDOS 2.0, 2.1, MSDOS 2.00 only)
  1324. entry   AH      38h
  1325.         AL      function code  (must be 0 in DOS 2.x)
  1326.         DS:DX   pointer to 32 byte memory buffer for returned information
  1327. return  CF      set on error
  1328.                 AX      error code (02h)
  1329.         BX      country code
  1330.         DS:DX   pointer to buffer filled with country information:
  1331.                 bytes 0,1       date/time format
  1332.                                 0       USA standard       H:M:S   M/D/Y
  1333.                                 1       European standard  H:M:S   D/M/Y
  1334.                                 2       Japanese standard  H:M:S   D:M:Y
  1335.                 byte2   ASCIIZ string currency symbol
  1336.                 byte3   zeroes
  1337.                 byte4   ASCIIZ string thousands separator
  1338.                 byte5   zeroes
  1339.                 byte6   ASCIIZ string decimal separator
  1340.                 byte7   zeroes
  1341.                 bytes 8,1Fh  24 bytes   reserved
  1342.  
  1343.  
  1344. Function  38h   Get Country Dependent Information
  1345.                 (PCDOS 3.x+, MSDOS 2.01+)
  1346. entry   AH      38h
  1347.         AL      function code
  1348.                 00h     to get current country information
  1349.                 01h-0FEh country code to get information for, for countries
  1350.                         with codes less than 255
  1351.                 0FFh    to get country information for countries with a code
  1352.                         greater than 255
  1353.                         BX      16 bit country code if AL=0FFh
  1354.         DS:DX   pointer to the memory buffer where the data will be returned
  1355.                 DX      0FFFFh if setting country code rather than getting info
  1356. return  CF      0 (clear) function completed
  1357.                 1 (set) error
  1358.                    AX   error code
  1359.                         02h     invalid country code (no table for it)
  1360.         (if DX <> 0FFFFh)
  1361.         BX      country code (usually international telephone code)
  1362.         DS:DX   pointer to country data buffer
  1363.           bytes 0,1     date/time format
  1364.                         0       USA standard       H:M:S   M/D/Y
  1365.                         1       European standard  H:M:S   D/M/Y
  1366.                         2       Japanese standard  H:M:S   D:M:Y
  1367.           bytes 2-6     currency symbol null terminated
  1368.           byte  07h     thousands separator null terminated
  1369.           byte  08h     zeroes
  1370.           byte  09h     decimal separator null terminated
  1371.           byte  0Ah     zeroes
  1372.           byte  0Bh     date separator null terminated
  1373.           byte  0Ch     zeroes
  1374.           byte  0Dh     time separator null terminated
  1375.           byte  0Eh     zeroes
  1376.           byte  0Fh     bit field currency format
  1377.                         bit 0 = 0  if currency symbol precedes the value
  1378.                                 1  if currency symbol is after the value
  1379.                         bit 1 = 0  no spaces between value and currency symbol
  1380.                                 1  one space between value and currency symbol
  1381.                         bit 2 = 1  set if currency symbol replaces decimal pt
  1382.                         bits 3-7   not defined by Microsoft
  1383.           byte  10h     number of significant decimal digits in currency
  1384.                         (number of places to right of decimal point)
  1385.           byte  11h     time format
  1386.                         bit 0 = 0       12 hour clock
  1387.                                 1       24 hour clock
  1388.                         bits 1-7 unknown, probably not used
  1389.           bytes 12h-15h address of case map routine (FAR CALL, AL = char)
  1390.                         entry   AL  ASCII code of character to be converted to 
  1391.                                     uppercase
  1392.                         return  AL  ASCII code of the uppercase input character
  1393.           byte  16h     data-list separator character
  1394.           byte  17h     zeroes
  1395.           bytes 18h-21h 5 words reserved
  1396. note 1) When an alternate keyboard handler is invoked, the keyboard routine is 
  1397.         loaded into user memory starting at the lowest portion of availible 
  1398.         user memory. The BIOS interrupt vector that services the keyboard is
  1399.         redirected to the memory area where the new routine resides. Each new
  1400.         routine takes up about 1.6K of memory and has lookup tables that return
  1401.         values unique to each language. (KEYBxx in the DOS book)
  1402.          Once the keyboard interrupt vector is changed by the DOS keyboard
  1403.         routine, the new routine services all calls unless the system is 
  1404.         returned to the US format by the ctrl-alt-F1 keystroke combination. This
  1405.         does not change the interrupt vector back to the BIOS location; it
  1406.         merely passes the table lookup to the ROM locations. 
  1407.      2) Ctrl-Alt-F1 will only change systems with US ROMS to the US layout.
  1408.         Some systems are delivered with non-US keyboard handler routines in ROM
  1409.      3) Case mapping call: the segment/offset of a FAR procedure that performs 
  1410.         country-specific lower-to-upper case mapping on ASCII characters 80h to
  1411.         0FFh. It is called with the character to be mapped in AL. If there is
  1412.         an uppercase code for the letter, it is returned in AL, if there is no
  1413.         code or the function was called with a value of less than 80h AL is
  1414.         returned unchanged.
  1415.      4) This call is fully implemented in MS-DOS version 2.01 and higher. It
  1416.         is in version 2.00 but not fully implemented (according to Microsoft)
  1417.  
  1418.  
  1419. Function  38h   Set Country Dependent Information
  1420. entry   AH      38h
  1421.         AL      code    country code to set information for, for countries
  1422.                         with codes less than 255
  1423.                 0FFh    to set country information for countries with a code
  1424.                         greater than 255
  1425.         BX      16 bit country code if AL=0FFh
  1426.         DX      0FFFFh
  1427. return  CF      clear   successful
  1428.                 set     if error
  1429.                         AX      error code (02h)
  1430.  
  1431.  
  1432. Function  39h   Create Subdirectory (MKDIR)
  1433.                 Makes a subdirectory along the indicated path
  1434. entry   AH      39h
  1435.         DS:DX   address of ASCIIZ pathname string
  1436. return  flag CF 0       successful
  1437.                 1       error
  1438.                         AX      error code if any  (3, 5) 
  1439. note 1) The ASCIIZ string may contain drive and subdirectory.
  1440.      2) Drive may be any valid drive (not nescessarily current drive)
  1441.      3) The pathname cannot exceed 64 characters
  1442.  
  1443.  
  1444. Function  3Ah   Remove Subdirectory  (RMDIR)
  1445. entry   AH      3Ah
  1446.         DS:DX   address of ASCIIZ pathname string
  1447. return  CF      clear     successful
  1448.                 set       AX      error code if any  (3, 5, 16)
  1449. note 1) The ASCIIZ string may contain drive and subdirectory.
  1450.      2) Drive may be any valid drive (not nescessarily current drive)
  1451.      3) The pathname cannot exceed 64 characters
  1452.  
  1453.  
  1454. Function  3Bh   Change Current Directory  (CHDIR)
  1455. entry   AH      3Bh
  1456.         DS:DX   address of ASCIIZ string
  1457. return  flag CF 0       successful
  1458.                 1       error
  1459.         AX      error code if any (3)
  1460. note 1) The pathname cannot exceed 64 characters
  1461.      2) The ASCIIZ string may contain drive and subdirectory.
  1462.      3) Drive may be any valid drive (not nescessarily current drive)
  1463.  
  1464.  
  1465. Function  3Ch   Create A File (CREAT)
  1466.                 Create a file with handle 
  1467. entry   AH      3Ch
  1468.         CX      attributes for file
  1469.                 00h     normal
  1470.                 01h     read only
  1471.                 02h     hidden
  1472.                 03h     system
  1473.         DS:DX   address of ASCIIZ filename string
  1474. return  flag CF 0       successful creation
  1475.                 1       error
  1476.         AX      16 bit file handle
  1477.                 or error code  (3, 4, 5)
  1478. note 1) The ASCIIZ string may contain drive and subdirectory.
  1479.      2) Drive may be any valid drive (not nescessarily current drive)
  1480.      3) If the volume label or subdirectory bits are set in CX, they are ignored
  1481.      4) The file is opened in read/write mode
  1482.      5) If the file does not exist, it is created. If one of the same name 
  1483.         exists, it is truncated to a length of 0.
  1484.      6) Good practice is to attempt to open a file with fn 3Dh and jump to an
  1485.         error routine if successful, create file if 3Dh fails. That way an
  1486.         existing file will not be truncated and overwritten.
  1487.  
  1488.  
  1489. Function  3Dh   Open A File
  1490.                 Open disk file with handle 
  1491. entry   AH      3Dh
  1492.         AL      access code byte
  1493. (DOS 2.x)       bits 0-2  file attribute
  1494.                 000     read only
  1495.                 001     write only
  1496.                 010     read/write
  1497.                 bits 3-7 should be set to zero
  1498. (DOS 3.x)       bits 0-2  file attribute
  1499.                 000     read only
  1500.                 001     write only
  1501.                 010     read/write
  1502.                 bit 3   reserved
  1503.                 0       should be set to zero
  1504.                 bits 4-6 sharing mode (network)
  1505.                 000     compatibility mode (the way FCBs open files)
  1506.                 001     read/write access denied (exclusive)
  1507.                 010     write access denied
  1508.                 011     read access denied
  1509.                 100     full access permitted
  1510.                 bit 7   inheritance flag
  1511.                 0       file inherited by child process
  1512.                 1       file private to child process
  1513.         DS:DX   address of ASCIIZ pathname string
  1514. return  flag CF set on error
  1515.                 AX      error code
  1516.                 1       error
  1517.         AX      16 bit file handle
  1518.                 or error code (1, 2, 4, 5, 0Ch)
  1519. note 1) Opens any normal, system, or hidden file
  1520.      2) Files that end in a colon are not opened
  1521.      3) The rear/write pointer is set at the first byte of the file and the
  1522.         record size of the file is 1 byte (the read/write pointer can be changed
  1523.         through function call 42h). The returned file handle must be used for 
  1524.         all subsequent input and output to the file. 
  1525.      4) If the file handle was inherited from a parent process or was 
  1526.         duplicated by DUP or FORCEDUP, all sharing and access restrictions are
  1527.         also inherited.
  1528.      5) A file sharing error (error 1) causes an int 24h to execute with an 
  1529.         error code of 2
  1530.  
  1531.  
  1532. Function  3Eh   Close A File Handle 
  1533.                 Close a file and release handle for reuse
  1534. entry   AH      3Eh
  1535.         BX      file handle
  1536. return  flag CF 0       successful close
  1537.                 1       error
  1538.         AX      error code if error (6)
  1539. note 1) When executed, the file is closed, the directory is updated, and all
  1540.         buffers for that file are flushed. If the file was changed, the time 
  1541.         and date stamps are changed to current
  1542.      2) If called with the handle 00000, it will close STDIN (normally the 
  1543.         keyboard).
  1544.  
  1545.  
  1546. Function  3Fh   Read From A File Or Device
  1547.                 Read from file with handle 
  1548. entry   AH      3Fh
  1549.         BX      file handle
  1550.         CX      number of bytes to read
  1551.         DS:DX   address of buffer
  1552. return  flag CF 0       successful read
  1553.                 1       error
  1554.         AX      0       pointer was already at end of file
  1555.                         or number of bytes read
  1556.                         or error code (5, 6)
  1557. note 1) This function attempts to transfer the number of bytes specified in CX
  1558.         to a buffer location. It is not guaranteed that all bytes will be read.
  1559.         If AX < CX a partial record was read.
  1560.      2) If performed from STDIN (file handle 0000), the input can be redirected
  1561.      3) If used to read the keyboard, it will only read to the first CR
  1562.      4) The file pointer is incremented to the last byte read.
  1563.  
  1564.  
  1565. Function  40h   Write To A File Or Device
  1566.                 Write to file with handle 
  1567. entry   AH      40h
  1568.         BX      file handle
  1569.         CX      number of bytes to write
  1570.         DS:DX   address of buffer
  1571. return  flag CF 0       successful write
  1572.                 1       error
  1573.         AX      number of bytes written
  1574.                 or error code  (5, 6)
  1575. note 1) This call attempts to transfer the number of bytes indicated in CX
  1576.         from a buffer to a file. If CX and AX do not match after the write,
  1577.         an error has taken place; however no error code will be returned for
  1578.         this problem. This is usually caused by a full disk.
  1579.      2) If the write is performed to STDOUT (handle 0001), it may be redirected
  1580.      3) To truncate the file at the current position of the file pointer, set
  1581.         the number of bytes in CX to zero before calling int 21h. The pointer
  1582.         can be moved to any desired position with function 42h.
  1583.      4) This function will not write to a file or device marked read-only.
  1584.      5) May also be used to display strings to CON instead of fn 09h. This
  1585.         function will write CX bytes and stop; fn 09h will continue to write
  1586.         until a $ character is found.
  1587.      6) This is the call that DOS actually uses to write to the screen in DOS
  1588.         2.x and above.
  1589.  
  1590.  
  1591. Function  41h   Delete A File From A Specified Subdirectory  (UNLINK)
  1592. entry   AH      41h
  1593.         DS:DX   pointer to ASCIIZ filespec to delete
  1594. return  CF      0       successful
  1595.                 1       error
  1596.                 AX      error code if any  (2, 5)
  1597. note 1) This function will not work on a file marked read-only
  1598.      2) Wildcards are not accepted
  1599.  
  1600.  
  1601. Function  42h   Move a File Read/Write Pointer  (LSEEK)
  1602. entry   AH      42h
  1603.         AL      method code 
  1604.                 00h     offset from beginning of file
  1605.                 01h     offset from present location
  1606.                 02h     offset from end of file
  1607.         BX      file handle
  1608.         CX      most significant half of offset
  1609.         DX      least significant half of offset
  1610. return  AX      low offset of new file pointer
  1611.         DX      high offset of new file pointer
  1612.         CF      0       successful move
  1613.                 1       error
  1614.                 AX      error code (1, 6)
  1615. note 1) If pointer is at end of file, reflects file size in bytes.
  1616.      2) The value in DX:AX is the absolute 32 bit byte offset from the beginning
  1617.         of the file
  1618.  
  1619.  
  1620. Function   43h  Get/Set file attributes  (CHMOD)
  1621. entry   AH      43h
  1622.         AL      00h     get file attributes
  1623.                 01h     set file attributes
  1624.                 CX      file attributes to set
  1625.                     bit 0       read only
  1626.                         1       hidden file
  1627.                         2       system file
  1628.                         3       volume label
  1629.                         4       subdirectory
  1630.                         5       written since backup
  1631.         DS:DX   pointer to full ASCIIZ file name
  1632. return  CF      set if error
  1633.         AX      error code  (1, 2, 3, 5)
  1634.         CX      file attributes on get
  1635.                 attributes:
  1636.                 01h     read only
  1637.                 02h     hidden
  1638.                 04h     system
  1639.                 0FFh    archive
  1640. note 1) This call will not change the volume label or directory bits
  1641.  
  1642.  
  1643. Function  44h   I/O Control for Devices (IOCTL)
  1644.                 Get or Set Device Information
  1645. entry   AH      44h
  1646.         AL      00h     Get Device Information (from DX)
  1647.                         BX      file or device handle
  1648.                         return  DX      device info
  1649.                                         If bit 7 set: (character device)
  1650.                                            bit 0: console input device
  1651.                                                1: console output device
  1652.                                                2: NUL device
  1653.                                                3: CLOCK$ device
  1654.                                                4: device is special
  1655.                                                5: binary (raw) mode
  1656.                                                6: not EOF
  1657.                                               12: network device (DOS 3.x)
  1658.                                               14: can process IOCTL control
  1659.                                                   strings (func 2-5)
  1660.                                         If bit 7 clear: (file)
  1661.                                            bits 0-5: block device number
  1662.                                                 6: file has not been written
  1663.                                                12: Network device (DOS 3.x)
  1664.                                                15: file is remote (DOS 3.x)
  1665.                 01h     Set Device Information (DH must be zero for this call)
  1666.                         DX bits: 
  1667.                         0    1  console input device
  1668.                         1    1  console output device
  1669.                         2    1  null device
  1670.                         3    1  clock device
  1671.                         4    1  reserved
  1672.                         5    0  binary mode - don't check for control chars
  1673.                              1  cooked mode - check for control chars
  1674.                         6    0  EOF - End Of File on input
  1675.                         7       device is character device if set, if not, EOF
  1676.                                 is 0 if channel has been written, bits 0-5 are 
  1677.                                 block device number
  1678.                         12      network device
  1679.                         14   1  can process control strings (AL 2-5, can only be
  1680.                                 read, cannot be set)
  1681.                         15   n  reserved
  1682.                 02h     Read CX bytes to device in DS:DX from BX control chan
  1683.                 03h     Write Device Control String
  1684.                         BX      device handle
  1685.                         CX      number of bytes to write
  1686.                         DS:DX   pointer to buffer
  1687.                         return  AX      number of bytes written
  1688.                 04h     Read From Block Device (drive number in BL)
  1689.                         BL      drive number (0=default)
  1690.                         CX      number of bytes to read
  1691.                         DS:DX   pointer to buffer
  1692.                         return  AX      number of bytes read
  1693.                 05h     Write to Block Device  (drive number in BL)
  1694.                         AX      number of bytes transfered
  1695.                 06h     Get Input Handle Status
  1696.                         BX      file or device handle
  1697.                         return  AL      0FFh    device ready
  1698.                                         00h     device not ready
  1699.                 07h     Get Output Handle Status
  1700.                         return  AL      00h     not ready
  1701.                                         0FFh    ready
  1702.                          note: for DOS 2.x, files are always ready for output
  1703.                 08h     Removable Media Bit (DOS 3.x+)
  1704.                         return  AX      00h     device is removable
  1705.                                         01h     device is nonremovable
  1706.                                         0Fh     invalid drive specification
  1707.                 09h     Test whether Local or Network Device in BL (DOS 3.x+)
  1708.                         BL      drive number (0=default)
  1709.                         return  DX      attribute word, bit 12 set if device is
  1710.                                         remote
  1711.                 0Ah     Is Handle in BX Local or Remote? (DOS 3.x+)
  1712.                         BX     file handle
  1713.                         return DX (attribute word) bit 15 set if file is remote
  1714.                 0Bh     Change Sharing Retry Count to DX (default=3), (DOS 3.x+)
  1715.                         CX     delay (default=1)
  1716.                         DX     retry count (default=3)
  1717.                 0Ch     General IOCTL (DOS 3.3 [3.2?]) allows a device driver to
  1718.                         prepare, select, refresh, and query Code Pages
  1719.                 0Dh     Block Device Request (DOS 3.3+)
  1720.                         BL      drive number (0=default)
  1721.                         CH      major subfunction
  1722.                         CL      minor subfunction
  1723.                                 40h set device parameters
  1724.                                 41h write logical device track
  1725.                                 42h format and verify logical device track
  1726.                                 60h get device parameters
  1727.                                 61h read logical device track
  1728.                                 62h verify logical device track
  1729.                         DS:DX   pointer to parameter block
  1730.                 0Eh     Get Logical Device (DOS 3.3+)
  1731.                         BL      drive number (0=default)
  1732.                         return  AL=0 block device has only one logical drive
  1733.                                 assigned 1..n the last letter used to reference
  1734.                                 the device (1=A:,etc)
  1735.                 0Fh     Set Logical Device (DOS 3.3+)
  1736.         BL      drive number:  0=default, 1=A:, 2=B:, etc.
  1737.         BX      file handle
  1738.         CX      number of bytes to read or write
  1739.         DS:DX   data or buffer
  1740.         DX      data
  1741. return  AX      number of bytes transferred
  1742.                 or error code (call function 59h for extended error codes)
  1743.                 or status  00h     not ready
  1744.                            0FFh    ready
  1745.         CF      set if error
  1746.  
  1747.  
  1748. Function  45h   Duplicate a File Handle (DUP)
  1749. entry   AH      45h
  1750.         BX      file handle to duplicate
  1751. return  CF      clear   AX      duplicate handle
  1752.                 set     AX      error code  (4, 6)
  1753. note 1) If you move the pointed of one handle, the pointer of the other will 
  1754.         also be moved.
  1755.      2) The handle in BX must be open
  1756.           
  1757.  
  1758. Function  46h   Force Duplicate of a Handle (FORCEDUP or CDUP)
  1759.                 Forces handle in CX to refer to the same file at the same
  1760.                 position as BX
  1761. entry   AH      46h
  1762.         BX      existing file handle
  1763.         CX      new file handle
  1764. return  CF      clear   both handles now refer to existing file
  1765.                 set     error
  1766.                 AX      error code (4, 6)
  1767. note 1) If CX was an open file, it is closed first
  1768.      2) If you move the read/write pointer of either file, both will move
  1769.      3) The handle in BX must be open
  1770.  
  1771.               
  1772. Function  47h   Get Current Directory
  1773.                 Places full pathname of current directory/drive into a buffer
  1774. entry   AH      47h
  1775.         DL      drive (0=default, 1=A:, etc.)
  1776.         DS:SI   points to 64-byte buffer area
  1777. return  CF      clear   DS:DI   pointer to ASCIIZ pathname of current directory
  1778.                 set     AX      error code (0Fh)
  1779. note   String does not begin with a drive identifier or a backslash   
  1780.  
  1781.  
  1782. Function  48h   Allocate Memory
  1783.                 Allocates requested number of 16-byte paragraphs of memory
  1784. entry   AH      48h
  1785.         BX      number of 16-byte paragraphs desired
  1786. return  CF      clear   AX      segment address of allocated space
  1787.                         BX      maximum number paragraphs available
  1788.                 set     AX      error code (7, 8)
  1789. note    BX indicates maximum memory availible only if allocation fails
  1790.  
  1791.  
  1792. Function  49h   Free Allocated Memory
  1793.                 Frees specified memory blocks
  1794. entry   AH      49h
  1795.         ES      segment address of area to be freed
  1796. return  CF      clear   successful
  1797.                 set     AX      error code (7, 9)
  1798. note 1) This call is only valid when freeing memory obtained by function 48h.
  1799.      2) A program should not try to release memory not belonging to it.
  1800.  
  1801.  
  1802. Function  4Ah   Modify Allocated Memory Blocks (SETBLOCK)
  1803.                 Expand or shrink memory for a program
  1804. entry   AH      4AH
  1805.         BX      new size in 16 byte paragraphs
  1806.         ES      segment address of block to change
  1807. return  CF      clear   nothing
  1808.                 set     AX      error code (7, 8, 9)
  1809.                     or  BX      max number paragraphs available
  1810. note 1) Max number paragraphs availible is returned only if the call fails
  1811.      2) Memory can be expanded only if there is memory availible
  1812.  
  1813.  
  1814. Function  4Bh   Load or Execute a Program  (EXEC)
  1815. entry   AH      4Bh
  1816.         AL      00h     load and execute program. A PSP is built for the program
  1817.                         the ctrl-break and terminate addresses are set to the
  1818.                         new PSP.
  1819.                *01h     load but don't execute  (note 1)
  1820.                *01h     load but don't execute (internal, DOS 3.x & DESQview) 
  1821.                *02h     load but do not execute (internal, DOS 2.x only) 
  1822.                 03h     load overlay (do not create PSP, do not begin execution)
  1823.         DS:DX   points to the ASCIIZ string with the drive, path, and filename
  1824.                 to be loaded
  1825.         ES:BX   points to a parameter block for the load
  1826.                (AL=00h) word    segment address of environment string to be
  1827.                                 passed
  1828.                        dword    pointer to the command line to be placed at
  1829.                                 PSP+80h
  1830.                        dword    pointer to default FCB to be passed at PSP+5Ch
  1831.                        dword    pointer to default FCB to be passed at PSP+6Ch
  1832.               (*AL=01h) word    segment of environment (0 = use current) 
  1833.                        dword    pointer to command line 
  1834.                        dword    pointer to FCB 1 
  1835.                        dword    pointer to FCB 2 
  1836.                        dword    will hold SS:SP on return 
  1837.                        dword    will hold program entry point (CS:IP) on return 
  1838.               (*AL=02h) word    segment of environment (0 = use current) 
  1839.                        dword    pointer to command line 
  1840.                        dword    pointer to FCB 1 
  1841.                        dword    pointer to FCB 2 
  1842.                (AL=03h) word    segment address where file will be loaded
  1843.                         word    relocation factor to be applied to the image
  1844. return  CF      set     error
  1845.                         AX      error code (1, 2, 8, 0Ah, 0Bh)
  1846. note 1) If you make this call with AL=1 the program will be loaded as if you 
  1847.         made the call with AL=0 except that the program will not be executed.
  1848.         Additionally, with AL=1 the stack segment and pointer along with the 
  1849.         program's CS:IP entry point are returned to the program which made the 
  1850.         4B01h call. These values are put in the four words at ES:BX+0Eh. On 
  1851.         entry to the call ES:BX points to the environment address, the command 
  1852.         line and the two default FCBs. This form of EXEC is used by DEBUG.COM.
  1853.      2) Application programs may invoke a secondary copy of the command 
  1854.         processor (normally COMMAND.COM) by using the EXEC function.  Your 
  1855.         program may pass a DOS command as a parameter that the secondary 
  1856.         command processor will execute as though it had been entered from the 
  1857.         standard input device.
  1858.         The procedure is:
  1859.          A. Assure that adequate free memory (17k for 2.x and 3.0, 23k for 3.1 
  1860.             up) exists to contain the second copy of the command processor and 
  1861.             the command it is to execute. This is accomplished by executing 
  1862.             function call 4Ah to shrink memory allocated to that of your current
  1863.             requirements. Next, execute function call 48h with BX=0FFFFh. This 
  1864.             returns the amount of memory availible.
  1865.         B. Build a parameter string for the secondary command processor in the 
  1866.            form:
  1867.                          1 byte   length of parameter string
  1868.                         xx bytes  parameter string
  1869.                          1 byte   0Dh (carriage return)
  1870.            For example, the assembly language statement below would build the 
  1871.            string to cause execution of the command FOO.EXE:
  1872.                               DB 19,"/C C:FOO",13
  1873.         C. Use the EXEC function call (4Bh), function value 0 to cause execution
  1874.            of the secondary copy of the command processor. (The drive, 
  1875.            directory, and name of the command processor can be gotten from the 
  1876.            COMSPEC variable in the DOS environment passed to you at PSP+2Ch.)
  1877.         D. Remember to set offset 2 of the EXEC control block to point to the 
  1878.            string built above.
  1879.      3) All open files of a process are duplicated in the newly created 
  1880.         process after an EXEC, except for files originally opened with the 
  1881.         inheritance bit set to 1.
  1882.      4) The environment is a copy of the original command processor's 
  1883.         environment. Changes to the EXECed environment are not passed back to
  1884.         the original. The environment is followed by a copy of the DS:DX 
  1885.         filename passed to the child process. A zero value will cause the 
  1886.         child process to inherit the environment of the calling process. The
  1887.         segment address of the environment is placed at offset 2Ch of the
  1888.         PSP of the program being invoked.
  1889.      5) This function uses the same resident part of COMMAND.COM, but makes a
  1890.         duplicate of the transient part. 
  1891.      6) How EXEC knows where to return to: Basically the vector for int 22h
  1892.         holds the terminate address for the current process. When a process 
  1893.         gets started, the previous contents of int 22h get tucked away in the 
  1894.         PSP for that process, then int 22h gets modified. So if Process A 
  1895.         EXECs process B, while Process B is running, the vector for int 22h 
  1896.         holds the address to return to in Process A, while the save location in
  1897.         Process B's PSP holds the address that process A will return to when
  1898.         *it* terminates. When Process B terminates by one of the usual legal 
  1899.         means, the contents of int 22h are (surmising) shoved onto the stack, 
  1900.         the old terminate vector contents are copied back to int 22h vector from
  1901.         Process B's PSP, then a RETF or equivalent is executed to return control
  1902.         to process A.
  1903.      7) To load an overlay file with 4B: first, don't de-allocate the memory
  1904.         that the overlay will load into. With the other 4Bh functions, the
  1905.         opposite is true--you have to free the memory first, with function 4Ah.
  1906.         Second, the "segment address where the file will be loaded" (first item
  1907.         in the parameter block for sub-function 03) should be a paragraph 
  1908.         boundary within your currently-allocated memory. Third, if the
  1909.         procedures within the overlay are FAR procs (while they execute, CS will
  1910.         be equal to the segment address of the overlay area), the relocation
  1911.         factor should be set to zero. On the other hand, if the CS register
  1912.         will be different from the overlay area's segment address, the
  1913.         relocation factor should be set to represent the difference. You
  1914.         determine where in memory the overlay file will load by using the
  1915.         segment address mentioned above. Overlay files are .EXEs (containing
  1916.         header, relocation table, and memory image).
  1917.      8) When function 00h returns, all registers are changed, including the
  1918.         stack. You must resore SS, SP, and any other required registers.
  1919.  
  1920.  
  1921. Function  4Ch   Terminate a Process (EXIT)
  1922.                 Quit with ERRORLEVEL exit code 
  1923. entry   AH      4Ch
  1924.         AL      exit code in AL when called, if any, is passed to next process
  1925. return  none
  1926. note 1) Control passes to DOS or calling program
  1927.      2) return code from AL can be retrieved by ERRORLEVEL or function 4Dh
  1928.      3) all files opened by this process are closed, buffers are flushed, and 
  1929.         the disk directory is updated
  1930.      4) Restores Terminate vector from PSP:000Ah
  1931.                  Ctrl-C vector from PSP:000Eh
  1932.                  Critical Error vector from PSP:0012h
  1933.  
  1934.  
  1935. Function  4Dh   Get Return Code of a Subprocess (WAIT)
  1936.                 Gets return code from functions 31h and 4Dh  (ERRORLEVEL)
  1937. entry   AH      4Dh
  1938. return  AL      exit code of subprogram (functions 31h or 4Ch)
  1939.         AH      circumstance which caused termination
  1940.                 00h     normal termination
  1941.                 01h     control-break
  1942.                 02h     critical device error
  1943.                 03h     terminate and stay resident (function 31h)
  1944. note    The exit code is only returned once
  1945.                                          
  1946.  
  1947. Function  4Eh   Find First Matching File (FIND FIRST)
  1948. entry   AH      4Eh
  1949.         CX      search attributes
  1950.         DS:DX   pointer to ASCIIZ filename (with attributes)
  1951. return  CF      set     AX      error code (2, 12h)
  1952.                 clear   data block written at current DTA
  1953.                         format of block is:  (info from BIX)
  1954.   documented by Micro-  |00h   1 byte   attribute byte of search
  1955.   soft as "reserved for |01h   1 byte   drive letter for search
  1956.   DOS' use on subsquent |02h   11 bytes the search name used
  1957.   Find Next calls"      |0Ch   2 bytes  word value of last entry
  1958.   function 4Fh          |0Fh   4 bytes  dword pointer to this DTA
  1959.                         |13h   2 bytes  word directory start
  1960.                         | PC-DOS 3.10 (from INTERRUP.ARC)
  1961.                         |00h   1 byte   drive letter
  1962.                         |01h-0Bh    bytes  search template
  1963.                         |0Ch   1 byte   search attributes
  1964.                         | DOS 2.x (and DOS 3.x except 3.1?) (from INTERRUP.ARC)
  1965.                         |00h   1 byte   search attributes
  1966.                         |01h   1 byte   drive letter
  1967.                         |02h-0Ch bytes  search template
  1968.                         |0Dh-0Eh 2 bytes entry count within directory
  1969.                         |0Fh-12h   bytes reserved
  1970.                         |13h-14h 2 bytes cluster number of parent directory
  1971.                         
  1972.                          15h   1 byte   file attribute
  1973.                          16h   2 bytes  file time
  1974.                          18h   2 bytes  file date
  1975.                          1Ah   2 bytes  low word of file size
  1976.                          1Ch   2 bytes  high word of file size
  1977.                          1Eh  13 bytes  name and extension of file found, plus
  1978.                                         1 byte of 0s. All blanks are removed 
  1979.                                         from the name and extension, and if an 
  1980.                                         extension is present it is preceded by a
  1981.                                         period.
  1982. note 1) Will not find volume label
  1983.      2) This function does not support network operations
  1984.      3) Wildcards are allowed in the filespec
  1985.      4) If the attribute is zero, only ordinary files are found. If the volume 
  1986.         label bit is set, only volume labels will be found. Any other attribute
  1987.         will return that attribute and all normal files together.
  1988.      5) To look for everything except the volume label, set the hidden, system,
  1989.         and subdirectory bits all to 1
  1990.  
  1991.  
  1992. Function  4Fh   Find Next Matching File (FIND NEXT)
  1993.                 Find next ASCIIZ file
  1994. entry   AH      4Fh
  1995. return  CF      clear   data block written at current DTA
  1996.                 set     AX      error code (2, 12h)
  1997. note 1) If file found, DTA is formatted as in call 4Eh
  1998.      2) Volume label searches using 4Eh/4Fh reportedly aren't 100% reliable 
  1999.         under DOS 2.x. The calls sometime report there's a volume label and 
  2000.         point to a garbage DTA, and if the volume label is the only item they
  2001.         often won't find it
  2002.      3) This function does not support network operations
  2003.      4) Use of this call assumes that the original filespec contained wildcards
  2004.  
  2005.                                          
  2006. Function  50h   "Used Internally by DOS" - Set PSP
  2007.  *              Set new Program Segment Prefix (current Process ID)
  2008. entry   AH      50h
  2009.         BX      segment address of new PSP
  2010. return  none - swaps PSP's regarded as current by DOS
  2011. note 1) By putting the PSP segment value into BX and issuing call 50h DOS stores
  2012.         that value into a variable and uses that value whenever a file call is 
  2013.         made. 
  2014.      2) Note that in the PSP (or PDB) is a table of 20 (decimal) open file 
  2015.         handles. The table starts at offset 18h into the PSP. If there is an 
  2016.         0FFh in a byte then that handle is not in use. A number in one of the 
  2017.         bytes is an index into an internal FB table for that handle. For 
  2018.         instance the byte at offset 18h is for handle 0, at offset 19h handle 
  2019.         1, etc. up to 13h. If the high bit is set then the file associated by 
  2020.         the handle is not shared by child processes EXEC'd with call 4Bh.
  2021.      3) Function 50h is dangerous in background operations prior to DOS 3.x as 
  2022.         it uses the wrong stack for saving registers.  (same as functions 
  2023.         0..0Ch in DOS 2.x)
  2024.      4) Under DOS 2.x, this function cannot be invoked inside an int 28h handler
  2025.         without setting the Critical Error flag
  2026.      5) Open File information, etc. is stored in the PSP DOS views as current. 
  2027.         If a program (eg. a resident program) creates a need for a second PSP,
  2028.         then the second PSP should be set as current to make sure DOS closes 
  2029.         that as opposed to the first when the second application finishes.
  2030.      6) See PC Mag Vol.5, No 9, p.314 for discussion. 
  2031.      7) Used by DOS 3.3 PRINT & DEBUG, DesQview 2.01, Windows 1.03, SYMDEB
  2032.         from MASM 4.0
  2033.  
  2034.                                          
  2035. Function  51h    "Used Internally by DOS" - Get Program Segment Prefix
  2036.  *               Returns the PSP address of currently executing program
  2037. entry   AH      51h
  2038. return  BX      address of currently executing program
  2039.                 offset
  2040.                 00h     program exit point
  2041.                 02h     memory size in paragraphs
  2042.                 04h     unused (0)
  2043.                 05h     CP/M style entry point (far call to DOS)
  2044.                 0Ah     terminate address (old int 22h)
  2045.                 0Ch     terminate segment
  2046.                 0Eh     break address (old int 23h)
  2047.                 10h     break segment
  2048.                 12h     error address (old int 24h)
  2049.                 14h     error segment
  2050.                 16h     parent PSP segment
  2051.                 18h     DOS 2.0+ open files, 0FFh = unused
  2052.                 2Ch     DOS 2.0+ environment segment
  2053.                 2Eh     far ptr to process's SS:SP
  2054.                 32h     DOS 3.x max open files
  2055.                 34h     DOS 3.x openfile table address
  2056.                 36h     DOS 3.x openfile table segment
  2057.                 38h     unused by DOS versions <= 3.3
  2058.                 50h     DOS function dispatcher (FAR routine)
  2059.                 53h     unused
  2060.                 55h     FCB #1 extension
  2061.                 5Ch     FCB #1
  2062.                 6Ch     FCB #2
  2063.                 80h     command tail / default DTA buffer
  2064. note 1) Used in DOS 2.x, 3.x uses 62h
  2065.      2) Function 51h is dangerous in background operations prior to DOS 3.x as 
  2066.         it uses the wrong stack for saving registers.  (same as functions 
  2067.         0..0Ch in DOS 2.x)                                           
  2068.      3) 50h and 51h might be used if you have more than one process in a PC.
  2069.         For instance if you have a resident program that needs to open a file
  2070.         you could first call 51h to save the current id and then call 50h to set
  2071.         the ID to your PSP.
  2072.      4) Under DOS 2.x, this function cannot be invoked inside an int 28h handler
  2073.         without setting the Critical Error flag
  2074.      5) Used by DOS 3.3 PRINT, DEBUG
  2075.  
  2076.  
  2077. Function  52h   "Used Internally by DOS" - IN-VARS   
  2078.  *              Returns a pointer to a set of DOS data variables MCB chain,
  2079.                 pointer to first device driver and a pointer to disk parameter
  2080.                 blocks (first one)
  2081. entry   AH      52h
  2082. return  ES:BX   pointer to the DOS list of lists, for disk information. Does not
  2083.                 access the disk, so information in tables might be incorrect if
  2084.                 disk has been changed. Returns a pointer to the following array
  2085.                 of longword pointers:
  2086.                 Bytes   Value
  2087.                 -2h,-1h segment of first memory control block
  2088.                 00h-03h pointer to first DOS disk block (see function 36h)
  2089.                 04h-07h Pointer to list of DOS file tables
  2090.                         dword   pointer to next file table
  2091.                         word    number of files in this table
  2092.                                 35h bytes per file
  2093.                                 00h-01h number of file handles referring to
  2094.                                         this file
  2095.                                 02h-06h unknown
  2096.                                 07h-0Ah pointer to device driver header if
  2097.                                         character device; pointer to DOS Device
  2098.                                         Control Block if block device (see
  2099.                                         fn 32h for format)
  2100.                                 0Bh-1Fh unknown
  2101.                                 20h-2Ah filename in FCB format (no path, no
  2102.                                         period, blank-padded)
  2103.                                 2Bh-2Ch PSP segment of file's owner
  2104.                                 2Dh-30h unknown -  0 always
  2105.                                 31h-32h unknown
  2106.                                 33h-34h unknown
  2107.                 8h-0Bh  pointer to CLOCK$ device driver, whether installable or
  2108.                         resident
  2109.                 0Ch-0Fh pointer to actual CON: device driver, whether 
  2110.                         installable or resident
  2111.         (DOS 2.x)
  2112.                 10      number of logical drives in system
  2113.                 11-12   maximum bytes/block of any block device
  2114.                 13-16   unknown
  2115.                 17      beginning (not a pointer. The real beginning!) of NUL
  2116.                         device driver. This is the first device on DOS's linked
  2117.                         list of device drivers.
  2118.         (DOS 3.x)
  2119.                 10h-11h maximum bytes/block of any block device (0200h)
  2120.                 12h-15h pointer to first disk buffer
  2121.                 16h-19h partially undefined: Pointer to array of drive info:
  2122.                         51h bytes per drive, starting with A: ...
  2123.                         00h-3Fh current path as ASCIIZ, starting with 'x:\'
  2124.                         40h-43h unknown    zeros always
  2125.                         44h     unknown    flags? Usually 40h, except for
  2126.                                 entry after last valid entry = 00h
  2127.                         45h-48h pointer to DOS disk block for this drive
  2128.                         49h-4Ah unknown. Current track or block? 
  2129.                                 -1 if never accessed
  2130.                         4Bh-4Eh unknown  -1 always
  2131.                         4Fh-52h unknown   2 always
  2132.                 1Ah-1Dh pointer to FCB table (if CONFIG.SYS contains FCBS=)
  2133.                 1Eh-1Fh size of FCB table
  2134.                 20h     number of block devices
  2135.                 21h     value of LASTDRIVE command in CONFIG.SYS (default 5)
  2136.                 22h     beginning (not a pointer. The real beginning!) of NUL 
  2137.                         device driver. This is the first device on DOS's linked 
  2138.                         list of device drivers.
  2139. note 1) This call is not supported in OS/2 1.0's DOS Compatibility Box
  2140.      2) Used by DOS 4.0 MEM.EXE, DOS 3.3 ASSIGN.COM, PRINT.COM, SUBST.EXE
  2141.  
  2142.                                                                               
  2143. Function  53h   "Used Internally by DOS" - Translate BPB
  2144.  *              Translates BPB (BIOS Parameter Block, see below) into a DOS Disk
  2145.                 Block (see function call 32h).  
  2146. entry   AH      53h
  2147.         DS:SI   pointer to BPB 
  2148.         ES:BP   pointer to area for DOS Disk Block.
  2149.                 Layout of Disk Block:
  2150.                 bytes   value
  2151.                 00h-01h bytes per sector, get from DDB bytes 02h-03h.
  2152.                 02h     sectors per cluster, get from (DDB byte 4) + 1
  2153.                 03h-04h reserved sectors, get from DDB bytes 06h-07h
  2154.                 05h     number of FATs, get from DDB byte 08h
  2155.                 06h-07h number of root dir entries, get from DDB bytes 09h-0Ah
  2156.                 08h-09h total number of sectors, get from: 
  2157.                         ((DDB bytes 0Dh-0Eh) - 1) * (sectors per cluster (BPB 
  2158.                         byte 2)) + (DDB bytes 0Bh-0Ch)
  2159.                 0Ah     media descriptor byte, get from DDB byte 16h
  2160.                 0Bh-0Ch number of sectors per FAT, get from DDB byte 0Fh
  2161. return  unknown                          
  2162.  
  2163.  
  2164. Function  54h   Get Verify Setting
  2165.                 Get verify flag status
  2166. entry   AH      54h
  2167. return  AL      00h if flag off
  2168.                 01h if flag on
  2169. note    Flag can be set with function 2Eh
  2170.         
  2171.                                          
  2172. Function  55h   "Used Internally by DOS" - Create "Child" PSP
  2173.  *              Create PSP: similar to function 26h (which creates a new Program
  2174.                 Segment Prefix at segment in DX) except creates a "child" PSP
  2175.                 rather than copying the existing one.
  2176. entry   AH      55h
  2177.         DX      segment number at which to create new PSP.
  2178. return  unknown
  2179. note 1) This call is similar to call 26h which creates a PSP except that unlike
  2180.         call 26h the segment address of the parent process is obtained from the
  2181.         current process ID rather than from the CS value on the stack (from the
  2182.         INT 21h call). DX has the new PSP value and SI contains the value to be
  2183.         placed into PSP:2 (top of memory).
  2184.      2) Function 55 is merely a substitute for function 26h. It will copy the
  2185.         current PSP to the segment address DX with the addition that SI is
  2186.         assumed to hold the new memory top segment. This means that function 
  2187.         26h sets SI to the segment found in the current PSP and then calls
  2188.         function 55h. 
  2189.  
  2190.                                          
  2191. Function  56h   Rename a File
  2192. entry   AH      56h
  2193.         DS:DX   pointer to ASCIIZ old pathname
  2194.         ES:DI   pointer to ASCIIZ new pathname
  2195. return  CF      clear   successful rename
  2196.                 set     AX      error code (2, 3, 5, 11h)
  2197. note 1) Works with files in same drive only
  2198.      2) Global characters not allowed in filename
  2199.      3) The name of a file is its full pathname. The file's full pathname can
  2200.         be changed, while leaving the actual FILENAME.EXT unchanged. Changing
  2201.         the pathname allows the file to be "moved" from subdirectory to
  2202.         subdirectory on a logical drive without actually copying the file.
  2203.      4) DOS 3.x allows renaming of directories
  2204.  
  2205.  
  2206.