home *** CD-ROM | disk | FTP | other *** search
/ Emulator Universe CD / emulatoruniversecd1998.iso / MSX / OS / MSXDOS2.ZIP / DOS2PROG.PMA / DOS2PROG.DOC
Encoding:
Text File  |  1993-05-16  |  79.9 KB  |  2,353 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                   M S X -- D O S   v e r s i o n  2
  18.                   =================================
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.                   The advanced disk operating system
  32.  
  33.                          for MSX 2 computers
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.      CONTENTS                                   Page
  65.  
  66.  
  67. 1.   Introduction ...............................  3
  68. 2.   Transient Program Environment ..............  4
  69.     2.1   Entry from MSX-DOS ....................  4
  70.     2.2   Return to MSX-DOS .....................  4
  71.     2.3   Page Zero Usage .......................  5
  72.     2.4   BIOS Jump Table .......................  8
  73.     2.5   RAM Paging ............................  9
  74. 3.   MSX-DOS calls .............................. 11
  75.     3.1   Calling Conventions ................... 11
  76.     3.2   Devices and Character I/O ............. 12
  77.     3.3   File Handles .......................... 13
  78.     3.4   File Info Blocks ...................... 15
  79.     3.5   Environment Strings ................... 18
  80.     3.6   File Control Blocks ................... 20
  81. 4.   Screen Control Codes ....................... 22
  82. 5.   Mapper Support Routines .................... 24
  83.     5.1   Mapper Initialization ................. 24
  84.     5.2   Mapper Variables and Routines ......... 24
  85.     5.3   Using Mapper Routines ................. 26
  86.     5.4   Allocating and Freeing Segments ....... 27
  87.     5.5   Inter-Segment Read and Write .......... 28
  88.     5.6   Inter-Segment Calls ................... 29
  89.     5.7   Direct paging routines ................ 30
  90. 6.   Errors ..................................... 32
  91.     6.1   Disk Errors ........................... 33
  92.     6.2   MSX-DOS Function Errors ............... 35
  93.     6.3   Program Termination Errors ............ 40
  94.     6.4   Command Errors ........................ 41
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.      This document describes the interface to transient programs provided by MSX-DOS version 2.20.
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. 1.   INTRODUCTION
  112. =================
  113.  
  114.  
  115.  
  116.      This  manual  describes  the environment  which MSX-DOS  2 provides  for 
  117. transient  programs on MSX 2 computers. It is intended as a guide for writing 
  118. new programs to run under MSX-DOS 2 and also to assist in converting existing 
  119. CP/M and MSX-DOS 1 programs to take advantage of the advanced features.
  120.  
  121.      MSX-DOS 2  provides many enhancements to the standard CP/M and MSX-DOS 1 
  122. environment,  but  is  largely compatible  with existing  programs. The  main 
  123. features include:
  124.  
  125.           MS-DOS style tree structured directories
  126.           File handles
  127.           Environment Strings
  128.           Proper error handling
  129.  
  130.  
  131.      Many extra DOS calls are implemented, and these are accessed via the DOS 
  132. entry  jump at  address 5  (the 'BDOS' jump in CP/M). The descriptions of the 
  133. individual functions can be found in the MSX-DOS 2 Function Specification.
  134.  
  135.  
  136.  
  137.      Throughout this  manual, the  term MSX-DOS is used generally to refer to 
  138. MSX-DOS 2 unless otherwise stated.
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166. 2.   TRANSIENT PROGRAM ENVIRONMENT
  167. ==================================
  168.  
  169.  
  170.  
  171.      This  chapter describes  the environment in which transient programs are 
  172. executed under  MSX-DOS, including  entry and  exit to the program and memory 
  173. usage.
  174.  
  175.  
  176.  
  177.  
  178. 2.1   ENTRY FROM MSX-DOS
  179.  
  180.  
  181.      A  transient program  will be  loaded at address 0100h, the start of the 
  182. TPA (Transient Program Area), and is CALLed by MSX-DOS with the stack pointer 
  183. set to  the end  of the TPA. If the stack pointer points to that location, as 
  184. much RAM as possible can be used as the stack. If it is undesirable, then the 
  185. transient program must set up its own stack in the TPA.
  186.  
  187.  
  188.      The  contents of  the Z-80 registers when a transient program is entered 
  189. are undefined. The first 256 bytes of RAM starting at the address 0 will have 
  190. been set up with various parameters and code as described in section 2.3.
  191.  
  192.  
  193.  
  194.      Interrupts  are enabled  when a  transient program is entered and should 
  195. generally be  left enabled.  MSX-DOS function  calls will generally re-enable 
  196. interrupts if the transient program has disabled them.
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221. 2.2 RETURN TO MSX-DOS 
  222.  
  223.  
  224.      A  transient program  can terminate  itself in any of the following four 
  225. ways:
  226.  
  227.      1. Returning, with the original stack pointer.
  228.      2. Jump to location 0000h.
  229.      3. MSX-DOS "Program Terminate" function call.
  230.      4. MSX-DOS "Terminate with Error Code" function call.
  231.  
  232.  
  233.  
  234.      The  first  two of  these methods  are identical  as far  as MSX-DOS  is 
  235. concerned, and  are compatible  with CP/M  and MSX-DOS 1. The third method is 
  236. also  compatible  with  CP/M  and  MSX-DOS  1  and is  equivalent to  doing a 
  237. "Terminate with Error Code" function call with an error code of zero. 
  238.  
  239.      The  new  "Terminate  with Error  Code" function  allows the  program to 
  240. return  an error  code to MSX-DOS, the first three terminating methods always 
  241. returning an  error code  of zero  (no error). All specially written programs 
  242. and  converted CP/M programs should use this new function, even for returning 
  243. an error code of zero.
  244.  
  245.  
  246.      Various  other events  outside the  control of a program can cause it to 
  247. terminate. For  example, typing  "Ctrl-C" or  "CTRL-STOP" at the keyboard, by 
  248. the  user selecting  "Abort" as  the response to an "Abort/Retry/Ignore" disk 
  249. error message  or by an error on the standard I/O channels. In these cases an 
  250. appropriate error code will be returned to MSX-DOS.
  251.  
  252.  
  253.      A  transient program  can define an "abort routine". This will be called 
  254. to  treat  the abnormal  termination of  the program  appropriately when  the 
  255. program terminates  by a  "Program Terminate"  or "Terminate with error code" 
  256. function, or after an abort error (see above). How to define this routine and 
  257. for what may be used is described in the MSX-DOS Function Specification.
  258.  
  259.  
  260.  
  261.  
  262. 2.3   PAGE ZERO USAGE
  263.  
  264.  
  265.      On entry,  various parameter  areas are set up for the transient program 
  266. in  the first  256 bytes  of RAM.  The layout of this area is as below and is 
  267. compatible with MSX-DOS 1 and with CP/M apart from the area used for MSX slot 
  268. switching calls.
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.        +------+------+------+------+------+------+------+------+
  277.  0000h |    Reboot entry    |  Reserved   |   MSX-DOS entry    |
  278.        +------+------+------+------+------+------+------+------+
  279.  0008h |  RST 08h not used         | RDSLT routine entry point |
  280.        +------+------+------+------+------+------+------+------+
  281.  0010h |  RST 10h not used         | WRSLT routine entry point |
  282.        +------+------+------+------+------+------+------+------+
  283.  0018h |  RST 18h not used         | CALSLT routine entry point|
  284.        +------+------+------+------+------+------+------+------+
  285.  0020h |  RST 20h not used         | ENASLT routine entry point|
  286.        +------+------+------+------+------+------+------+------+
  287.  0028h |  RST 28h not used         |          not used         |
  288.        +------+------+------+------+------+------+------+------+
  289.  0030h | CALLF routine entry point |          not used         |
  290.        +------+------+------+------+------+------+------+------+
  291.  0038h |  Interrupt vector  |                                  |
  292.        +------+------+------+                                  +
  293.  0040h |                                                       |
  294.        +                                                       +
  295.  0048h |         Used by secondary slot switching code         |
  296.        +                                                       +
  297.  0050h |                                                       |
  298.        +                           +------+------+------+------+
  299.  0058h |                           |                           |
  300.        +------+------+------+------+                           +
  301.  0060h |         Unopened CP/M FCB for first parameter         |
  302.        +                           +------+------+------+------+
  303.  0068h |                           |                           |
  304.        +------+------+------+------+                           +
  305.  0070h |         Unopened CP/M FCB for second parameter        |
  306.        +                           +------+------+------+------+
  307.  0078h |                           |    Space for end of FCB   |
  308.        +------+------+------+------+------+------+------+------+
  309.  0080h |                                                       |
  310.    .   .                                                       .
  311.    .   .   Default Disk transfer address.  Initialized to      .
  312.    .   .   original command line parameters.                   .
  313.    .   .                                                       .
  314.  00F8h |                                                       |
  315.        +------+------+------+------+------+------+------+------+
  316.  
  317.  
  318.  
  319.      At address 0000h is a jump instruction which can be used for terminating 
  320. the  transient program.  The destination  of this  jump can  also be  used to 
  321. locate the  BIOS jump  vector (see  section 2.4).  The low  byte of this jump 
  322. address will always be 03h for CP/M compatibility.
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.      The two  reserved bytes  at addresses 0003h and 0004h are the IOBYTE and 
  332. current  drive/user in CP/M. Although MSX-DOS keeps the current drive byte up 
  333. to date  for CP/M compatibility, new programs are not recommended to use this 
  334. but  instead to  use the  "Get current drive" MSX-DOS function call. The user 
  335. number and  IOBYTE are not supported since I/O redirection is not done in the 
  336. same way as CP/M and there is no concept of user numbers.
  337.  
  338.      At address 0005h is a jump instruction to the start of the resident part 
  339. of MSX-DOS which is used for making MSX-DOS calls. In addition the address of 
  340. this  jump defines  the top of the TPA which the program may use. The size of 
  341. the TPA depends on what cartridges are used on the MSX machine and the number 
  342. of them,  but is  typically 53K. The low byte of the destination of this jump 
  343. will  always be  06h for  CP/M compatibility,  and the  six bytes immediately 
  344. preceding it will contain the CP/M version number and a serial number.
  345.  
  346.  
  347.      Four  bytes  are  reserved  for the  user at  each Z80  restart location 
  348. (0008h-0028h), which  is sufficient for a jump. The bytes between the restart 
  349. locations however are used for the entry points to various MSX slot switching 
  350. routines.
  351.  
  352.  
  353.      The  whole  area  from  0038h to  005Bh is  used for  MSX interrupt  and 
  354. secondary slot  switching code, and must not be modified. Note that most CP/M 
  355. debuggers  (such as  ZSID and DDT) use address 38h as a breakpoint entry, and 
  356. these programs  will have  to be modified to use a different restart. RST 28h 
  357. is recommended.
  358.  
  359.  
  360.      The two FCBs set up at addresses 005Ch and 006Ch are valid unopened FCBs 
  361. containing the first two command line parameters interpreted as filenames. If 
  362. both  filenames  are  to be  used then  the second  one must  be copied  to a 
  363. separate  FCB elsewhere  in memory  because it  will be  overwritten when the 
  364. first one is opened. See section 3.6 for the format of FCBs.
  365.  
  366.      The whole  of the  command line,  with the  initial command  removed, is 
  367. stored in the default disk transfer area at address 0080h, with a length byte 
  368. first  and  a  terminating null  (neither the  null nor  the length  byte are 
  369. included  in the  length). This  string will  have been upper-cased (when the 
  370. environment string  UPPER is ON) and will include any leading spaces typed to 
  371. ensure CP/M compatibility.
  372.  
  373.  
  374.      New  programs  for MSX-DOS  should not  use the  CP/M FCBs,  since other 
  375. MSX-DOS calls are available which are generally easier to use and which allow 
  376. programs  to  access directories  and handle  path names  (see section  3 for 
  377. details of these facilities).
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.      Improved methods  are also  available for accessing the command line. An 
  387. environment  string called  "PARAMETERS" is set up which contains the command 
  388. line  not  upper-cased. Another  environment string  called "PROGRAM"  allows 
  389. programs to  find out  the drive, directory and filename from which they were 
  390. loaded.  See section  3.5 for  details of  these environment  strings and  of 
  391. environment strings in general.
  392.  
  393.  
  394.  
  395.  
  396.  
  397. 2.4   BIOS JUMP TABLE
  398.  
  399.  
  400.      The  jump at address 0000h will always jump to an address whose low byte 
  401. is 03h.  At this address will be another jump instruction which is the second 
  402. entry  in a  seventeen entry jump table. This corresponds exactly to the BIOS 
  403. jump table in CP/M 2.2.
  404.  
  405.      The first eight entries in the table are for rebooting and for character 
  406. I/O. These  routines are implemented with the same specification as CP/M. The 
  407. remaining  jumps are  low level  disk related  functions in  CP/M and have no 
  408. equivalent in  MSX-DOS since  its filing  system is  totally different. These 
  409. routines  simply return without doing anything apart from corrupting the main 
  410. registers and returning an error where possible.
  411.  
  412.  
  413.      MSX-DOS switches to an internal stack while executing a BIOS call and so 
  414. only a small amount of space (8 bytes) is required on the user's stack.
  415.  
  416.  
  417.      Note that although the jump table is always on a 256 byte page boundary, 
  418. it is  not the "correct" distance above the top of the TPA (as defined by the 
  419. contents  of address  0006h) to  correspond with  CP/M 2.2.  This should  not 
  420. matter to  well behaved  CP/M programs  but it is rumoured that some programs 
  421. rely  on  the  size  of  the  BDOS  in  CP/M  2.2. These  programs will  need 
  422. modification.
  423.  
  424.  
  425.      The entries in the BIOS jump vector are as below:
  426.  
  427.    xx00h - JMP  WBOOT     ;Warm boot
  428.    xx03h - JMP  WBOOT     ;Warm boot
  429.    xx06h - JMP  CONST     ;Console status
  430.    xx09h - JMP  CONIN     ;Console input
  431.    xx0Ch - JMP  CONOUT    ;Console output
  432.    xx0Fh - JMP  LIST      ;List output
  433.    xx12h - JMP  PUNCH     ;Punch (auxiliary) output
  434.    xx15h - JMP  READER    ;Reader (auxiliary) input
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.    xx18h - JMP  RETURN    ;Home in CP/M
  442.    xx1Bh - JMP  RETURN    ;Select disk in CP/M 
  443.    xx1Eh - JMP  RETURN    ;Set track in CP/M
  444.    xx21h - JMP  RETURN    ;Set sector in CP/M
  445.    xx24h - JMP  RETURN    ;Set DMA address in CP/M
  446.    xx27h - JMP  RETURN    ;Read sector in CP/M
  447.    xx2Ah - JMP  RETURN    ;Write sector in CP/M
  448.    xx2Dh - JMP  LSTST     ;List status
  449.    xx30h - JMP  RETURN    ;Sector translate in CP/M
  450.  
  451.  
  452.  
  453.  
  454. 2.5   RAM PAGING
  455.  
  456.      When  a transient program is loaded, the mapper RAM slot will be enabled 
  457. in all  four pages and the four RAM segments which make up the basic 64k will 
  458. be paged in. There will be MSX BIOS ROM compatible slot handling entry points 
  459. available  in page-0  and various mapper support routines available in page-3 
  460. (see section 5 for specifications of these).
  461.  
  462.      A  program may  do any slot switching and paging which it likes while it 
  463. is running  and need not restore either the slot selections or the RAM paging 
  464. before  it exits,  since COMMAND2.COM  will handle  this. A  program must  of 
  465. course  take  the usual  precautions with  the interrupt  and the  slot entry 
  466. points if  it alters  page-0, and must never alter page-3 (nothing is allowed 
  467. to do that!).
  468.  
  469.      Pages 0,  1 and  2 can  contain any  slot when doing a function call and 
  470. will be preserved. Any parameters can be passed from the slot being selected, 
  471. except that environment strings and disk transfer areas must be in the mapper 
  472. RAM slot.
  473.  
  474.  
  475.      Any RAM  segments can  be selected  in pages  0, 1 and 2 when an MSX-DOS 
  476. function  call or  an MSX-DOS  BIOS function call is made, and also the stack 
  477. can  be  in  any  page. The  current paging  state will  be preserved  by all 
  478. function calls  even in  error conditions. Any disk transfers will be done to 
  479. the  RAM segments  which are paged in when the function call is made, even if 
  480. they are not the original TPA segments.
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.      If  a transient  program wants  to use more RAM than the TPA then it can 
  497. use the  mapper support routines (described in section 5) to obtain more RAM. 
  498. Before  using any  RAM other than the four TPA segments, the program must ask 
  499. the mapper  routines to allocate a new segment. This ensures that there is no 
  500. contention  with the  program trying to use a segment which is already in use 
  501. (by the  RAM disk  for example). The segments should normally be allocated as 
  502. "user  segments" since  these will  automatically be  freed when  the program 
  503. terminates. "system segments" should only be allocated if it is necessary for 
  504. them to remain in use after the transient program has terminated.
  505.  
  506.  
  507.  
  508.      Having  allocated additional  segments, the program may page them in and 
  509. use any  of the  mapper support  routines to access them. It will normally be 
  510. necessary  for a transient program to remember the segment numbers of the TPA 
  511. segments in  order to  page them  back in when they are required. The segment 
  512. numbers  will normally  be 0,  1, 2  and 3  but this  must NOT  be assumed by 
  513. transient programs,  they must  use the  "GET_Pn" mapper routines to find out 
  514. the segment numbers before paging anything else in.
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551. 3.   MSX-DOS FUNCTION CALLS
  552. ===========================
  553.  
  554.  
  555.  
  556.  
  557.  
  558. 3.1   CALLING CONVENTIONS
  559.  
  560.  
  561.      MSX-DOS function calls are made by putting the function code in register 
  562. C  with any  other parameters  required in  the other main registers and then 
  563. executing a  "CALL 5"  instruction. The  operation will  be performed and the 
  564. results will be returned in various registers depending on the function.
  565.  
  566.  
  567.      Generally  all the  main registers (AF, BC, DE and HL) will be corrupted 
  568. by MSX-DOS  calls or  will return  results. The  alternate register set (AF', 
  569. BC',  DE' and  HL') are  always preserved, whilst the index registers (IX and 
  570. IY) are preserved except in the one or two cases where they return results.
  571.  
  572.  
  573.      Only  a  small  amount of  space (8  bytes) is  needed on  the transient 
  574. program's  stack because  MSX-DOS switches  to an  internal stack  when it is 
  575. called.
  576.  
  577.  
  578.      For compatibility  all functions  which have  a CP/M  counterpart return 
  579. with  A=L and  B=H. Frequently  A returns an error flag, with zero indicating 
  580. success and 01h or FFh indicating failure.
  581.  
  582.  
  583.      All of  the new  MSX-DOS functions (function code above 40h) return with 
  584. an  error code  in A  and any  other results  in the other main registers. An 
  585. error code  of 0  means no  error, whilst  any non-zero  code means  an error 
  586. occurred,  the exact  nature of which can be found by looking at the value. A 
  587. list of error codes and messages is given in section 6. An "explain" function 
  588. is provided  which will  give an  ASCII explanation  string for an error code 
  589. (see Function Specification for details).
  590.  
  591.  
  592.  
  593.      The  actual functions  available are  documented in the MSX-DOS Function 
  594. Specification.
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606. 3.2   DEVICES AND CHARACTER I/O
  607.  
  608.  
  609.      Wherever  a filename  is given to an MSX-DOS function, a device name may 
  610. also be  given. These  devices are  used for  character based I/O and allow a 
  611. program  to access  a disk file or a character device in exactly the same way 
  612. without having to know which it is using.
  613.  
  614.  
  615.      The syntax of device names is identical to that of filenames so programs 
  616. do  not need  any special  handling to use device names. This applies both to 
  617. the  new  MSX-DOS  2  functions and  the CP/M  compatible FCB  functions. The 
  618. reserved filenames used for devices are:
  619.  
  620.      CON  - screen output, keyboard input
  621.      PRN  - printer output
  622.      LST  - printer output
  623.      AUX  - auxiliary output/input
  624.      NUL  - null device
  625.  
  626.  
  627.      When  any of  these appear  as the  main part of a filename, it actually 
  628. refers to  the device; the extension is ignored. Most function calls that use 
  629. files  can  also  use  devices.  For  example,  a  filename  of  CON  can  be 
  630. successfully  given  to  the  "rename  file"  function  or the  "delete file" 
  631. function. No error will be returned but the device will be unaffected.
  632.  
  633.  
  634.      The  AUX device  mentioned above  does not do anything by default, but a 
  635. routine may  be hooked  into it  so that  it refers  for example  to a serial 
  636. driver.  The NUL  device does not actually do anything; output characters are 
  637. ignored and  an end-of-file  is always  input. The  LST and  PRN devices  are 
  638. identical.
  639.  
  640.  
  641.      The CON device is used to read from the keyboard or write to the screen. 
  642. When reading  from the  CON device,  the system  will read  a line  at a time 
  643. allowing  the user to use line editing facilities. Only when the user types a 
  644. CR (carriage return) will the line be entered. End of input is signified by a 
  645. Ctrl-Z character at the start of a line.
  646.  
  647.  
  648.      The system  automatically opens  several file  handles to these standard 
  649. devices  (see section  3.3 for  details). These  file handles  may be used by 
  650. programs foraccessing  the standard  devices. Alternatively  a program can do 
  651. character  I/O by  using the  traditional CP/M character functions (functions 
  652. 01h...0Bh).  These  two  methods  are  both  acceptable but  they should  not 
  653. normally be mixed since they use separate buffering schemes and so characters 
  654. can get lost in these buffers.
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.      The  redirection is specified at the command line, both of these methods 
  662. (standard file  handles and  character functions) will be redirected. However 
  663. it  is preferable  to use  the standard file handles and to read and write in 
  664. large blocks because when accessing disk files these will be very much faster 
  665. than using the character functions.
  666.  
  667.  
  668.      Even  if the redirection was specified at the command line, programs may 
  669. sometimes need  to do  screen output and keyboard input which will bypass any 
  670. redirection. For example disk error handling routines may need to do this. To 
  671. facilitate this, there is a function provided which allows redirection of the 
  672. character  functions to  be temporarily  cancelled. This  is described in the 
  673. "Function Specification" document (function number 70h).
  674.  
  675.  
  676.  
  677.  
  678. 3.3   FILE HANDLES
  679.  
  680.  
  681.      File handles  are the method by which files are read from and written to 
  682. using  the new MSX-DOS functions. File handles may also be used to manipulate 
  683. files in other ways (e.g. the manipulation of the file attributes).
  684.  
  685.      A file  handle is an 8 bit number which refers to a particular open file 
  686. or  device.  A  new  file  handle is  allocated when  the "open  file handle" 
  687. (function  43H) or  "create file handle" (function 44H) function is used. The 
  688. file handle  can be  used to  read and  write data to the file and remains in 
  689. existence  until  the  "close  file  handle" (function  45H) or  "delete file 
  690. handle"  (function 52H)  function is  called. Other operations can be done on 
  691. files using  file handles,  such as  changing the  attributes or renaming the 
  692. files to which they refer.
  693.  
  694.  
  695.      Whenever MSX-DOS  allocates a  new file  handle, it  will use the lowest 
  696. number  available. The  maximum file  handle number in the current version is 
  697. 63. In  future versions  this may be increased but will never be greater than 
  698. 127, so file handles can never be negative.
  699.  
  700.  
  701.      Space  for  the  internal  data  structures  used  for  file  handles is 
  702. allocated  dynamically within a 16K RAM segment (the "data segment") so there 
  703. is no  fixed limit  to the  number of  file handles  which can be open at one 
  704. time. This segment is kept outside the TPA, so anything stored there does not 
  705. reduce  TPA size.  As well  as keeping  internal file handle information, the 
  706. system also keeps disk buffers and environment strings in the data segment.
  707.  
  708.  
  709.      Various  file  handles  are  pre-defined  and  are already  open when  a 
  710. transient program is executed. These file handles refer to the standard input 
  711. and output  devices (see  section 3.2).  The "traditional" CP/M style MSX-DOS 
  712. character I/O functions actually refer to these file handles.
  713.  
  714.  
  715.  
  716.      A  transient program  actually gets  a copy  of the  standard input  and 
  717. output file  handles which the command interpreter was using, rather than the 
  718. originals.  This means  that the  program can freely close these file handles 
  719. and re-open  them to  different destinations  and need  not reset them before 
  720. terminating.
  721.  
  722.  
  723.      The default file handles and their destinations are:
  724.  
  725.           0 - Standard input (CON)
  726.           1 - Standard output (CON)
  727.           2 - Standard error input/output (CON)
  728.           3 - Standard auxiliary input/output (AUX)
  729.           4 - Standard printer output (PRN)
  730.  
  731.  
  732.  
  733.      When the  command interpreter is about to execute a command (for example 
  734. a transient program), it executes a "fork" function call (function 60H). This 
  735. informs the system that a new program is being executed as a "subroutine" and 
  736. amongst  other things, all of the currently open file handles are duplicated, 
  737. so that  the new program will be using copies of the original handles, rather 
  738. than the command interpreter's.
  739.  
  740.  
  741.      If the transient program changes any of the file handles, by closing any 
  742. existing ones  or opening  new ones, it will be the program's own set of file 
  743. handles which are modified, the original set will remain unaltered. After the 
  744. program  has terminated,  the command  interpreter executes a "join" function 
  745. call (function  61H), passing  to it a process id which was returned from the 
  746. original  "fork". This  tells the  system that the new program has terminated 
  747. and so all its file handles can be thrown away. 
  748.  
  749.      Reference  counts are  kept of  how many copies of each handle there are 
  750. which enables  the system  to tidy  up any  file handles  which are no longer 
  751. needed  when a  program terminates. This ensures that the system will not run 
  752. out of file handles because of badly behaved programs not closing them.
  753.  
  754.  
  755.      These "fork"  and "join"  functions are  available for  user programs if 
  756. they  find them  useful. In  addition to tidying up file handles, "join" will 
  757. also free up any user allocated RAM segments which the program has not freed.
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771. 3.4   FILE INFO BLOCKS
  772.  
  773.  
  774.      All  new MSX-DOS  functions that  act on  files on  disk can be passed a 
  775. simple pointer  to a  null-terminated string (called an ASCIIZ string), which 
  776. can  contain a  drive, path and unambiguous filename. These are typically the 
  777. operations which a transient program will perform, often through a high level 
  778. language interface. The Command Specification gives details of these.
  779.  
  780.  
  781.      To any  of these  ASCIIZ functions,  a File  Info Block (FIB) may passed 
  782. instead.  FIBs are  used for more complex operations such as the searching of 
  783. directories for unknown files or sub-directories.
  784.  
  785.  
  786.      A FIB  is a 64 byte area of the user's memory which contains information 
  787. about the directory entry on disk for a particular file or sub-directory. The 
  788. information  in a FIB is filled in by the new MSX-DOS "find" functions ("find 
  789. first entry"  (function 40H),  "find new entry" (function 42H) and "find next 
  790. entry" (function 41H)). The format of a File Info Block is as follows:
  791.  
  792.      0 - Always 0FFh
  793.  1..13 - Filename as an ASCIIZ string
  794.     14 - File attributes byte
  795. 15..16 - Time of last modification
  796. 17..18 - Date of last modification
  797. 19..20 - Start cluster
  798. 21..24 - File size
  799.     25 - Logical drive
  800. 26..63 - Internal information, must not be modified
  801.  
  802.  
  803.  
  804.      The 0FFh at the start of the fileinfo block must be there to distinguish 
  805. it  from a  pathname string,  since some  functions can  take either  type of 
  806. parameter.
  807.  
  808.  
  809.      The  filename is  stored in a suitable format for directly printing, and 
  810. is in  the form  of an  ASCIIZ string. Any spaces will have been removed, the 
  811. filename  extension (if  present) will be preceded by a dot and the name will 
  812. have been  uppercased. If  the entry  is a volume label then the name will be 
  813. stored without the "." separator, with spaces left in and not uppercased.
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.      The  file attributes  byte is  a byte  of flags concerning the file. The 
  827. format of this byte is:
  828.  
  829. Bit 0 - READ ONLY.  If set then the file cannot be written to or deleted, but 
  830.         can be read, renamed or moved.
  831.  
  832. Bit 1 - HIDDEN  FILE. If  set then  the file  will only be found by the "Find 
  833.         First"  function  if  the  "hidden  file"  bit is  set in  the search 
  834.         attributes  byte.   All  the  commands  implemented  by  the  command 
  835.         interpreter that access files and directories on disk can take a "/H" 
  836.         option which allows the command to find hidden files.
  837.  
  838.  
  839. Bit 2 - SYSTEM FILE.  As far as MSX-DOS functions are concerned, this bit has 
  840.         exactly  the same  effect as  the "HIDDEN  FILE" bit  except that the 
  841.         "Find New"  and "Create" function calls will not automatically delete 
  842.         a  system  file.  None  of  the commands  implemented by  the command 
  843.         interpreter allow system files to be accessed.
  844.  
  845.  
  846. Bit 3 - VOLUME  NAME. If  set then this entry defines the name of the volume. 
  847.         Can only  occur in  the root directory, and only once. All other bits 
  848.         are ignored.
  849.  
  850.  
  851. Bit 4 - DIRECTORY.  If set  then the  entry is  a sub-directory rather than a 
  852.         file and so cannot be opened for reading and writing. Only the hidden 
  853.         bit has any meaning for sub-directories.
  854.  
  855.  
  856. Bit 5 - ARCHIVE BIT.  Whenever a file has been written to and closed this bit 
  857.         is  set. This  bit can be examined by, for example, the XCOPY command 
  858.         to determine whether the file has been changed.
  859.  
  860.  
  861. Bit 6 - Reserved (always 0).
  862.  
  863.  
  864. Bit 7 - DEVICE  BIT.  This  is  set  to  indicate that  the FIB  refers to  a 
  865.         character device  (eg. "CON")  rather than  a disk  file. All  of the 
  866.         other attributes bits are ignored.
  867.  
  868.  
  869.  
  870.      The time of last modification is encoded into two bytes as follows:
  871.  
  872.      Bits 15..11 - HOURS (0..23)
  873.      Bits 10...5 - MINUTES (0..59)
  874.      Bits  4...0 - SECONDS/2 (0..29)
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.      The  date of  last modification is encoded into two bytes as follows. If 
  882. all bits are zero then there is no valid date set.
  883.  
  884.      Bits 15...9 - YEAR (0..99 corresponding to 1980..2079)
  885.      Bits  8...5 - MONTH (1..12 corresponding to Jan..Dec)
  886.      Bits  4...0 - DAY (1..31)
  887.  
  888.  
  889.  
  890.      The file  size is a 32 bit number stored with the lowest byte first, and 
  891. is zero for sub-directories.
  892.  
  893.  
  894.  
  895.      The logical drive is a single byte drive number, with 1 corresponding to 
  896. A:, 2  to B:  etc. It  will never be zero, since if zero was specified in the 
  897. original  function, this means the default drive and the driven number of the 
  898. default drive will be filled in here.
  899.  
  900.  
  901.  
  902.      The  internal information  tells MSX-DOS where on the disk the directory 
  903. entry is stored. This enables functions to which the fileinfo block is passed 
  904. to operate  on the  directory entry,  for example deleting it, renaming it or 
  905. opening  it. Data  stored here  also enables  the "find  next entry" function 
  906. (function 41H)  to carry  on the  search to  find the next matching file. The 
  907. user should not access or modify the internal information at all.
  908.  
  909.  
  910.  
  911.      Fileinfo  blocks are  filled in  by the  "find first  entry", "find  new 
  912. entry"  and  "find next  entry" MSX-DOS  functions. Each  of these  functions 
  913. locates a  directory entry  and fills in the fileinfo block with the relevant 
  914. information.
  915.  
  916.  
  917.      In the  case of  "find first entry" a directory will be searched for the 
  918. first  entry which matches a given filename and which has suitable attributes 
  919. (see the  Function Specification for details). "Find next entry" carries on a 
  920. search  started by  a previous  "find first  entry" function  and updates the 
  921. fileinfo block with the next matching entry.
  922.  
  923.  
  924.      "Find new  entry" is just like "find first entry" except that instead of 
  925. looking  for a  matching entry,  it will  create a  new one and then return a 
  926. fileinfo block just as if "find first" had found it.
  927.  
  928.  
  929.  
  930.      Having created  a fileinfo block using one of the "find" functions there 
  931. are  two ways  in which  it can  be used.  The first way is to simply use the 
  932. information which  it contains such as the filename and size. For example the 
  933. "DIR" command simply prints out the information on the screen.
  934.  
  935.  
  936.  
  937.      The more interesting way of using a fileinfo block is to pass it back to 
  938. another  MSX-DOS  function  in  order  to  carry  out some  operation on  the 
  939. directory  entry. Many  of the  MSX-DOS functions  described in  the Function 
  940. Specification take  a pointer  in register  DE which  can either  point to  a 
  941. drive/path/file  string or a fileinfo block. In either case a particular file 
  942. or directory is being specified for the function to act on.
  943.  
  944.  
  945.      The  functions  which  can take  such a  parameter are  "Delete File  or 
  946. Subdirectory"  (function 4DH),  "Rename file or Subdirectory" (function 4EH), 
  947. "Move  File  or  Subdirectory"  (function  4FH),  "Get/Set  File  Attributes" 
  948. (function 50H),  "Get/Set File  Date and  Time" (function 51H) and "Open File 
  949. handle"  (function 43H).  All of  these carry out the obvious function on the 
  950. specified file or directory.
  951.  
  952.  
  953.      A fileinfo  block can  also be  passed to  a "find  first" or "find new" 
  954. function  in place  of the  drive/path/file string. In this case the fileinfo 
  955. block must refer to a directory rather than a file and a filename string must 
  956. also be  passed in register HL (typically null which is equivalent to "*.*"). 
  957. The  directory specified  by the  fileinfo block will be searched for matches 
  958. with the  filename, subject  to the usual attribute checking. This feature is 
  959. necessary  for the command interpreter so that a command such as "DIR A:UTIL" 
  960. can have the required action if UTIL is a directory.
  961.  
  962.  
  963.  
  964.  
  965. 3.5   ENVIRONMENT STRINGS
  966.  
  967.  
  968.      MSX-DOS  maintains a list of "environment strings" in it's data segment. 
  969. An environment  string is  a named item which has a value associated with it. 
  970. Both  the  name  and  the  value  are  user-defined. Environment  strings are 
  971. accessed  at  the  function  call  level  via  the  "Get  Environment String" 
  972. (function 6BH), "Set Environment String" (function 6CH) and "Find Environment 
  973. String" (function 6DH) functions.
  974.  
  975.  
  976.      The name of an environment string is a non-null string consisting of any 
  977. characters that  are valid in filenames. The name can be up to 255 characters 
  978. long.  The characters of the name are upper-cased when the string is defined, 
  979. although for name comparisons case is not significant.
  980.  
  981.  
  982.      The value  of an  environment string  consists of  a string  of non-null 
  983. characters  and  can  be  up  to  255  characters long.  If the  value of  an 
  984. environment string is set to a null string, then the name is removed from the 
  985. list of environment strings. Similarly, if the value of an environment string 
  986. that  has not been defined is read, then a null string is returned. The value 
  987. is not  upper-cased and  no interpretation is placed on the characters in the 
  988. value string.
  989.  
  990.  
  991.  
  992.      When  a transient  program is loaded and executed from COMMAND2.COM, two 
  993. special environment strings are set up, which it can read.
  994.  
  995.  
  996.      An environment  string called  PARAMETERS is  set up to the command line 
  997. not  including the  actual command name. This is similar to the one set up at 
  998. 80h for CP/M compatibility, but has not been upper-cased.
  999.  
  1000.  
  1001.      Another environment string called PROGRAM is also set up and this is the 
  1002. whole  path used  to locate the program on disk. The drive is first, followed 
  1003. by the  path from  the root  and then the actual filename of the program. The 
  1004. drive,  path  and  filename  can  be separated  if desired  using the  "Parse 
  1005. Pathname" function call (function 5CH).
  1006.  
  1007.  
  1008.      The PROGRAM  environment string has several uses. The main use is that a 
  1009. program  can use  it to  load overlay files from the same directory as it was 
  1010. loaded from.  The last  item in  PROGRAM (ie. the actual program filename) is 
  1011. replaced  with the  name of  the overlay file, and then the new string can be 
  1012. passed to  any of  the new MSX-DOS 2 functions that take ASCIIZ strings (such 
  1013. as "Open File").
  1014.  
  1015.  
  1016.      Note  that  some  CP/M  programs  are  capable  of  loading and  running 
  1017. transient programs,  and in this case they obviously will not have set up the 
  1018. PROGRAM  and PARAMETERS  environment strings,  and they will in fact still be 
  1019. set up  from when  the CP/M  program was  loaded. If  a program wishes to use 
  1020. PROGRAM and PARAMETERS and still be loadable from a CP/M program, then it can 
  1021. look  at a  variable called "LOAD_FLAG", which is in page 0 at address 0037h. 
  1022. It is  set to  zero on  every MSX-DOS  2 function call but is set to non-zero 
  1023. immediately   before  a   transient  program   is  executed  by  the  command 
  1024. interpreter. Similarly,  if a  new transient  program has the ability to load 
  1025. other  transient programs  and it  sets up  PROGRAM and  PARAMETERS, then  it 
  1026. should also set LOAD_FLAG to non-zero.
  1027.  
  1028.  
  1029.      Another special environment string is one called APPEND. This can be set 
  1030. up  by the  user from  the command  interpreter and is used by the CP/M "Open 
  1031. File (FCB)"  function. When  this function  call is  done and the file is not 
  1032. found,  an alternative directory, specified by APPEND, is searched. It is not 
  1033. anticipated however  that new  transient programs will use this function call 
  1034. or the APPEND environment string.
  1035.  
  1036.  
  1037.      Several environment  strings are  set up by the command interpreter when 
  1038. it  starts up  and are altered by the user to control various system features 
  1039. and options,  and it  may be  useful for  transient programs  to read some of 
  1040. these.  For example,  it may be useful to read the PATH environment string or 
  1041. the DATE  and TIME  environment strings  if the  program prints out dates and 
  1042. times.   The  Command   Specification  contains   details  of  these  default 
  1043. environment strings.
  1044.  
  1045.  
  1046. 3.6   FILE CONTROL BLOCKS
  1047.  
  1048.  
  1049.      It  is  not  anticipated  that  specially  written  MSX-DOS 2  transient 
  1050. programs  or MSX-DOS 1 or CP/M programs which are modified for MSX-DOS 2 will 
  1051. use the  CP/M-compatible FCB  functions, but  the format of the FCBs used for 
  1052. these  functions is given here for reference. This format is, of course, very 
  1053. similar to  the FCBs  used by  CP/M and  MSX-DOS 1 but the use of some of the 
  1054. fields within the FCB are different (though generally compatible).
  1055.  
  1056.  
  1057.      A basic  FCB is  33 bytes  long. This  type of  FCB can be used for file 
  1058. management  operations (delete,  rename etc.) and also for sequential reading 
  1059. and writing.  The random read and write functions use an extra 3 bytes on the 
  1060. end  of the  FCB to  store a  random record  number. The MSX-DOS 1 compatible 
  1061. block read  and write  functions also  use this  additional three (or in some 
  1062. cases four) bytes - see the Function Specification for details.
  1063.  
  1064.  
  1065.      The layout  of an  FCB is  given below. A general description of each of 
  1066. the fields is included here. The individual function description given in the 
  1067. Function  Specification details  of how the fields are used for each function 
  1068. where this is not obvious.
  1069.  
  1070.       00h  Drive number 1...8. 0 => default drive. Must be set up in all FCBs 
  1071.            used, never modified by MSX-DOS function calls (except "Open File" 
  1072.            if APPEND was used).
  1073.  
  1074.  
  1075. 01h...08h  Filename, left  justified with  trailing blanks.  Can contain  "?" 
  1076.            characters   if  ambiguous   filename  is  allowed  (see  Function 
  1077.            Specification). When  doing comparisons case will be ignored. When 
  1078.            creating new files, name will be uppercased.
  1079.  
  1080.  
  1081. 09h...0Bh  Filename  extension. Identical to filename. Note that bit-7 of the 
  1082.            filename extension characters are NOT interpreted as flags as they 
  1083.            are in CP/M.
  1084.  
  1085.  
  1086.      0Ch   Extent number  (low byte).  Must be  set (usually  to zero) by the 
  1087.            transient program before open or create. It is used and updated by 
  1088.            sequential  read and write, and also set by random read and write. 
  1089.            This is compatible with CP/M and MSX-DOS 1.
  1090.  
  1091.  
  1092.      0Dh   File attributes. Set by "open", "create" or "find".
  1093.  
  1094.  
  1095.      0Eh   Extent  number (high  byte) for CP/M functions. Zeroed by open and 
  1096.            create. For sequential read and write it is used and updated as an 
  1097.            extension  to  the  extent  number  to  allow larger  files to  be 
  1098.            accessed.  Although  this  is  different  from  CP/M  it  does not 
  1099.            interfere with CP/Ms use of FCBs and is the same as MSX-DOS 1.
  1100.  
  1101.            Record size  (low byte)  for MSX-DOS 1 compatible block functions. 
  1102.            Must  be set  to the  required record  size before using the block 
  1103.            read or write functions. 
  1104.  
  1105.      0Fh   Record count  for CP/M  functions. Set  up by  open and create and 
  1106.            modified when necessary by sequential and random reads and writes. 
  1107.            This is the same as CP/M and MSX-DOS 1.
  1108.  
  1109.            Record  size (high byte) for MSX-DOS 1 compatible block functions. 
  1110.            Must be  set to  the required  record size  before using the block 
  1111.            read and write functions.
  1112.  
  1113.  
  1114. 10h...13h  File size  in bytes,  lowest byte  first. File  size is exact, not 
  1115.            rounded  up to  128 bytes. This field is set up by open and create 
  1116.            and updated  when the file is extended by write operations. Should 
  1117.            not  be modified by the transient program as it is written back to 
  1118.            disk by  a close  function call. This is the same as MSX-DOS 1 but 
  1119.            different from CP/M which stores allocation information here.
  1120.  
  1121.  
  1122. 14h...17h  Volume-id. This  is a  four byte number identifying the particular 
  1123.            disk  which this FCB is accessing. It is set up by open and create 
  1124.            and  is  checked on  read, write  and close  calls. Should  not be 
  1125.            modified by  the program. Note that this is different from MSX-DOS 
  1126.            1  which stores  the date  and time  of last update here, and from 
  1127.            CP/M which stores allocation information.
  1128.  
  1129.  
  1130. 18h...1Fh  Internal  information. These  bytes contain  information to enable 
  1131.            the file  to be located on the disk. Should not be modified at all 
  1132.            by  the transient  program. The  internal information kept here is 
  1133.            similar but  not identical  to that  kept by MSX-DOS 1 and totally 
  1134.            different from CP/M.
  1135.  
  1136.  
  1137.       20h  Current  record within  extent (0...127). Must be set (normally to 
  1138.            zero) by  the transient  program before  first sequential  read or 
  1139.            write. Used and modified by sequential read and write. Also set up 
  1140.            by random read and write. This is compatible with CP/M and MSX-DOS 
  1141.            1.
  1142.  
  1143.  
  1144. 21h...24h  Random  record number,  low byte first. This field is optional, it 
  1145.            is only  required if  random or block reads or writes are used. It 
  1146.            must  be set  up before  doing these  operations and is updated by 
  1147.            block read  and write but not by random read or write. Also set up 
  1148.            by the "set random record" function.
  1149.  
  1150.            For the  block operations, which are in MSX-DOS 1 but not in CP/M, 
  1151.            all  four bytes are used if the record size is less than 64 bytes, 
  1152.            and only  the first  three bytes are used if the record size is 64 
  1153.            bytes  or more.  For random  read and  write only  the first three 
  1154.            bytes  are  used  (implied  record  size  is 128  bytes). This  is 
  1155.            compatible with CP/M and with MSX-DOS 1.
  1156.  
  1157.  
  1158. 4.   SCREEN CONTROL CODES
  1159. =========================
  1160.  
  1161.  
  1162.      Below is  a list  of all control codes and escape sequences which may be 
  1163. used  when doing  character output by MSX-DOS character functions, BIOS calls 
  1164. or writing  to the  device CON.  These are  all compatible with MSX-DOS 1 and 
  1165. contain the VT-52 control codes.
  1166.  
  1167.      The  screen is 24 lines of 2 to 80 characters. When a printing character 
  1168. is displayed the cursor is moved to the next position and to the start of the 
  1169. next line at the end of a line. If a character is written in the bottom right 
  1170. position  then  the  screen  will  be  scrolled  to  allow the  cursor to  be 
  1171. positioned at  the start  of the  next line.  The letters in escape sequences 
  1172. must be in the correct case, the spaces are inserted for readability they are 
  1173. not  part of  the sequence. Numbers (indicated by <n> or <m>) are included in 
  1174. the sequence as a single byte usually with an offset of 20h added.
  1175.  
  1176.  
  1177.  
  1178. Ctrl-G  07h = Bell.
  1179.  
  1180.  
  1181. Ctrl-H  08h = Cursor left, wraps around to previous line, stop at top left of 
  1182.         screen.
  1183.  
  1184.  
  1185. Ctrl-I  09h = Tab, overwrites with spaces up to next 8th column, wraps around 
  1186.         to start of next line, scrolls at bottom right of screen.
  1187.  
  1188.  
  1189. Ctrl-J  0Ah = Line feed, scrolls if at bottom of screen.
  1190.  
  1191.  
  1192. Ctrl-K  0Bh = Cursor home.
  1193.  
  1194.  
  1195. Ctrl-L  0Ch = Clear screen and home cursor.
  1196.  
  1197.  
  1198. Ctrl-M  0Dh = Carriage return.
  1199.  
  1200.  
  1201. Ctrl-[  1Bh = ESC - see below for escape sequences.
  1202.  
  1203.  
  1204. Ctrl-\  1Ch = Cursor right, wrap around to next line, stop at bottom right of 
  1205.         screen.
  1206.  
  1207.  
  1208. Ctrl-]  1Dh =  Cursor left, wrap around to previous line, stop at top left of 
  1209.         screen. 
  1210.  
  1211.  
  1212. Ctrl-^  1Eh = Cursor up, stop at top of screen.
  1213.  
  1214.  
  1215. Ctrl-_  1Fh = Cursor down, stop at bottom of screen.
  1216.  
  1217.         7Fh = Delete  character and move cursor left, wrap around to previous 
  1218.         line, stop at top of screen.
  1219.  
  1220. Esc A       = Cursor up, stops at top of screen.
  1221.  
  1222.  
  1223. Esc B       = Cursor down, stops at bottom of screen.
  1224.  
  1225.  
  1226. Esc C       = Cursor right, stops at end of line.
  1227.  
  1228.  
  1229. Esc D       = Cursor left, stops at start of line.
  1230.  
  1231.  
  1232. Esc E       = Clear screen and home cursor.
  1233.  
  1234.  
  1235. Esc H       = Cursor home.
  1236.  
  1237.  
  1238. Esc J       = Erase to end of screen, don't move cursor.
  1239.  
  1240.  
  1241. Esc j       = Clear screen and home cursor.
  1242.  
  1243.  
  1244. Esc K       = Erase to end of line, don't move cursor.
  1245.  
  1246.  
  1247. Esc L       = Insert  a line  above cursor  line, scroll rest of screen down. 
  1248.               Leave cursor at start of new blank line. 
  1249. Esc l       = Erase entire line, don't move cursor.
  1250.  
  1251.  
  1252. Esc M       = Delete cursor  line, scrolling  rest of screen up. Leave cursor 
  1253.               at start of next line.
  1254.  
  1255. Esc x 4     = Select block cursor. 
  1256.  
  1257. Esc x 5     = Cursor off.
  1258.  
  1259. Esc Y <n><m>= Position  cursor at  row <n>  column <m>. Top left of screen is 
  1260.               n=m=20h (ASCII space).
  1261.  
  1262. Esc y 4     = Select underscore cursor.
  1263.  
  1264. Esc y 5     = Cursor on.
  1265.  
  1266.  
  1267. 5.   MAPPER SUPPORT ROUTINES
  1268. ============================
  1269.  
  1270.  
  1271.      MSX-DOS 2  contains routines  to provide  support for the memory mapper. 
  1272. This allows MSX application programs or MSX-DOS transient programs to utilize 
  1273. more  than the  basic 64k of memory, without conflicting with the RAM disk or 
  1274. any other system software.
  1275.  
  1276.  
  1277.  
  1278.  
  1279.   5.1   MAPPER INITIALIZATION
  1280.  
  1281.      When  the DOS  kernel is  initialized it checks that there is the memory 
  1282. mapper in  the system,  and that  there is at least 128k of RAM available. If 
  1283. the kernel has found at least one slot which contains 128k of the mapper RAM, 
  1284. it  selects the  slot which  contains the  largest amount of RAM (or the slot 
  1285. with the  smallest slot  number, if  there are two or more mapper slots which 
  1286. have  the same  amount of  RAM) and makes that slot usable as the system RAM. 
  1287. When there is not enough memory on the memory mapper, MSX-DOS 2 won't start.
  1288.  
  1289.  
  1290.      Next  the kernel builds up a table of all the 16k RAM segments available 
  1291. to this  slot (primary  mapper slot).  The first  four segments (64k) for the 
  1292. user  and the  two highest numbered segments are allocated to the system, one 
  1293. for the  DOS kernel  code and  one for  the DOS  kernel workspace.  All other 
  1294. segments  (at least two) are marked as free initially. Then the kernel builds 
  1295. up the  similar tables for other RAM slots, if any. All of these segments are 
  1296. marked as free initially.
  1297.  
  1298.  
  1299.  
  1300.  
  1301.    5.2   MAPPER VARIABLES AND ROUTINES
  1302.  
  1303.      The  mapper support  routines use some variables in the DOS system area. 
  1304. These tables  may be  referred and  used by the user programs for the various 
  1305. purposes, but must not be altered. The contents of the tables are as follows:
  1306.  
  1307. address                 function
  1308. +0              Slot address of the mapper slot.
  1309. +1              Total  number of  16k RAM  segments. 1...255 (8...255 for the 
  1310.                 primary)
  1311. +2              Number of free 16k RAM segments.
  1312. +3              Number of  16k RAM segments allocated to the system (at least 
  1313.                 6 for the primay)
  1314. +4              Number of 16k RAM segments allocated to the user.
  1315. +5...+7         Unused. Always zero.
  1316. +8...           Entries  for other mapper slots. If there is none, +8 will be 
  1317.                 zero.
  1318.  
  1319.  
  1320.  
  1321.      A program  uses the  mapper support code by calling various subroutines. 
  1322. These  are accessed  through a  jump table  which is  located in  the MSX-DOS 
  1323. system area. The contents of the jump table are as follows:
  1324.  
  1325.  
  1326. address entry name      function
  1327. +0H     ALL_SEG     Allocate a 16k segment.
  1328. +3H     FRE_SEG     Free a 16k segment.
  1329. +6H     RD_SEG      Read byte from address A:HL to A.
  1330. +9H     WR_SEG      Write byte from E to address A:HL.
  1331. +CH     CAL_SEG     Inter-segment call.  Address in IYh:IX
  1332. +FH     CALLS       Inter-segment  call.  Address  in  line  after  the  call 
  1333.                     instruction.
  1334. +12H    PUT_PH      Put segment into page (HL).
  1335. +15H    GET_PH      Get current segment for page (HL)
  1336. +18H    PUT_P0      Put segment into page 0.
  1337. +1BH    GET_P0      Get current segment for page 0.
  1338. +1EH    PUT_P1      Put segment into page 1.
  1339. +21H    GET_P1      Get current segment for page 1.
  1340. +24H    PUT_P2      Put segment into page 2.
  1341. +27H    GET_P2      Get current segment for page 2.
  1342. +2AH    PUT_P3      Not supported  since page-3  must never  be changed. Acts 
  1343.                     like a "NOP" if called.
  1344. +2DH    GET_P3      Get current segment for page 3.
  1345.  
  1346.  
  1347.      A  program can  use the  extended BIOS  calls for  the mapper support to 
  1348. obtain these addresses. The calls are provided because these addresses may be 
  1349. changed in  the future  version, or to use mapper routines other than MSX-DOS 
  1350. mapper support routines.
  1351.  
  1352.      To use the extended BIOS, the program should test "HOKVLD" flag at FB20h 
  1353. in  page-3. If  bit-0 (LSB)  is 0,  there is  no extended BIOS nor the mapper 
  1354. support. Otherwise,  "EXTBIO" entry (see below) has been set up and it can be 
  1355. called  with various  parameters. Note  that this test is unnecessary for the 
  1356. applications which  are based on MSX-DOS (such as the program which is loaded 
  1357. from the disk), and the program may proceed to the next step.
  1358.  
  1359.      Next,  the  program  sets  the  device  number of  the extended  BIOS in 
  1360. register D,  the function  number in  register E,  and required parameters in 
  1361. other  registers, and  then calls  "EXTBIO" at FFCAh in page-3. In this case, 
  1362. the stack  pointer must  be in  page-3. If there is the extended BIOS for the 
  1363. specified  device number,  the contents  of the  registers AF,  BC and HL are 
  1364. modified according  to the  function; otherwise, they are preserved. Register 
  1365. DE  is  always  preserved.  Note  that  in  any  cases  the  contents  of the 
  1366. alternative registers (AF', BC', DE' and HL') and the index registers (IX and 
  1367. IY) are corrupted.
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376. The functions available in the mapper support extended BIOS are:
  1377.  
  1378. * Get mapper variable table
  1379.  
  1380.         Parameter:      A = 0
  1381.                         D = 4 (device number of mapper support)
  1382.                         E = 1
  1383.         Result:         A = slot address of primary mapper
  1384.                         DE = reserved
  1385.                         HL = start address of mapper variable table
  1386.  
  1387. * Get mapper support routine address
  1388.  
  1389.         Parameter:      A = 0
  1390.                         D = 4
  1391.                         E = 2
  1392.         Result:         A = total number of memory mapper segments
  1393.                         B = slot number of primary mapper
  1394.                         C = number of free segments of primary mapper
  1395.                         DE = reserved
  1396.                         HL = start address of jump table
  1397.  
  1398.      In  these mapper support extended BIOS, register A is not required to be 
  1399. zero. Note that, however, if there is no mapper support routine, the contents 
  1400. of registers  will not  be modified,  and the value which is not zero will be 
  1401. returned  in A  otherwise. Thus,  the existence of the mapper support routine 
  1402. can be  determined by  setting zero  in A  at the  calling and  examining the 
  1403. returned value of A.
  1404.  
  1405.      The  slot address of the primary mapper returned by the extended BIOS is 
  1406. the same  as the  current RAM  slot address  in page-3,  and, in the ordinary 
  1407. environment  (DISK-BASIC and  MSX-DOS), the same RAM slot is also selected in 
  1408. page-2. In MSX-DOS, this is also true in page-0 and page-1.
  1409.  
  1410.  
  1411.  
  1412.    5.3   USING MAPPER ROUTINES
  1413.  
  1414.      A program  can request  a 16k  RAM segment  at any  time by  calling the 
  1415. "ALL_SEG"  routine.  This  either  returns  an  error  if there  are no  free 
  1416. segments, or the segment number of a new segment which the program can use. A 
  1417. program  must not  use any  segment which  it has  not explicitly  allocated, 
  1418. except for the four segments which make up the basic 64k of RAM.
  1419.  
  1420.      A  segment can  be allocated  either as  a user  segment or  as a system 
  1421. segment.  User   segments  will  be  automatically  freed  when  the  program 
  1422. terminates,  whereas system segments are never freed unless the program frees 
  1423. them explicitly. Normally, programs should allocate user segments.
  1424.  
  1425.      RAM segments can be accessed by the "RD_SEG" and "WR_SEG" routines which 
  1426. read  and  write  bytes  to  specified segments.  The routines  "CAL_SEG" and 
  1427. "CALLS"  allow  inter-segment  calls  to  be  done  in much  the same  way as 
  1428. inter-slot calls in the current MSX system.
  1429.  
  1430.  
  1431.      Routines  are provided  to explicitly  page a segment in, or to find out 
  1432. which segment  is in  a particular page. There are routines in which the page 
  1433. (0...3)  is specified  by the  top two bits of an address in HL ("PUT_PH" and 
  1434. "GET_PH").  And  there are  also specific  routines for  accessing each  page 
  1435. ("GET_Pn" and "PUT_Pn"). These routines are very fast so a program should not 
  1436. suffer in performance by using them.
  1437.  
  1438.  
  1439.      Note that  page-3 should never be altered since this contains the mapper 
  1440. support  routines and all the other system variables. Also great care must be 
  1441. taken if  page-0 is  altered since  this contains  the interrupt and the slot 
  1442. switching entry points. Pages 1 and 2 can be altered in any way.
  1443.  
  1444.  
  1445.      None  of the  mapper support  routines will  disturb the  slot selection 
  1446. mechanism at  all. For  example when  "PUT_P1" is  called, the  specified RAM 
  1447. segment  will only  appear at  address 4000h...7FFFh  if the  mapper slot  is 
  1448. selected in page-1. The "RD_SEG" and "WR_SEG" routines will always access the 
  1449. RAM segment  regardless of  the current slot selection in the specified page, 
  1450. but the mapper RAM slot must be selected in page-2.
  1451.  
  1452.  
  1453.  
  1454.  
  1455.    5.4   ALLOCATING and FREEING SEGMENTS
  1456.  
  1457.      The following  two routines  can be called to allocate or free segments. 
  1458. All  registers apart  from AF  and BC are preserved. An error is indicated by 
  1459. the carry  flag being set on return. The slot selection and RAM paging may be 
  1460. in  any state  when these routines are called and both will be preserved. The 
  1461. stack must  not be  in page-0  or page-2  when either  of these  routines are 
  1462. called.
  1463.  
  1464.  
  1465.      A  program must  not use  any segment (apart from the four which make up 
  1466. the basic 64k) unless it has specifically allocated it, and must not continue 
  1467. to use a segment after it has been freed. 
  1468.  
  1469.      A segment  may be  allocated either  as a  user or a system segment. The 
  1470. only  difference is  that user  segments will be automatically freed when the 
  1471. program terminates  whereas system segments will not be. In general a program 
  1472. should  allocate a  user segment  unless it  needs the data in the segment to 
  1473. outlast  the  program itself.  User segments  are always  allocated from  the 
  1474. lowest numbered  free segment  and system  segments from the highest numbered 
  1475. one.
  1476.  
  1477.  
  1478.      An error  from "allocate  segment" usually  indicates that  there are no 
  1479. free segments, although it can also mean that an invalid parameter was passed 
  1480. in  register  A  and  B.  An  error  from "free  segment" indicates  that the 
  1481. specified segment number does not exist or is already free.
  1482.  
  1483.  
  1484.  
  1485.  
  1486. ALL_SEG - Parameters:   A=0 => allocate user segment
  1487.                         A=1 => allocate system segment
  1488.                         B=0 => allocate primary mapper
  1489.                        B!=0 => allocate 
  1490.                        FxxxSSPP slot address (primary mapper, if 0)
  1491.                         xxx=000 allocate specified slot only
  1492.                         xxx=001 allocate other slots than specified
  1493.                         xxx=010 try  to allocate  specified slot  and, if  it 
  1494.                                 failed, try another slot (if any)
  1495.                         xxx=011 try to  allocate other  slots than  specified 
  1496.                                 and, if it failed, try specified slot
  1497.           Results:      Carry set   => no free segments
  1498.                         Carry clear => segment allocated
  1499.                                        A=new segment number
  1500.                                        B=slot  address of  mapper slot  (0 if 
  1501.                                          called as B=0)
  1502.  
  1503.  
  1504. FRE_SEG - Parameters:   A=segment number to free
  1505.                         B=0 primary mapper
  1506.                         B!=0 mapper other than primary
  1507.           Returns:      Carry set => error
  1508.                         Carry clear => segment freed OK 
  1509.  
  1510.  
  1511.  
  1512.    5.5   INTER-SEGMENT READ AND WRITE
  1513.  
  1514.      The  following two routines can be called to read or write a single byte 
  1515. from any  mapper RAM  segment. The  calling sequence  is very  similar to the 
  1516. inter-slot  read  and  write routines  provided by  the MSX  system ROM.  All 
  1517. registers  apart from AF are preserved and no checking is done to ensure that 
  1518. the segment number is valid.
  1519.  
  1520.      The  top two bits of the address are ignored and the data will be always 
  1521. read or  written via page-2, since the segment number specifies a 16k segment 
  1522. which could appear in any of the four pages. The data will be read or written 
  1523. from  the correct  segment regardless of the current paging or slot selection 
  1524. in page-0  or page-1,  but note  that the mapper RAM slot must be selected in 
  1525. page-2 when either of these routines are called. This is so that the routines 
  1526. do  not have to do any slot switching and so can be fast. Also the stack must 
  1527. not be in page-2. These routines will return disabling interrupts.
  1528.  
  1529. RD_SEG -  Parameters:   A = segment number to read from
  1530.                        HL = address within this segment
  1531.           Results:      A = value of byte at that address
  1532.                         All other registers preserved 
  1533.  
  1534.  
  1535. WR_SEG -  Parameters:   A = segment number to write to
  1536.                        HL = address within this segment
  1537.                         E = value to write 
  1538.           Returns:      A = corrupted
  1539.                         All other registers preserved 
  1540.  
  1541.  
  1542.    5.6   INTER-SEGMENT CALLS
  1543.  
  1544.      Two  routines  are  provided  for doing  inter-segment calls.  These are 
  1545. modelled very closely on the two inter-slot call routines provided by the MSX 
  1546. system ROM, and the specification of their usage is very similar.
  1547.  
  1548.      No  check is  done that  the called segment actually exists so it is the 
  1549. user's responsibility  to ensure  this. The called segment will be paged into 
  1550. the  specified address  page, but  it is  the user's responsibility to ensure 
  1551. that the mapper slot is enabled in this page, since neither of these routines 
  1552. will alter  the slot  selection at  all. This  is to  ensure that they can be 
  1553. fast.
  1554.  
  1555.      The routine  cannot be  used to do an inter-segment call into page-3. If 
  1556. this  is attempted then the specified address in page-3 will simply be called 
  1557. without any  paging, since  page-3 must never be altered. Calling into page-0 
  1558. must  be done  with some care because of the interrupt and other entry point. 
  1559. Also care must be taken that the stack is not paged out by these calls.
  1560.  
  1561.  
  1562.      These  routines,  unlike  inter-slot  calls,  do not  disable interrupts 
  1563. before passing control to the called routine. So they return to the caller in 
  1564. the  same state  as before,  unless the  interrupt flag  was modified  by the 
  1565. called routine.
  1566.  
  1567.  
  1568.      Parameters cannot  be passed  in registers  IX, IY, AF', BC', DE' or HL' 
  1569. since  these are  used internally  in the  routine. These  registers will  be 
  1570. corrupted by  the inter-segment  call and may also be corrupted by the called 
  1571. routine. All other registers (AF, BC, DE and HL) will be passed intact to the 
  1572. called routine and returned from it to the caller.
  1573.  
  1574.  
  1575.  
  1576. CAL_SEG - Parameters: IY = segment number to be called
  1577.                       IX = address to call
  1578.                       AF, BC, DE, HL passed to called routine
  1579.                       Other registers corrupted
  1580.           Results:    AF, BC, DE, HL, IX and IY returned from called routine. 
  1581.                       All others corrupted.
  1582.  
  1583.  
  1584. CALLS -   Parameters: AF, BC, DE, HL passed to called routine
  1585.                       Other registers corrupted
  1586.           Calling sequence:   CALL  CALLS
  1587.                               DB    SEGMENT
  1588.                               DW    ADDRESS  
  1589.           Results:    AF, BC, DE, HL, IX and IY returned from called routine. 
  1590.                       All others corrupted.
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.    5.7   DIRECT PAGING ROUTINES
  1597.  
  1598.      The  following  routines  are  provided  to allow  programs to  directly 
  1599. manipulate  the current  paging state  without having to access the hardware. 
  1600. Using these routines ensures compatibility with any changes to the details of 
  1601. the  hardware.  The  routines  are  very  fast  and  so using  them will  not 
  1602. compromise the performance of programs.
  1603.  
  1604.  
  1605.      Routines are  provided to directly read or write to any of the four page 
  1606. registers.  No checking of the validity of the segment number is done so this 
  1607. is the  user's responsibility. Note that the value written in the register is 
  1608. also  written in  memory and,  if the  register value is requested, the value 
  1609. stored in  memory will  be returned and the one in the register will never be 
  1610. read  directly. This  is done  to avoid  errors from  hardware conflicts when 
  1611. there are  two or more mapper registers in the system. The user should always 
  1612. manipulate the memory mapper through these routines.
  1613.  
  1614.  
  1615.      The "GET"  routines return  values from internal images of the registers 
  1616. without  actually reading  the registers  themselves. This  ensures that if a 
  1617. segment is  enabled by, for example, "PUT_P1" then a subsequent "GET_P1" call 
  1618. will  return the  actual value.  Reading the  mapper register  may produce  a 
  1619. different value because the top bits of the segment numbers are generally not 
  1620. recorded.
  1621.  
  1622.  
  1623.      Although  a "PUT_P3"  routine is provided, it is in fact a dummy routine 
  1624. and will  not alter  the page-3 register. This is because the contents of the 
  1625. page-3  register should never be altered. The "GET_P3" routine does behave as 
  1626. expected to allow the user to determine what segment is in page-3.
  1627.  
  1628.  
  1629.      Another  pair of  routines ("GET_PH" and "PUT_PH") is provided which are 
  1630. identical in  function except  that the page is specified by the top two bits 
  1631. of register H. This is useful when register HL contains an address, and these 
  1632. routines  do not  corrupt register  HL. "PUT_PH"  will never alter the page-3 
  1633. register.
  1634.  
  1635.  
  1636.  
  1637. PUT_Pn -  Parameters:   n = 0,1,2 or 3 to select page
  1638.                         A = segment number
  1639.           Results:      None
  1640.                         All registers preserved 
  1641.  
  1642.  
  1643. GET_Pn -  Parameters:   n = 0,1,2 or 3 to select page
  1644.           Results:      A = segment number
  1645.                         All other registers preserved 
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651. PUT_PH -  Parameters:   H = high byte of address
  1652.                         A = segment number
  1653.           Results:      None
  1654.                         All registers preserved
  1655.  
  1656.  
  1657. GET_PH -  Parameters:   H = high byte of address
  1658.           Results:      A = segment number
  1659.                         All other registers preserved 
  1660.  
  1661.  
  1662.  
  1663.      Before  using these  direct paging routines to alter the paging state, a 
  1664. program should  first use the "GET_Pn" routines to determine the initial four 
  1665. segments  for when  it needs to restore these. No program should assume fixed 
  1666. values for  these initial  segments since they are likely to change in future 
  1667. versions of the system.
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706. 6.   ERRORS
  1707. ===========
  1708.  
  1709.  
  1710.      All  the new  MSX-DOS 2  functions (function  codes above 40h) return an 
  1711. "error code" in A. This is zero if the operation was successful. If non-zero, 
  1712. then the error code explains the exact nature of the error.
  1713.  
  1714.      Since  MSX-DOS  2  performs  an  "OR A"  instruction immediately  before 
  1715. returning  from a  function call,  a "JR NZ" instruction is often used in the 
  1716. transient program  immediately after the "CALL 5" instruction to test whether 
  1717. an  error occurred.  Frequently the destination of this error jump just loads 
  1718. the error  code into  B and does a "Terminate with Error Code" function. This 
  1719. then  passes the  error code back to the command interpreter which prints the 
  1720. appropriate message.
  1721.  
  1722.      A transient program may also itself get the actual message for any error 
  1723. returned by  an MSX-DOS  2 function  call by  using the  "Explain Error Code" 
  1724. function. See the Function Specification for details.
  1725.  
  1726.      The error codes start at 0FFh and descend in value. Values less than 40h 
  1727. are 'user  errors' and  will never  be used  by the system and can be used by 
  1728. transient programs to return their own errors. User errors below 20h returned 
  1729. to the command interpreter will not have any message printed.
  1730.  
  1731.  
  1732.      If  the   "Explain  Error   Code"  function   call  (see   the  Function 
  1733. Specification) is asked to explain an error code for which it does not have a 
  1734. message,  then the  string returned will be "System error <n>" or "User error 
  1735. <n>" as appropriate, where <n> is the error number.
  1736.  
  1737.  
  1738.      Below  is  a  list  of  all currently  defined error  numbers and  their 
  1739. messages  and meanings.  Also given is the mnemonic, which is often used as a 
  1740. symbol in  a source file and is used throughout the MSX-DOS 2 system to refer 
  1741. to a particular error.
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.    6.1   DISK ERRORS
  1762.  
  1763.      The  errors in  this group  are those  which are  usually passed to disk 
  1764. error handling  routines. By  default they will be reported as "Abort, Retry" 
  1765. errors.  These errors except the one from "format disk" will be passed to the 
  1766. error handling routine, so they will not be returned as the return value from 
  1767. BDOS.
  1768.  
  1769.  
  1770.  
  1771. Incompatible disk (.NCOMP, 0FFh)
  1772.  
  1773.      The disk  cannot be accessed in that drive (eg. a double sided disk in a 
  1774. single sided drive).
  1775.  
  1776.  
  1777.  
  1778. Write error (.WRERR, 0FEh)
  1779.  
  1780.      General error occurred during a disk write.
  1781.  
  1782.  
  1783.  
  1784. Disk error (.DISK, 0FDh)
  1785.  
  1786.      General unknown disk error occurred.
  1787.  
  1788.  
  1789.  
  1790. Not ready (.NRDY, 0FCh)
  1791.  
  1792.      Disk drive did not respond, usually means there is no disk in the drive.
  1793.  
  1794.  
  1795.  
  1796. Verify error (.VERFY, 0FBh)
  1797.  
  1798.      With  VERIFY enabled,  a sector  could not be read correctly after being 
  1799. written.
  1800.  
  1801.  
  1802.  
  1803. Data error (.DATA, 0FAh)
  1804.  
  1805.      A disk  sector could  not be  read because  the CRC  error checking  was 
  1806. incorrect, usually indicating a damaged disk.
  1807.  
  1808.  
  1809.  
  1810. Sector not found (.RNF, 0F9h)
  1811.  
  1812.      The  required sector  could not  be found  on the  disk, usually means a 
  1813. damaged disk.
  1814.  
  1815.  
  1816.  
  1817. Write protected disk (.WPROT, 0F8h)
  1818.  
  1819.      Attempt to write to a disk with the write protect tab on.
  1820.  
  1821.  
  1822.  
  1823. Unformatted disk (.UFORM, 0F7h)
  1824.  
  1825.      The disk  has not  been formatted,  or it  is a  disk using  a different 
  1826. recording technique.
  1827.  
  1828.  
  1829.  
  1830. Not a DOS disk (.NDOS, 0F6h)
  1831.  
  1832.      The  disk  is  formatted  for  another  operating  system and  cannot be 
  1833. accessed by MSX-DOS.
  1834.  
  1835.  
  1836.  
  1837. Wrong disk (.WDISK, 0F5h)
  1838.  
  1839.      The  disk has  been changed while MSX-DOS was accessing it. Must replace 
  1840. the correct disk.
  1841.  
  1842.  
  1843.  
  1844. Wrong disk for file (.WFILE, 0F4h)
  1845.  
  1846.      The  disk  has been  changed while  there is  an open  file on  it. Must 
  1847. replace the correct disk.
  1848.  
  1849.  
  1850.  
  1851. Seek error (.SEEK, 0F3h)
  1852.  
  1853.      The required track of the disk could not be found.
  1854.  
  1855.  
  1856.  
  1857. Bad file allocation table (.IFAT, 0F2h)
  1858.  
  1859.      The file  allocation table  on the disk has got corrupted. CHKDSK may be 
  1860. able to recover some of the data on the disk.
  1861.  
  1862.  
  1863.  
  1864. (.NOUPB, 0F1h)
  1865.  
  1866.      This  error has  no message  because it  is always trapped internally in 
  1867. MSX-DOS as part of the disk change handling.
  1868.  
  1869.  
  1870.  
  1871. Cannot format this drive (.IFORM, 0F0h)
  1872.  
  1873.      Attempt to  format a drive which does not allow formatting. Usually as a 
  1874. result of trying to format the RAM disk.
  1875.  
  1876.  
  1877.  
  1878.  
  1879.    6.2   MSX-DOS FUNCTION ERRORS
  1880.  
  1881.      The  following errors are those which are normally returned from MSX-DOS 
  1882. function calls. See the Function Specification document for details of errors 
  1883. from particular MSX-DOS functions.
  1884.  
  1885.  
  1886.  
  1887. Internal error (.INTER, 0DFh)
  1888.  
  1889.      Should never occur. 
  1890.  
  1891.  
  1892. Not enough memory (.NORAM, 0DEh)
  1893.  
  1894.      MSX-DOS  has  run out  of memory  in its  16k kernel  data segment.  Try 
  1895. reducing the  number of  sector buffers or removing some environment strings. 
  1896. Also occurs if there are no free segments for creating the RAMdisk.
  1897.  
  1898.  
  1899.  
  1900. Invalid MSX-DOS call (.IBDOS, 0DCh)
  1901.  
  1902.      An  MSX-DOS call  was made with an illegal function number. Most illegal 
  1903. function calls  return no  error, but  this error  may be  returned if a "get 
  1904. previous error code" function call is made.
  1905.  
  1906.  
  1907.  
  1908. Invalid drive (.IDRV, 0DBh)
  1909.  
  1910.      A  drive number parameter, or a drive letter in a drive/path/file string 
  1911. is one which does not exist in the current system.
  1912.  
  1913.  
  1914.  
  1915. Invalid filename (.IFNM, 0DAh)
  1916.  
  1917.      A filename  string is  illegal. This is only generated for pure filename 
  1918. strings, not drive/path/file strings. 
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926. Invalid pathname (.IPATH, 0D9h)
  1927.  
  1928.      Can  be  returned  by  any  function  call  which  is  given  an  ASCIIZ 
  1929. drive/path/file  string. Indicates that the syntax of the string is incorrect 
  1930. in some way.
  1931.  
  1932.  
  1933.  
  1934. Pathname too long (.PLONG, 0D8h)
  1935.  
  1936.      Can  be  returned  by  any  function  call  which  is  given  an  ASCIIZ 
  1937. drive/path/file  string.  Indicates that  the complete  path being  specified 
  1938. (including current directory if used) is longer than 63 characters.
  1939.  
  1940.  
  1941.  
  1942. File not found (.NOFIL, 0D7h)
  1943.  
  1944.      Can be  returned by  any function  which looks for files on a disk if it 
  1945. does  not find  one. This error is also returned if a directory was specified 
  1946. but not found. In other cases, .NODIR error (see below) will be returned.
  1947.  
  1948.  
  1949.  
  1950. Directory not found (.NODIR, 0D6h)
  1951.  
  1952.      Returned if  a directory  item in  a drive/path/file string could not be 
  1953. found.
  1954.  
  1955.  
  1956.  
  1957. Root directory full (.DRFUL, 0D5h)
  1958.  
  1959.      Returned  by "create"  or "move"  if a new entry is required in the root 
  1960. directory and it is already full. The root directory cannot be extended.
  1961.  
  1962.  
  1963.  
  1964. Disk full (.DKFUL, 0D4h)
  1965.  
  1966.      Usually results from a write operation if there was insufficient room on 
  1967. the disk for the amount of data being written. May also result from trying to 
  1968. create or extend a sub-directory if the disk is completely full.
  1969.  
  1970.  
  1971.  
  1972. Duplicate filename (.DUPF, 0D3h)
  1973.  
  1974.      Results  from  "rename" or  "move" if  the destination  filename already 
  1975. exists in the destination directory.
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981. Invalid directory move (.DIRE, 0D2h)
  1982.  
  1983.      Results from  an attempt  to move  a sub-directory  into one  of its own 
  1984. descendants.  This is  not allowed as it would create an isolated loop in the 
  1985. directory structure.
  1986.  
  1987.  
  1988.  
  1989. Read only file (.FILRO, 0D1h)
  1990.  
  1991.      Attempt to write to or delete a file which has the "read only" attribute 
  1992. bit set.
  1993.  
  1994.  
  1995.  
  1996. Directory not empty (.DIRNE, 0D0h)
  1997.  
  1998.      Attempt to delete a sub-directory which is not empty.
  1999.  
  2000.  
  2001.  
  2002. Invalid attributes (.IATTR, 0CFh)
  2003.  
  2004.      Can result  from an  attempt to change a file's attributes in an illegal 
  2005. way,  or trying  to do  an operation  on a  file which  is only possible on a 
  2006. sub-directory. Also results from illegal use of volume name fileinfo blocks.
  2007.  
  2008.  
  2009.  
  2010. Invalid . or .. operation (.DOT, 0CEh)
  2011.  
  2012.      Attempt to  do an  illegal operation  on the  "." or  ".." entries  in a 
  2013. sub-directory, such as rename or move them.
  2014.  
  2015.  
  2016.  
  2017. System file exists (.SYSX, 0CDh)
  2018.  
  2019.      Attempt  to  create  a  file  or sub-directory  of the  same name  as an 
  2020. existing system file. System files are not automatically deleted.
  2021.  
  2022.  
  2023.  
  2024. Directory exists (.DIRX, 0CCh)
  2025.  
  2026.      Attempt  to  create  a  file  or sub-directory  of the  same name  as an 
  2027. existing sub-directory. Sub-directories are not automatically deleted.
  2028.  
  2029.  
  2030.  
  2031. File exists (.FILEX, 0CBh)
  2032.  
  2033.      Attempt  to create a sub-directory of the same name as an existing file. 
  2034. Files are not automatically deleted when creating sub-directories.
  2035.  
  2036.  
  2037.  
  2038. File already in use (.FOPEN, 0CAh)
  2039.  
  2040.      Attempt to  delete, rename,  move, or  change the attributes or date and 
  2041. time  of a  file which  has a  file handle  already open to it, other than by 
  2042. using the file handle itself.
  2043.  
  2044.  
  2045.  
  2046. Cannot transfer above 64K (.OV64K, 0C9h)
  2047.  
  2048.      Disk transfer area would have extended above 0FFFFh.
  2049.  
  2050.  
  2051.  
  2052. File allocation error (.FILE, 0C8h)
  2053.  
  2054.      The cluster  chain for a file was corrupt. Use CHKDSK to recover as much 
  2055. of the file as possible.
  2056.  
  2057.  
  2058.  
  2059. End of file (.EOF, 0C7h)
  2060.  
  2061.      Attempt  to read  from a  file when  the file  pointer is  already at or 
  2062. beyond the end of file.
  2063.  
  2064.  
  2065.  
  2066. File access violation (.ACCV, 0C6h)
  2067.  
  2068.      Attempt to  read or  write to  a file  handle which  was opened with the 
  2069. appropriate  access bit  set. Some of the standard file handles are opened in 
  2070. read only or write only mode.
  2071.  
  2072.  
  2073.  
  2074. Invalid process id (.IPROC, 0C5h)
  2075.  
  2076.      Process id number passed to "join" function is invalid.
  2077.  
  2078.  
  2079.  
  2080. No spare file handles (.NHAND, 0C4h)
  2081.  
  2082.      Attempt  to  open or  create a  file handle  when all  file handles  are 
  2083. already in use. There are 64 file handles available in the current version.
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091. Invalid file handle (.IHAND, 0C3h)
  2092.  
  2093.      The  specified  file handle  is greater  than the  maximum allowed  file 
  2094. handle number.
  2095.  
  2096.  
  2097.  
  2098. File handle not open (.NOPEN, 0C2h)
  2099.  
  2100.      The specified file handle is not currently open.
  2101.  
  2102.  
  2103.  
  2104. Invalid device operation (.IDEV, 0C1h)
  2105.  
  2106.      Attempt to  use a  device file  handle or  fileinfo block for an invalid 
  2107. operation such as searching in it or moving it.
  2108.  
  2109.  
  2110.  
  2111. Invalid environment string (.IENV, 0C0h)
  2112.  
  2113.      Environment item name string contains an invalid character.
  2114.  
  2115.  
  2116.  
  2117. Environment string too long (.ELONG, 0BFh)
  2118.  
  2119.      Environment  item name or value string is either longer than the maximum 
  2120. allowed length of 255, or is too long for the user's buffer.
  2121.  
  2122.  
  2123.  
  2124. Invalid date (.IDATE, 0BEh)
  2125.  
  2126.      Date parameters passed to "set date" are invalid.
  2127.  
  2128.  
  2129.  
  2130. Invalid time (.ITIME, 0BDh)
  2131.  
  2132.      Time parameters passed to "set time" are invalid.
  2133.  
  2134.  
  2135.  
  2136. RAM disk (drive H:) already exists (.RAMDX, 0BCh)
  2137.  
  2138.      Returned from the "ramdisk" function if trying to create a RAM disk when 
  2139. one already exists.
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146. RAM disk does not exist (.NRAMD, 0BBh)
  2147.  
  2148.      Attempt to  delete the  RAM disk  when it  does not  currently exist.  A 
  2149. function  which tries  to access  a non-existent  RAM disk  will get  a .IDRV 
  2150. error.
  2151.  
  2152.  
  2153.  
  2154. File handle has been deleted (.HDEAD, 0BAh)
  2155.  
  2156.      The file  associate with  a file  handle has  been deleted  so the  file 
  2157. handle can no longer be used.
  2158.  
  2159.  
  2160.  
  2161. (.EOL, 0B9h)
  2162.  
  2163.      Internal error should never occur.
  2164.  
  2165.  
  2166.  
  2167. Invalid sub-function number (.ISBFN, 0B8h)
  2168.  
  2169.      The  sub-function number passed to the IOCTL function (function 4Bh) was 
  2170. invalid.
  2171.  
  2172.  
  2173.  
  2174.  
  2175.    6.3   PROGRAM TERMINATION ERRORS
  2176.  
  2177.      The following  errors are those which may be generated internally in the 
  2178. system  and passed  to "abort"  routines. They  will not normally be returned 
  2179. from function  calls. Note that an abort routine can also be passed any error 
  2180. which  a transient program passes to the "terminate with error code" function 
  2181. call.
  2182.  
  2183.  
  2184.  
  2185. Ctrl-STOP pressed (.STOP, 09Fh)
  2186.  
  2187.      The Ctrl-STOP key is tested in almost all places in the system including 
  2188. all character I/O.
  2189.  
  2190.  
  2191.  
  2192. Ctrl-C pressed (.CTRLC, 09Eh)
  2193.  
  2194.      Ctrl-C is  only tested  for on  those character  functions which specify 
  2195. status checks.
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201. Disk operation aborted (.ABORT, 09Dh)
  2202.  
  2203.      This  error  occurs  when  any  disk  error  is aborted  by the  user or 
  2204. automatically  by the  system. The original disk error code will be passed to 
  2205. the abort routine in B as the secondary error code.
  2206.  
  2207.  
  2208.  
  2209. Error on standard output (.OUTERR, 09Ch)
  2210.  
  2211.      Returned if any error occurred on a standard output channel while it was 
  2212. being  accessed through  the character  functions (functions  01h...0Bh). The 
  2213. original error  code is  passed to  the abort  routine in  register B  as the 
  2214. secondary  error code.  This error  will normally only occur if a program has 
  2215. altered the standard file handles.
  2216.  
  2217.  
  2218.  
  2219. Error on standard input (.INERR, 09Bh)
  2220.  
  2221.      Returned if  any error occurred on a standard input channel while it was 
  2222. being  accessed through  the character  functions (functions  01h...0Bh). The 
  2223. original error  code is  passed to  the abort  routine in  register B  as the 
  2224. secondary error code. The most likely error is end of file (.EOF). This error 
  2225. will normally only occur if a program has altered the standard file handles.
  2226.  
  2227.  
  2228.  
  2229.  
  2230.    6.4   COMMAND ERRORS
  2231.  
  2232.      The following errors will not be returned from an MSX-DOS function call, 
  2233. but  are used  by the  command interpreter.  They are included here because a 
  2234. transient program  may find  it useful  to return  some of them. The "Command 
  2235. Specification"  document gives  more details  of what these errors means from 
  2236. the command interpreter.
  2237.  
  2238.  
  2239.  
  2240. Wrong version of COMMAND (.BADCOM, 08Fh)
  2241.  
  2242.      COMMAND2.COM loaded  it's transient part from disk but it's checksum was 
  2243. not what was expected.
  2244.  
  2245.  
  2246.  
  2247. Unrecognized command (.BADCM, 08Eh)
  2248.  
  2249.      A  given command was not an internal command and a .COM or .BAT file was 
  2250. not found with the same name.
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256. Command too long (.BUFUL, 08Dh)
  2257.  
  2258.      The command in a batch file exceeded 127 characters in length.
  2259.  
  2260.  
  2261.  
  2262. (.OKCMD, 08Ch)
  2263.  
  2264.      An internal  error used after executing a command passed to COMMAND2.COM 
  2265. on the command line. (There is no message for this error code.)
  2266.  
  2267.  
  2268.  
  2269. Invalid parameter (.IPARM,      08Bh)
  2270.  
  2271.      The  parameter to  a command was invalid in some way eg. a number out of 
  2272. range.
  2273.  
  2274.  
  2275.  
  2276. Too many parameters (.INP, 08Ah)
  2277.  
  2278.      After parsing  all the  parameters required  for a  command, there  were 
  2279. still more non-separator characters on the command line.
  2280.  
  2281.  
  2282.  
  2283. Missing parameter (.NOPAR, 089h)
  2284.  
  2285.      Where a parameter was expected the end of line was found.
  2286.  
  2287.  
  2288.  
  2289. Invalid option (.IOPT, 088h)
  2290.  
  2291.      The  letter given  after a  / on  the command  line was invalid for that 
  2292. command.
  2293.  
  2294.  
  2295.  
  2296. Invalid number (.BADNO, 087h)
  2297.  
  2298.      Non-digit characters appeared where a number was expected.
  2299.  
  2300.  
  2301.  
  2302. File for HELP not found (.NOHELP, 086h)
  2303.  
  2304.      The  help  file was  not found  or the  parameter was  not a  valid HELP 
  2305. parameter.
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311. Wrong version of MSX-DOS (.BADVER, 085h)
  2312.  
  2313.      This error  is never  used by  the command  interpreter, it  has its own 
  2314. internal  message  for  this  error.  However  it  is provided  for transient 
  2315. programs which may find it useful to return this error. 
  2316.  
  2317.  
  2318. Cannot concatenate destination file (.NOCAT, 084h)
  2319.  
  2320.      The destination file in CONCAT is matched by the source specification.
  2321.  
  2322.  
  2323.  
  2324. Cannot create destination file (.BADEST, 083h)
  2325.  
  2326.      In COPY, creating the destination file would overwrite one of the source 
  2327. files (or another file that is already in use).
  2328.  
  2329.  
  2330.  
  2331. File cannot be copied onto itself (.COPY, 082h)
  2332.  
  2333.      In  COPY, the  destination file  if created  would overwrite  the source 
  2334. file.
  2335.  
  2336.  
  2337.  
  2338. Cannot overwrite previous destination file (.OVDEST, 081h)
  2339.  
  2340.      In  COPY,  an  ambiguous  source  was  specified  with  a non-ambiguous, 
  2341. non-directory, non-device destination.
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.                               * * * * *
  2353.