@nataliapc/mcp-openmsx 1.1.5 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +38 -0
  2. package/dist/server.js +110 -23
  3. package/dist/utils.js +17 -0
  4. package/package.json +4 -1
  5. package/resources/audio/toc.json +31 -0
  6. package/resources/bios/Calling_BIOS_from_MSX-DOS.md +75 -0
  7. package/resources/bios/MSX2_SUBROM_BIOS_calls.md +734 -0
  8. package/resources/bios/MSX_BIOS_calls.md +1046 -0
  9. package/resources/bios/toc.json +24 -0
  10. package/resources/book--msx2-technical-handbook/Appendix1__BIOS_Listing.md +1464 -0
  11. package/resources/book--msx2-technical-handbook/Appendix2__Math-Pack.md +427 -0
  12. package/resources/book--msx2-technical-handbook/Appendix3__Bit_Block_Transfer.md +182 -0
  13. package/resources/book--msx2-technical-handbook/Appendix4__Work_Area_Listing.md +1637 -0
  14. package/resources/book--msx2-technical-handbook/Appendix5__VRAM_Map.md +145 -0
  15. package/resources/book--msx2-technical-handbook/Appendix6__IO_Map.md +128 -0
  16. package/resources/book--msx2-technical-handbook/Appendix8_10__Control_Codes_and_Escape_Sequences.md +76 -0
  17. package/resources/book--msx2-technical-handbook/Chapter1__MSX_System_Overview.md +402 -0
  18. package/resources/book--msx2-technical-handbook/Chapter2__BASIC.md +2148 -0
  19. package/resources/book--msx2-technical-handbook/Chapter3__MSX-DOS.md +2577 -0
  20. package/resources/book--msx2-technical-handbook/Chapter4a__VDP_and_Display_Screen.md +2052 -0
  21. package/resources/book--msx2-technical-handbook/Chapter4b__VDP_and_Display_Screen.md +3311 -0
  22. package/resources/book--msx2-technical-handbook/Chapter5a__Access_to_Peripherals_through_BIOS.md +2714 -0
  23. package/resources/book--msx2-technical-handbook/Chapter5b__Access_to_Peripherals_through_BIOS.md +1263 -0
  24. package/resources/book--msx2-technical-handbook/MSX_Kun_BASIC_Compiler.md +220 -0
  25. package/resources/book--msx2-technical-handbook/toc.json +82 -0
  26. package/resources/book--the-msx-red-book/the_msx_red_book.md +10349 -0
  27. package/resources/book--the-msx-red-book/toc.json +12 -0
  28. package/resources/msx-dos/MSX-DOS_2_Function_Specifications.md +1366 -0
  29. package/resources/msx-dos/MSX-DOS_2_Program_Interface_Specification.md +963 -0
  30. package/resources/msx-dos/toc.json +18 -0
  31. package/resources/msx-unapi/Ethernet_UNAPI_specification_1.1.md +369 -0
  32. package/resources/msx-unapi/Introduction_to_MSX-UNAPI.md +132 -0
  33. package/resources/msx-unapi/MSX_UNAPI_specification_1.1.md +679 -0
  34. package/resources/msx-unapi/TCP-IP_UNAPI_specification.md +2361 -0
  35. package/resources/msx-unapi/toc.json +27 -0
  36. package/resources/others/toc.json +11 -0
  37. package/resources/processors/Z80_R800_instruction_set.md +482 -0
  38. package/resources/processors/toc.json +24 -0
  39. package/resources/processors/z80-undocumented.tex +5617 -0
  40. package/resources/processors/z80_detailed_instruction_set.md +2025 -0
  41. package/resources/programming/toc.json +121 -0
  42. package/resources/system/MSX_IO_ports_overview.md +554 -0
  43. package/resources/system/toc.json +18 -0
  44. package/resources/video/V9938_Technical_Data_Book.md +3623 -0
  45. package/resources/video/V9958_Technical_Data_Book.md +417 -0
  46. package/resources/video/V9990_Programmers_Manual_Banzai.html +1582 -0
  47. package/resources/video/VDP_TMS9918A.txt +709 -0
  48. package/resources/video/toc.json +28 -0
@@ -0,0 +1,2577 @@
1
+ # CHAPTER 3 - MSX-DOS
2
+
3
+ Large capacity storage devices with high-speed access are necessary for business applications. That is why a disk operating system was added to the MSX machine. The DOS (disk operating system) is also required to handle the large amount of data on the disk effectively. MSX-DOS is derived from MS-DOS which is used widely on 16-bit machines. Thus, it represents the most powerful DOS environment for Z-80 based machines. Chapter 3 describes the basic operations of MSX-DOS and the use of the system calls.
4
+
5
+ <p>&nbsp;</p>
6
+
7
+ ## Index
8
+
9
+ - [1. OVERVIEW](#1--overview)
10
+ - [1.1 Features of MSX-DOS](#11-features-of-msx-dos)
11
+ - [1.2 MSX-DOS Environment](#12-msx-dos-environment)
12
+ - [1.3 MSX-DOS System Resources](#13-msx-dos-system-resources)
13
+ - [2. OPERATION](#2--operation)
14
+ - [2.1 Basic Operations](#21-basic-operations)
15
+ - [2.2 Internal commands](#22-internal-commands)
16
+ - [2.3 Batch Command Usage](#23--batch-command-usage)
17
+ - [2.4 External Commands](#24-external-commands)
18
+ - [3. STRUCTURE OF DISK FILES](#3--structure-of-disk-files)
19
+ - [3.1 Data units on the disk](#31-data-units-on-the-disk)
20
+ - [3.2 File Access](#32-file-access)
21
+ - [4. SYSTEM CALL USAGE](#4--system-call-usage)
22
+ - [4.1 Peripheral I/O](#41-peripheral-io)
23
+ - [4.2 Environment Setting and Readout](#42-environment-setting-and-readout)
24
+ - [4.3 Absolute READ/WRITE (direct access to sectors)](#43-absolute-readwrite-direct-access-to-sectors)
25
+ - [4.4 File Access Using FCB](#44-file-access-using-fcb)
26
+ - [Changes from the original](#changes-from-the-original)
27
+
28
+
29
+ <p>&nbsp;</p>
30
+
31
+ ## 1. OVERVIEW
32
+
33
+ What kind of software is MSX-DOS? What does it offer to users? The following sections describe and introduce the features, functions, and software configurations of MSX-DOS.
34
+
35
+
36
+ <p>&nbsp;</p>
37
+
38
+ ### 1.1 Features of MSX-DOS
39
+
40
+ #### Consolidation of disk operating environment
41
+
42
+ MSX-DOS is the disk operating system for MSX computers. It works with any version of MSX and can be operated on both the MSX1 and MSX2 without any problem. Disk operation on MSX is always done via MSX-DOS. This is also true concerning MSX DISK-BASIC, which uses BDOS calls for disk input/output. MSX-DOS and DISK-BASIC use the same disk format so that file conversion between BASIC and DOS is not necessary. This greatly increases operating efficiency and allows more effective use of file resources when MSX-DOS is used as the software development environment.
43
+
44
+
45
+ #### Compatibility with MS-DOS
46
+
47
+ MSX-DOS, created on the basis of MSX-DOS (ver 1.25) which is a disk operating system for 16-bit personal computers, uses the same file format as MS-DOS. It is compatible with MS-DOS at the file level so that MSX-DOS can read and write files written on MS-DOS disks. In turn MS-DOS can read and write files created by MSX-DOS. Both disk operating systems use similar commands, so users who are familiar with MSX-DOS can easily use MS-DOS when upgrading to 16-bit machines.
48
+
49
+
50
+ #### Using CP/M applications
51
+
52
+ MSX-DOS has system call compatibility with CP/M and can execute most programs created on CP/M without any modification. Most CP/M applications can thus be easily used with MSX-DOS. This opens up a large library of existing software which can be run on the MSX machines.
53
+
54
+
55
+ <p>&nbsp;</p>
56
+
57
+ ### 1.2 MSX-DOS Environment
58
+
59
+
60
+ #### System requirements
61
+
62
+ To use MSX-DOS, a minimum configuration of 64K bytes RAM, a CRT, one disk drive, and a disk interface ROM is required. If less than 64K bytes RAM is installed, MSX-DOS cannot be used. MSX computers can only use MSX-DOS if they have 64K bytes RAM or more. Since MSX2 computers always have 64K bytes or more of RAM, they can always run MSX-DOS. A limited disk basic is used on those machines with less than 64K bytes RAM. Disk interface ROM is always supplied with the disk drive, and, on MSX machines with an internal disk drive, it resides inside the machine. For those machines using disk cartridges, it is in the cartridge.
63
+
64
+
65
+ #### System supported
66
+
67
+ MSX-DOS supports up to eight disk drives. On a one-drive system, it has a 2-drive simulation feature (it uses one drive as two drives by replacing diskettes temporarily). It supports keyboard input, screen output, and printer output.
68
+
69
+
70
+ #### Media supported
71
+
72
+ MSX-DOS, which has a flexible file manager that does not depend on the physical structure of the disk, supports various media and uses 3.5 inch double density disks as standard. Either a one-sided disk called 1DD or two-sided disk called 2DD is used. Each of them uses either an 8-sector track format so four kinds of media can be used. The Microsoft formats for these four types are shown below.
73
+
74
+
75
+ ##### _Table 3.1 Media supported by MSX-DOS_
76
+
77
+ ```
78
+ ----------------------------------------------------------------------
79
+ | | 1DD, 9 | 2DD, 9 | 1DD, 8 | 2DD, 8 |
80
+ | | sectors | sectors | sectors | sectors |
81
+ |----------------------------+---------+---------+---------+---------|
82
+ | media ID | 0F8H | 0F9H | 0FAH | 0FBH |
83
+ | number of sides | 1 | 2 | 1 | 2 |
84
+ | tracks per side | 80 | 80 | 80 | 80 |
85
+ | sectors per track | 9 | 9 | 8 | 8 |
86
+ | bytes per sector | 512 | 512 | 512 | 512 |
87
+ | cluster size (in sectors) | 2 | 2 | 2 | 2 |
88
+ | FAT size (in sectors) | 2 | 3 | 1 | 2 |
89
+ | number of FATs | 2 | 2 | 2 | 2 |
90
+ | number of recordable files | 112 | 112 | 112 | 112 |
91
+ ----------------------------------------------------------------------
92
+ ```
93
+
94
+ **Note:** See [Section 3](#3--structure-of-disk-files) for the meanings of the above words.
95
+
96
+
97
+ <p>&nbsp;</p>
98
+
99
+ ### 1.3 MSX-DOS System Resources
100
+
101
+
102
+ #### Memory map
103
+
104
+ MSX-DOS consists of the following modules: COMMAND.COM, MSXDOS.SYS, and a disk interface ROM. It resides in memory as shown in [Figure 3.1](#figure-31--msx-dos-memory-map) when MSX-DOS is active. COMMAND.COM and MSXDOS.SYS are disk files until MSX-DOS is booted and then read into RAM after that. Disk interface ROM includes a disk driver, DOS kernel, and DISK-BASIC interpreter.
105
+
106
+
107
+ ##### _Figure 3.1 MSX-DOS memory map_
108
+
109
+ ```
110
+ 0000H -----------------------
111
+ | system scratch area |
112
+ 0100H |---------------------| --- 4000H ---------------------
113
+ | | ^ | disk driver |
114
+ | | | | DOS kernel |
115
+ | | | | DISK BASIC |
116
+ | | | | interpreter |
117
+ | | TPA 7FFFH ---------------------
118
+ | | |
119
+ | | | disk interface ROM
120
+ |---------------------| |
121
+ | COMMAND.COM | V
122
+ (0006H) |---------------------| ---
123
+ | MSXDOS.SYS |
124
+ |---------------------|
125
+ | work area |
126
+ FFFFH -----------------------
127
+ ```
128
+
129
+
130
+ The area 00H to FFH of RAM is called the system scratch area, which is used by MSX-DOS for exchanging data with other programs. This area is important when using system calls, which are described later. The area which begins at 0100H and ends where the contents of 0006H of RAM indicates is calles the TPA (Transient Program Area). This area is accessible by the user. MSXDOS.SYS always resides at a higher address than TPA (when destroyed, the result is unpredictable), and COMMAND.COM is placed in TPA.
131
+
132
+
133
+ #### COMMAND.COM
134
+
135
+ The main operation of MSX-DOS is to accept typing commands from the keyboard and execute them. In this case the program COMMAND.COM is responsible for the process from getting a string to interpreting and executing it, or accepting commands from the user interface. Programs executed by COMMAND.COM consists of internal commands, batch commands, and external commands.
136
+
137
+ Internal commands are inside COMMAND.COM and on RAM. Typing an internal acommand causes COMMAND.COM to call and execute it immediately.
138
+
139
+ For the external command, COMMAND.COM loads the routine from disk to TPA and executes it (the execution of external commands always begins at 100H). In this case COMMAND.COM frees its own area for the external command. That is, COMMAND.COM might erase itself and writes the external command onto it, when the external command is small enough and does not use the high-end of TPA, COMMAND.COM would not be destroyed. When the external command ends with "RET", MSXDOS.SYS examines whether COMMAND.COM has been destroyed (by using checksum) and, if so, re-loads COMMAND.COM onto RAM and passes the control to COMMAND.COM.
140
+
141
+ Batch commands are carried out by getting command line input from a batch file instead of from the keyboard. Each step of the batch file can execute any internal command or external command. It is possible that the batch command executes another batch command, but the control will not return to the caller after the called batch command is done.
142
+
143
+
144
+ #### MSXDOS.SYS
145
+
146
+ MSXDOS.SYS, core of MSX-DOS, controls disk access and communications with peripherals. These MSXDOS.SYS functions are opened as "BDOS (Basic Disk Operating System)" so that the user can use them. Each routine opened is called a "system call", which is useful in developping software for managing the disk (see [section 4](#4--system-call-usage)). Each execution is, however, not done by MSXDOS.SYS itself but DOS kernel. MSXDOS.SYS is an intermediation which arranges input/output requests from COMMAND.COM or external commands and passes them to the DOS kernel.
147
+
148
+ MSXDOS.SYS includes a portion called BIOS other than BDOS, as shown in [Figure 3.2](#figure-32--msxdossys). BIOS, which has been prepared to be compatible with CP/M, is not normally used.
149
+
150
+
151
+ ##### _Figure 3.2 MSXDOS.SYS_
152
+
153
+ ```
154
+ -------------- --+
155
+ | BDOS | |
156
+ |------------| | MSXDOS.SYS
157
+ | BIOS | |
158
+ -------------- --+
159
+ ```
160
+
161
+ #### DOS kernel
162
+
163
+ The DOS kernel is the fundamental input/output routine which resides in the disk interface ROM and executes BDOS functions of MSXDOS.SYS. Actually, any system call function can be executed using the DOS kernel. DISK-BASIC executes system calls by calling the DOS kernel directly.
164
+
165
+
166
+ #### Procedure for invoking MSX-DOS
167
+
168
+ MSX-DOS is invoked by the following procedure:
169
+
170
+ 1. Resetting MSX causes all the slots to be examined first, and when two bytes, 41H and 42H, are written in the top of the examined slot, the slot is interpreted as connected to a certain ROM. When connected with ROM, the INIT (initialize) routine whose address is set to the header portion of ROM is carried out. In the case of the INIT routine of the disk interface ROM, the work area for the drive connected to the interface is allocated first.
171
+
172
+ 2. When all slots have been examined, FEDAH (H.STKE) is then referred to. Unless the contents of this address is C9H (unless a certain routine is set to the hook of H.STKE during INIT routine), the environment for DISK-BASIC is prepared and execution jumps to H.STKE.
173
+
174
+ 3. When the contents of H.STKE is C9H in the examination above, the cartridge with TEXT entry is searched in each slot and, if found, the environment for DISK-BASIC is prepared, and then the BASIC program at the cartridge is carried out.
175
+
176
+ 4. Then, the contents of the boot sector (logical sector #0) is transferred to C000H to C0FFH. At this time, when "DRIVE NOT READY" or "READ ERROR" occurs, or when the top of the transferred sector is neither EBH nor E9H, DISK-BASIC is invoked.
177
+
178
+ 5. The routine at C01EH is called with CY flag reset. Normally, since code "RET NC" is written to this address, nothing is carried and the execution returns. Any boot program written here in assembly language is invoked automatically.
179
+
180
+ 6. RAM capacity is examined (contents of RAM will not be destroyed). Less than 64K bytes causes DISK-BASIC to be invoked.
181
+
182
+ 7. The environment for MSX-DOS is prepared and C01EH is called with a CY flag set. MSXDOS.SYS is loaded from 100H, and the execution jumps to 100H. After this, MSX-DOS transfers itself to a high order address. If MSXDOS.SYS does not exist, DISK-BASIC is invoked.
183
+
184
+ 8. MSXDOS.SYS loads COMMAND.COM from 100H and jumps to its start address. COMMAND.COM also transfers itself to a high order address and then begins to execute. If COMMAND.COM does not exist, the message "INSERT A DISKETTE" appears and the execution waits for the correct diskette to be inserted in the drive.
185
+
186
+ 9. At the first boot for MSX-DOS, when a file named "AUTOEXEC.BAT" exists, it is carried out as a batch file. When MSX-DOS is not invoked and DISK-BASIC starts, if a BASIC program named "AUTOEXEC.BAS" exists, it will be carried out.
187
+
188
+
189
+ <p>&nbsp;</p>
190
+
191
+ ## 2. OPERATION
192
+
193
+ This section describes how to type command line input from the keyboard. This is the basis of MSX-DOS operations. Several examples of actual use and their explanations will be given for the commands used in MSX-DOS.
194
+
195
+
196
+ <p>&nbsp;</p>
197
+
198
+ ### 2.1 Basic Operations
199
+
200
+
201
+ #### Message at startup
202
+
203
+ When MSX-DOS is invoked, the following message appears on the screen:
204
+
205
+
206
+ ##### _Figure 3.3 Screen at atartup_
207
+
208
+ ![Figure 3.3](https://raw.githubusercontent.com/Konamiman/MSX2-Technical-Handbook/master/pics/Figure%203.3.png)
209
+
210
+ The upper two lines show the version of MSXDOS.SYS and its copyright. The last line shows the version of COMMAND.COM.
211
+
212
+
213
+ #### Prompt
214
+
215
+ Then, a prompt (input request symbol) appears under the version description. The prompt for MSX-DOS consists of two characters: the default drive name plus ">".
216
+
217
+
218
+ #### Default drive
219
+
220
+ The term "default drive" as the first character of the prompt is the drive to be accessed automatically when the drive name is omitted. When the default drive is A, for example, referring to a file "BEE" on drive "B" needs to be typed as "B:BEE". A file "ACE" on drive A, however, can be typed simply as "ACE" omitting the drive name.
221
+
222
+ ```
223
+ ex.1) A>DIR B:BEE (⟵ referring to "BEE" on drive B)
224
+ ex.2) A>DIR ACE (⟵ referring to "ACE" on drive A)
225
+ ```
226
+
227
+ #### Changing default drive
228
+
229
+ When using systems with more than one drive, typing "B" causes the default drive to be changed to B. When changing the default drive to C to H, "C" or the appropiate letter is needed. Specfification of a drive which does not exist causes an error.
230
+
231
+ ```
232
+ ex.1) A>B:
233
+ B> (⟵ Default drive has been changed to B)
234
+
235
+ ex.2) A>K:
236
+ Invalid Drive Specification
237
+ A> (⟵ Drive K does not exist. Default drive is not changed.)
238
+ ```
239
+
240
+ #### Command input
241
+
242
+ When a prompt is displayed it indicates that MSX-DOS requests a command to be input. By typing in a command, MSX-DOS can get an instruction.
243
+
244
+ Three forms of commands exist as shown in [Table 3.2](#table-32--three-forms-of-commands). The COMMAND.COM program interprets and executes these commands. MSX-DOS operations are repeats of the actions "give a command - make COMMAND.COM execute it".
245
+
246
+
247
+ ##### _Table 3.2 Three forms of commands_
248
+
249
+ ```
250
+ -------------------------------------------------------------------------
251
+ | (1) Internal | Command inside COMMAND.COM. Assembly routine on RAM. |
252
+ | command | Thirten commands are prepared as described later. |
253
+ |--------------+--------------------------------------------------------|
254
+ | (2) External | Assembly routine on disk. It is loaded from disk at |
255
+ | command | execution. Its file name has an extension "COM". |
256
+ |--------------+--------------------------------------------------------|
257
+ | (3) Batch | Text file containing one or more commands. Commands |
258
+ | command | are executed orderly (batch operation). File names |
259
+ | | have the extension "BAT". |
260
+ -------------------------------------------------------------------------
261
+ ```
262
+
263
+ #### File name convention
264
+
265
+ Files handled by MSX-DOS are expressed by a "file spec" which is described below:
266
+
267
+ (1) File spec is expressed in the form `<drive>:<file name>`.
268
+
269
+ (2) `<drive>` is a character from A to H. When specifying the default drive, it can be omitted as well as the colon ":" following it.
270
+
271
+ (3) `<file name>` is expressed in the form of `<filename>.<extension>`.
272
+
273
+ (4) `<filename>` is a string containing one or more (up to 8) characters. When more than 8 characters are sepcified, the ninth and subsequent characters are ignored.
274
+
275
+ (5) `<extension>` is a string containing up to 3 (including zero) characters. When more than 3 characters are specified, 4th and subsequent chartacters are ignored.
276
+
277
+ (6) `<extension>` can be omitted as well a preceding period ".".
278
+
279
+ (7) Characters which are available in `<filename>` and `<extension>` are shown in [Table 3.3](#table-33--available-characters-for-file-name).
280
+
281
+ (8) Cases are not sensitive. Capital letters and small letters have the same meaning.
282
+
283
+
284
+ ##### _Table 3.3 Available characters for file name_
285
+
286
+ ```
287
+ ---------------------------------------------------------------------------------------
288
+ | Available | A to Z 0 to 9 $ & # % ( ) - @ ^ { } ' ` ! |
289
+ | characters | characters corresponding to character codes 80H to FEH |
290
+ |-------------+-----------------------------------------------------------------------|
291
+ | Unavailable | ~ * + , . / : ; = ? [ ] |
292
+ | characters | characters corresponding to character codes 00H to 20H and 7FH, FFH |
293
+ ---------------------------------------------------------------------------------------
294
+ ```
295
+
296
+ #### Wildcards
297
+
298
+ Using a special character called a "wildcard" in the description of `<filename>` and `<extension>` of the file specification causes files with common characters to be specified. Wildcards are "?" and "\*".
299
+
300
+ ```
301
+ (1) "?" is a substitution for one character.
302
+ ex) "TEXT", "TEST", "TENT" ⟵ "TE?T"
303
+ "F1-2.COM", "F2-6.COM" ⟵ "F?-?.COM"
304
+
305
+ (2) "*" is a substitution for a string with any length.
306
+ ex) "A", "AB", "ABC" ⟵ "A*"
307
+ "files with an extension .COM" ⟵ "*.COM"
308
+ "all files" ⟵ "*.*"
309
+ ```
310
+
311
+ When comparing existing file names and file names with wildcards, the portion less than 8 characters of `<filename>` and the portion less than 3 characters of `<extension>` are considered to be padded with spaces (" "). Thus, a specification "A???.??" is not expanded to "ABCDE.123" but to "AZ.9", as shown in [Figure 3.4](#figure-34--wildcard-expansion).
312
+
313
+
314
+ ##### _Figure 3.4 Wildcard expansion_
315
+
316
+ ![Figure 3.4](https://raw.githubusercontent.com/Konamiman/MSX2-Technical-Handbook/master/pics/Figure%203.4.png)
317
+
318
+ An asterisk (\*) is interpreted as either 8 question marks or 3 question marks (?) depending on if it is in the file name position or file extension position. For example, a file name "A*B" is not interpreted as "any strings which begin with A and end with B". It is interpreted as "any strings which begin with A", as shown below.
319
+
320
+ ```
321
+ A*B ("*" is expanded to 8 "?"s)
322
+ |
323
+ V
324
+ A????????B (Characters after 8th are deleted)
325
+ |
326
+ V
327
+ A???????
328
+ ```
329
+
330
+ #### Device name
331
+
332
+ MSX-DOS does not need special commands for data input/output with peripherals. This means that it considers each objective device as a certain file (device file) and input/output actions are done by reading or writing to or from this file. This enables MSX-DOS users to treat input/output devices in the same way as files on a disk. Five devices are supported as standard by MSX-DOS as shown in [Table 3.4](#table-34--device-names) and are specified with proper names. For this reason, these names can not be used to specify disk files. These device names with drive specifications or extensions are also treated as simple device names.
333
+
334
+
335
+ ##### _Table 3.4 Device names_
336
+
337
+ ```
338
+ --------------------------------------------------------------------------
339
+ | Device name | Input/output device to be specified |
340
+ |-------------+----------------------------------------------------------|
341
+ | | Reserved name for input/output expansion |
342
+ | AUX | which normally has the same effect as NUL |
343
+ | | |
344
+ |-------------+----------------------------------------------------------|
345
+ | | |
346
+ | CON | Console (keyboard for input, screen for OUTPUT) |
347
+ | | |
348
+ |-------------+----------------------------------------------------------|
349
+ | | |
350
+ | LST | Printer (ouput only; cannot be used for input) |
351
+ | | |
352
+ |-------------+----------------------------------------------------------|
353
+ | | |
354
+ | PRN | Printer (same as LST) |
355
+ | | |
356
+ |-------------+----------------------------------------------------------|
357
+ | | Special device used as a dummy when the result is not |
358
+ | NUL | desired to be displayed on the screen or put in a file. |
359
+ | | When used for input, always EOF. |
360
+ --------------------------------------------------------------------------
361
+ ```
362
+
363
+ #### Input functions using a template
364
+
365
+ A "template" is a character buffer area and can be used for command input. The template contains the previous command line most recently entered. It is possible to use the template for easier command entry. By taking advantage of this template feature, it is easy to execute previous commands again or to execute the command partially modified. The keys listed in [Table 3.6](#table-36--template-functions) are used for the template operation.
366
+
367
+
368
+ #### Other special keys
369
+
370
+ In addition to the template operation keys, the following control keys are also available. These special key functions also support some other system calls described later.
371
+
372
+
373
+ ##### _Table 3.5 Special key functions_
374
+
375
+ ```
376
+ ---------------------------------------------------------------
377
+ | | Function |
378
+ |-------+-----------------------------------------------------|
379
+ | ^C | stops command currently executed |
380
+ | ^S | pauses screen output until any key is pressed |
381
+ | ^P | send characters to the printer at the same time |
382
+ | | they appear on the secreen |
383
+ | ^N | resets ^P and send characters only to the secreen |
384
+ | ^J | feeds a line on the screen and continue input |
385
+ ---------------------------------------------------------------
386
+ ```
387
+
388
+ ##### _Table 3.6 Template functions_
389
+
390
+ ```
391
+ -------------------------------------------------------------------------
392
+ | Name | Keys used | Functions |
393
+ |----------+--------------+---------------------------------------------|
394
+ | COPY1 | RIGHT, ^\ | Gets one character from the template and |
395
+ | | | displays it in the command line |
396
+ |----------+--------------+---------------------------------------------|
397
+ | | | Gets characters before the character to be |
398
+ | COPYUP | SELECT, ^X | typed next (by keyboard) from the template |
399
+ | | | and displays them on the command line |
400
+ |----------+--------------+---------------------------------------------|
401
+ | | | Gets all characters from the location which |
402
+ | COPYALL | DOWN, ^_ | the template is currently referring to the |
403
+ | | | end of the line and displays them on the |
404
+ | | | command line |
405
+ |----------+--------------+---------------------------------------------|
406
+ | SKIP1 | DEL | Skips one character of the template |
407
+ |----------+--------------+---------------------------------------------|
408
+ | SKIPUP | CLS, ^L | Skips template characters before the |
409
+ | | | character to be typed next (by keyboard) |
410
+ |----------+--------------+---------------------------------------------|
411
+ | VOID | UP, ESC, ^^, | Discards current line input not changing |
412
+ | | ^U, ^[ | the template |
413
+ |----------+--------------+---------------------------------------------|
414
+ | | | Discards one character input and returns |
415
+ | BS | LEFT, BS, | the location referred by the template |
416
+ | | ^H, ^] | by one character |
417
+ |----------+--------------+---------------------------------------------|
418
+ | | | Switches insert mode/normal input mode, |
419
+ | INSERT | INS, ^R | in insert mode, displays keyboard input |
420
+ | | | on the command line with fixing the |
421
+ | | | location referred by the template |
422
+ |----------+--------------+---------------------------------------------|
423
+ | NEWLINE | HOME, ^K | Transfers the contents of current command |
424
+ | | | line to the template |
425
+ |-------------------------+---------------------------------------------|
426
+ | | Feeds a line on screen but continues |
427
+ | Return | getting input. Transfers the contents of |
428
+ | key | current command line to the template |
429
+ | | and executes it |
430
+ |-------------------------+---------------------------------------------|
431
+ | Keys other | Displays a character corresponding to the |
432
+ | than above | key on the command line and skips one |
433
+ | | character of the template |
434
+ -------------------------------------------------------------------------
435
+ ```
436
+
437
+ ##### _Table 3.7 Template operation examples_
438
+
439
+ ```
440
+ ---------------------------------------------------------------------------
441
+ | | | Contents of template ("-" |
442
+ | Keyboard input | Command line display | indicates location currently |
443
+ | | | referred to) |
444
+ |-------------------+----------------------+------------------------------|
445
+ | DIR ABCDE | A>DIR ABCDE | --------- |
446
+ | | | |
447
+ | RETURN | A> | DIR ABCDE |
448
+ | | | - |
449
+ | DOWN | A>DIR ABCDE | DIR ABCDE |
450
+ | | | - |
451
+ | LEFT LEFT LEFT | A>DIR AB | DIR ABCDE |
452
+ | | | - |
453
+ | INS XYZ | A>DIR ABXYZ | DIR ABCDE |
454
+ | | | - |
455
+ | RIGHT RIGHT RIGHT | A>DIR ABXYZCDE | DIR ABCDE |
456
+ | | | - |
457
+ | UP | A> | DIR ABCDE |
458
+ | | | - |
459
+ | DOWN | A>DIR ABCDE | DIR ABCDE |
460
+ | | | - |
461
+ | UP | A> | DIR ABCDE |
462
+ | | | - |
463
+ | XXX | A>XXX | DIR ABCDE |
464
+ | | | - |
465
+ | DOWN | A>XXX ABCDE | DIR ABCDE |
466
+ | | | - |
467
+ | HOME | A>XXX ABCDE | XXX ABCDE |
468
+ | | | - |
469
+ ---------------------------------------------------------------------------
470
+ ```
471
+
472
+ #### Disk errors
473
+
474
+ When an error occurs during disk access, MSX-DOS retries sometimes. Still more errors cause MSX-DOS to display the following message and inquire what to do with them. Press one of the keys A, R, or I.
475
+
476
+
477
+ ##### _Figure 3.5 Error display_
478
+
479
+ ![Figure 3.5](https://raw.githubusercontent.com/Konamiman/MSX2-Technical-Handbook/master/pics/Figure%203.5.png)
480
+
481
+ The following error might occur other than listed above. It indicates that the pointer in FAT is pointing to a cluster which does not exist. When this error occurs, the diskette will be unusable.
482
+
483
+ ```
484
+ Bad FAT
485
+ ```
486
+
487
+ <p>&nbsp;</p>
488
+
489
+ ### 2.2 Internal commands
490
+
491
+ Internal commands are assembly language programs grouped together in COMMAND.COM. It is not necessary to read them from the disk so they are executed fast. Following are 13 internal commands. This section describes their use.
492
+
493
+ ```
494
+ BASIC ........... jumps to MSX DISK-BASIC
495
+ COPY ............ copies a file
496
+ DATE ............ displays or modifies date
497
+ DEL ............. deletes a files
498
+ DIR ............. displays a list of files
499
+ FORMAT .......... formats a disk
500
+ MODE ............ modifies number of characters to be displayed in one line
501
+ PAUSE ........... pauses a batch command operation
502
+ REM ............. puts a comment line in a batch command
503
+ REN ............. renames a file name
504
+ TIME ............ displays or modifies time
505
+ TYPE ............ prints the contents of a file
506
+ VERIFY .......... turns on/off the verify mode
507
+ ```
508
+
509
+ #### BASIC
510
+
511
+ form: `BASIC [<file spec>]`
512
+
513
+ Starts DISK-BASIC. This is not done by loading BASIC onto RAM but by selecting BASIC-ROM in 0000H to 7FFFH by switching the slot, so it starts immediately. When `<file spec>` is specified, the corresponding BASIC program is automatically read and executed. To return to the MSX-DOS environment from BASIC, execute "CALL SYSTEM".
514
+
515
+
516
+ #### COPY
517
+
518
+ This command copies the contents of one file to another. Specifying parameters enables various options.
519
+
520
+
521
+ _(1) File duplication_
522
+
523
+ form: `COPY <file spec 1> <file spec 2>`
524
+
525
+ Duplicates the file specified by `<file spec 1>` into a file specified by `<file spec 2>`. Files having the same names cannot be created on the same disk. On different disks, specifying the same names is possible.
526
+
527
+ examples:
528
+
529
+ ```
530
+ A>COPY ABC XYZ ⟵ copies file "ABC" and makes a file "XYZ".
531
+
532
+
533
+ A>COPY B:ABC XYZ ⟵ copies a file "ABC" on drive B and makes a file "XYZ".
534
+
535
+ A>COPY B:ABC C:XYZ ⟵ copies a file "ABC" on drive B and makes a file "XYZ" on drive C.
536
+ ```
537
+
538
+ When copying files, either ASCII or binary mode may be selected. The "/A" swith specifies ASCII mode and the "/B" switch specifies binary mode. If no mode is specified, binary mode is selected by default (except when combining files, described in (4) below, when ASCII is the default mode). [Table 3.8](#table-38--ascii-mode-and-binary-mode) shows the differences between the ASCII and the binary modes.
539
+
540
+
541
+ ##### _Table 3.8 ASCII mode and binary mode_
542
+
543
+ ```
544
+ -----------------------------------------------------------------------------
545
+ | | Read from source file | Write to destination file |
546
+ |-----------+-----------------------------------+---------------------------|
547
+ |ASCII mode | ignore after 1AH (file end mark) | add one byte 1AH to end |
548
+ |Binary mode| read as long as physical file size| write without modification|
549
+ -----------------------------------------------------------------------------
550
+ ```
551
+
552
+ examples:
553
+
554
+ ```
555
+ A>COPY/A ABC XYZ ⟵ ABC to XYZ (both files are in ASCII mode)
556
+
557
+ A>COPY ABC/A XYZ/B ⟵ reads ABC in ASCII mode and writes it to XYZ in binary mode
558
+ ```
559
+
560
+ _(2) File duplication to another disk drive_
561
+
562
+ form: `COPY <file spec> [<destination drive>:]`
563
+
564
+ Copies a file specified by `<file spec>` to `<destination drive>` under the same file name. When `<destination drive>` is omitted, it is copied to the default drive. The drive name included in the `<file spec>` must not be the same as the `<destination drive>`.
565
+
566
+ More than one file can be copied by using wildcards in the `<file spec>`. In this case, the file name is displayed on the screen each time the file is copied.
567
+
568
+ examples:
569
+
570
+ ```
571
+ A>COPY *.COM B: ⟵ copies any files with extension "COM" on default drive to drive B
572
+
573
+ A>COPY B:ABC ⟵ copies a file ABC to default drive
574
+ ```
575
+
576
+ _(3) Simultaneous duplication of many files_
577
+
578
+ form:
579
+ ```
580
+ COPY <file spec 1> <file spec 2>
581
+ ------------- -------------
582
+ | |
583
+ wildcard description wildcard description
584
+ ```
585
+
586
+ When `<file spec 2>`, the destination, is described using wildcards, the portions corresponding to wildcards are replaced with corresponding characters in `<file spec 1>`. For example, when
587
+
588
+ ```
589
+ COPY AB-07.021 FL?X*.V??
590
+ ```
591
+
592
+ is executed, it is interpreted as shown in figure 3.6 and a file "FL-X7.V21" is created.
593
+
594
+
595
+ ##### _Figure 3.6 Wildcard specification of destination file_
596
+
597
+ ![Figure 3.6](https://raw.githubusercontent.com/Konamiman/MSX2-Technical-Handbook/master/pics/Figure%203.6.png)
598
+
599
+ Using wildcards in the specification of `<file spec 1>` enables the duplication of many files at the same time.
600
+
601
+ examples:
602
+
603
+ ```
604
+ A>COPY *.ASM *.MAC ⟵ makes files with extension "MAC" from any files with extension "ASM"
605
+
606
+ A>COPY A*.* B:Z*.* ⟵ Any files beginning with the character A are copied to files beginning with
607
+ the character Z on drive B
608
+ ```
609
+
610
+ _(4) File concatenation_
611
+
612
+ form:
613
+ ```
614
+ COPY <multiple file spec> <file name>
615
+ --------------------
616
+ |
617
+ wildcard specification, or
618
+ multiple file spec connected by "+"
619
+ ```
620
+
621
+ When one destination file receives more than one source file, the contents of all source files are concatenated and stored to the specified destination file. When specifying more than one source file, wildcards are available, and file specs can also be copied by using the plus sign.
622
+
623
+ When files are concatenated, ASCII mode is selected by default and 1AH is considered the file end mark. Thus, concatenating binary files including data 1AH by the COPY command causes data after 1AH to be discarded. To prevent this, specify /B switch and use COPY command in binary mode.
624
+
625
+ If more than one wildcard appears in the specification of source files, the second wildcard and after are expanded referring to original file names, as in paragraph (3) above. This permits concatenation of similar files at the same time.
626
+
627
+ examples:
628
+
629
+ ```
630
+ A>COPY X+Y+Z XYZ ⟵ concatenates X, Y, AND Z and stores in a file XYZ
631
+
632
+ A>COPY *.LST ALL ⟵ concatenates any files with extension "LST" and stores in a file ALL
633
+
634
+ A>COPY /B *.DAT ALL ⟵ concatenates any ".DAT" files in binary mode
635
+
636
+ A>COPY ASC/A+BIN/B AB/B ⟵ concatenates an ASCII file ASC and a binary file BIN and stores in a file AB
637
+
638
+ A>COPY *.LST+*.REF *.PRN ⟵ concatenates files named same with extension "LST" and extension "REF"
639
+ and makes a file with extension "PRN"
640
+ ```
641
+
642
+ #### DATE
643
+
644
+ form:
645
+ ```
646
+ DATE [<month>-<day>-<year>]
647
+ - -
648
+ | |
649
+ -------
650
+ |
651
+ "/" and "." are also allowed.
652
+ ```
653
+
654
+ Sets the date in the internal CLOCK-IC. For MSX machines without a CLOCK-IC, it is written to the specific work area. Creations or modifications of files on MSX-DOS cause this date information to be recorded for each file.
655
+
656
+ When the DATE command is executed without specifying `<month>/<day>/<year>`, the date currently set is displayed with a request for a new date as shown below. Pressing only the RETURN key here leaves the date unchanged.
657
+
658
+ ```
659
+ Current date is <day of week> <month>-<day>-<year>
660
+ Enter new date:
661
+ ```
662
+
663
+ The format of the date to be set by the DATE command has three fields: `<year>`, `<month>`, and `<day>`. Each field is separated by "-", "/", or ".". Each field can have the following numerical values:
664
+
665
+ ```
666
+ <year>: 1980 to 2079
667
+ 0 to 79 (considered as 2000 to 2079)
668
+ 80 to 99 (considered as 1980 to 1999)
669
+ <month>: 1 to 12
670
+ <day>: 1 to 31
671
+ ```
672
+
673
+ Foreign versions of MSX-DOS have different date formats: `<month>-<day>-<year>` or `<day>-<month>-<year>`.
674
+
675
+
676
+ #### DEL
677
+
678
+ form: `DEL <file spec>`, `ERASE` is also allowed
679
+
680
+ Deletes the specified file. Wildcards can be used to specify more than one files.
681
+
682
+ Since `DEL *.*` causes all files on the diskette to be deleted, in this case, an acknowledgement is required.
683
+
684
+ ```
685
+ A>DEL *.*
686
+ Are you sure (Y/N)?
687
+ ```
688
+
689
+ Pressing "Y" or "y" causes all files to be deleted.
690
+
691
+ `ERASE` may be used the same way as the DEL command.
692
+
693
+
694
+ #### DIR
695
+
696
+ form: `DIR [<file spec>] [/W] [/P]`
697
+
698
+ The following information about the specified at `<file spec>` is listed from the left side in one line.
699
+
700
+ ```
701
+ <file name> <file size> <date> <time>
702
+ ```
703
+
704
+ The fields `<date>` and `<time>` show when the file was created or last modified. When this information is longer than one line, items displayed near the right side are omitted.
705
+
706
+ In addition to the usual wildcards, the following abbreviations for `file spec` can be used.
707
+
708
+ ```
709
+ Abbreviation Formal notation
710
+
711
+ DIR = DIR *.*
712
+ DIR <drive>: = DIR <drive>:*.*
713
+ DIR <filename> = DIR <filename>.*
714
+ DIR .<extension> = DIR *.<extension>
715
+ ```
716
+
717
+ When the /W switch is specified, only `<filename>`s are padded to one line. When the /P switch is specified, the listing is stopped after each display page to wait for any key input.
718
+
719
+ examples:
720
+
721
+ ```
722
+ A>DIR ⟵ displays information for all files on drive A
723
+
724
+ A>DIR B: ⟵ displays information for all files on drive B
725
+
726
+ A>DIR TEST ⟵ displays information for all files having <filename> "TEST"
727
+
728
+ A>DIR /W ⟵ displays all file names of drive A
729
+ ```
730
+
731
+ #### FORMAT
732
+
733
+ form: `FORMAT`
734
+
735
+ Formats a diskette in MSX-DOS format. In other words, directories and FAT are initialised and any files are erased. Since MSX-DOS has the same disk format as MS-DOS, the formatted diskette is also read or written by MS-DOS.
736
+
737
+ When executing the FORMAT command, an inquiry
738
+
739
+ ```
740
+ Drive name? (A,B) (⟵ Depends on number of drives)
741
+ ```
742
+
743
+ is made for the name of the drive containing a disk to be formatted. Answering "A" or "B" causes the menu to be displayed when a drive that can select one-sided and two-sided formats is being used. After specifying the type of format,
744
+
745
+ ```
746
+ Strike a key when ready
747
+ ```
748
+
749
+ is displayed to wait for a key input. Pressing any key starts formatting. See the disk drive manual for the format menu.
750
+
751
+
752
+ #### MODE
753
+
754
+ form: `MODE <characters per line>`
755
+
756
+ Sets the number of characters to be displayed in one line on the screen. `<characters per line>` can have a value from 1 to 80 and the screen mode depends on that value:
757
+
758
+ ````
759
+ <characters per line> Screen mode
760
+ 1 to 32 GRAPHIC 1 (SCREEN 1)
761
+ 33 to 40 TEXT 1 (SCREEN 0:WIDTH 40)
762
+ 41 to 80 TEXT 2 (SCREEN 0:WIDTH 80)
763
+ ````
764
+
765
+ #### PAUSE
766
+
767
+ form: `PAUSE [<comment>]`
768
+
769
+ MSX-DOS has a "batch operation" feature which automatically executes a series of commands written in a text file. During the batch operation, you may want to stop command execution temporarily. One example would be for the user to exchange disks. PAUSE can be used in such cases.
770
+
771
+ When this command is executed,
772
+
773
+ ```
774
+ Strike a key when ready...
775
+ ```
776
+
777
+ is displayed and a key input is expected. Pressing any key other than Ctrl-C here ends the PAUSE command and proceeds to the next one. Pressing CTRL-C abandons the batch operation. Any kind of comments can follow "PAUSE". This makes it possible to display the purpose of the request for the key input.
778
+
779
+
780
+ #### REM
781
+
782
+ form: `REM [<comment>]`
783
+
784
+ REM is used to write a comment in the batch command. It does nothing as a command. A space between "REM" and `<comment>` is required.
785
+
786
+
787
+ #### REN
788
+
789
+ form: `REN <file spec> <file name>`, `RENAME` is also allowed
790
+
791
+ REN changes the file name specified by `<file spec>`. Wildcards can be used in both `<file spec>` and `<file name>`. Specifying wildcards for `<file name>` causes these wildcards to be replaced with corresponding characters of the `<file spec>` (see COPY command).
792
+
793
+ Any attempt to change a file name to a name already in use will cause an error.
794
+
795
+ examples:
796
+
797
+ ```
798
+ A>REN ABC XYZ ⟵ changes the file name "ABC" to "XYZ"
799
+
800
+ A>REN B:ABC XYZ ⟵ changes the file name "ABC" on drive B to "XYZ"
801
+
802
+ A>REN *.BIN *.COM ⟵ changes any files with the extension "BIN" to "COM"
803
+ ```
804
+
805
+ #### TIME
806
+
807
+ form: `TIME [<hour>[:<minute>[:<second>]]]`
808
+
809
+ TIME sets the time for the internal CLOCK-IC. Nothing happens to machines that do not have a CLOCK-IC. When a file is created on MSX-DOS, time information set here is recorded for each file.
810
+
811
+ Executing the TIME command without specifying the time causes the current time setting to be displayed as shown below. Then there is an input request for a new time. Pressing only the RETURN key does not change the time.
812
+
813
+ ```
814
+ Current time is <hour>:<minute>:<second>:<second/100><p or a>
815
+ Enter new time:
816
+ ```
817
+
818
+ The punctuation mark ":" separates the three TIME command fields of `<hour>`, `<minute>`, and `<second>`. Fields after `<minute>` or `<second>` may be omitted or considered to be 0. Each field can have the following values:
819
+
820
+ ```
821
+ <hour>: 0 to 23
822
+ 12A (represents midnight)
823
+ 0A to 11A (represents midnight to 11 o'clock in the morning)
824
+ 12P (represents noon)
825
+ 1P to 11P (represents 1 o'clock to 11 o'clock in the evening)
826
+ <minute>: 0 to 59
827
+ <second>: 0 to 59
828
+ ```
829
+
830
+ examples:
831
+
832
+ ```
833
+ A>TIME 12 ⟵ sets time to 12:00:00
834
+
835
+ A>TIME 1:16P ⟵ sets time to 13:16:00
836
+ ```
837
+
838
+ #### TYPE
839
+
840
+ form: `TYPE <file spec>`
841
+
842
+ The command TYPE displays the contents of a file specified by `<file spec>`. Using wildcards in <file spec> causes the first of the corresponding files to be displayed. This command is for ASCII files, and displaying binary files causes unreadable control characters to be sent to the screen.
843
+
844
+
845
+ #### VERIFY
846
+
847
+ form: `VERIFY [ON|OFF]`
848
+
849
+ VERIFY sets/resets the verify mode. When the verify mode is turned ON, after data is written to the disk, it is always read to ensure that it was written correctly. This is why disk access takes longer. "VERIFY OFF" is set by default.
850
+
851
+
852
+ <p>&nbsp;</p>
853
+
854
+ ### 2.3 Batch Command Usage
855
+
856
+ MSX-DOS has a batch feature that allows a series of commands listed in the order of operation to be executed automatically. The file containing this procedureis called a "batch file" and the series of operations defined by a batch file is called a "batch command".
857
+
858
+ A batch file uses the extension ".BAT". Typing only the file name (the extension ".bat" is not typed) at the command line prompt causes MSX-DOS to execute the commands in the file line by line.
859
+
860
+ For example, let us consider the following operation:
861
+
862
+ 1. Copy all files on drive A with the extension ".COM" onto drive B.
863
+ 2. List all "COM" files on drive B.
864
+ 3. Delete all "COM" files on drive A.
865
+
866
+ This operation could be achieved by issuing the following commands to MSX-DOS:
867
+
868
+ ```
869
+ A>COPY A:*.COM B:
870
+ A>DIR B:*.COM /W
871
+ A>DEL A:*.COM
872
+ ```
873
+
874
+ If these three lines are combined into a batch file called "MV.BAT", the command line input "MV" will automatically execute the operation shown above. The following list illustrates this.
875
+
876
+ ```
877
+ A>COPY CON MV.BAT -+
878
+ COPY A:*.COM B: | creates "MV.BAT"
879
+ DIR B:*.COM /W |
880
+ DEL A:*.COM -+
881
+ ^Z Ctrl-Z + RETURN key input
882
+
883
+ A>TYPE MV.BAT -+
884
+ COPY A:*.COM B: | to confirm the contents of "MV.BAT"
885
+ DIR B:*.COM /W |
886
+ DEL A:*.COM -+
887
+
888
+ A>MV invokes the batch command "MV"
889
+ A>COPY A:*.COM B: reads the first line automatically and executes it
890
+ .
891
+ .
892
+ .
893
+ A>DIR B:*.COM /W reads the second line automatically and executes it
894
+ .
895
+ .
896
+ .
897
+ A>DEL A:*.COM reads the third line automatically and executes it
898
+ .
899
+ .
900
+ .
901
+ ```
902
+
903
+ A batch operation may be interrupted by pressing Ctrl-C. When Ctrl-C is entered during batch operations, the request shown in [Figure 3.7](#figure-37--interrupt-of-the-batch-operation) is displayed on the screen.
904
+
905
+
906
+ ##### _Figure 3.7 Interrupt of the batch operation_
907
+
908
+ ```
909
+ -----------------------------------
910
+ | |
911
+ | Terminate batch file (Y/N)? |
912
+ | |
913
+ -----------------------------------
914
+ ```
915
+
916
+ Selecting "Y" here terminates the batch command and returns to MSX-DOS. Selecting "N" reads the next line of the batch file and continues the execution of the batch command.
917
+
918
+
919
+ #### Batch variables
920
+
921
+ For more flexible use of the batch command, any string can be passed as parameters from the command line to the batch command. Parameters passed are referred to with the symbols "%n" where n is any number from 0 to 9. These "%n" symbols are called batch variables.
922
+
923
+ Batch variables %1, %2, ... correspond to parameters specified in the command line from left to right, and %0 is for the name of the batch command itself.
924
+
925
+
926
+ ##### _Figure 3.8 Examples for batch variables usage_
927
+
928
+ ```
929
+ -----------------------------------------------------------------
930
+ | |
931
+ | A>COPY CON TEST.BAT ......... creates a batch command |
932
+ | REM %0 %1 %2 %3 |
933
+ | ^Z |
934
+ | 1 file copied |
935
+ | A>TYPE TEST.BAT |
936
+ | REM %0 %1 %2 %3 ...... a batch command to display 3 arguments |
937
+ | |
938
+ | A>TEST ONE TWO THREE FOUR ...... executes the batch command, |
939
+ | A>REM TEST ONE TWO THREE giving arguments to it |
940
+ | A> |
941
+ | |
942
+ -----------------------------------------------------------------
943
+ ```
944
+
945
+ #### AUTOEXEC.BAT
946
+
947
+ The batch file named "AUTOEXEC.BAT" is used as a special autostart program at MSX-DOS startup. When MSX-DOS is invoked, COMMAND.COM examines whether AUTOEXEC.BAT exists and, if so, executes it.
948
+
949
+
950
+ <p>&nbsp;</p>
951
+
952
+ ### 2.4 External Commands
953
+
954
+ External commands exist on the diskette as files with the extension ".COM", and typing the external command name (except for the extension) causes the command to be executed in the following manner.
955
+
956
+ 1. loads an external command after 100H
957
+ 2. calls 100H
958
+
959
+
960
+ #### Developing external commands
961
+
962
+ Assembly language routines created to work in memory at location 100H and saved under file names with the extension ".COM" are called external commands and can be executed from MSX-DOS.
963
+
964
+ For example, consider a program to produce a control code "0CH" by using one-character output routine (see system calls) and clear the screen. This is an 8-byte program as shown below.
965
+
966
+
967
+ ##### List 3.1 Contents of CLS.COM
968
+
969
+ ```
970
+ 1E 0C LD E,0CH ; E := control-code of CLS
971
+ 0F 02 LD C,02H ; C := function No. of CONSOLE OUTPUT
972
+ CD 05 00 CALL 0005H ; call BDOS
973
+ C9 RET
974
+ ```
975
+
976
+ Writing these 8 bytes to a file named CLS.COM produces the external command "CLS" to clear the screen. The following sample program uses the sequential file access feature of BASIC to make this command. After this program is run, the CLS command is created on the diskette. Confirm that the command actually works after returning to MSX-DOS.
977
+
978
+
979
+ ##### List 3.2 Creating CLS.COM
980
+
981
+ ```
982
+ 100 '***** This program makes "CLS.COM" *****
983
+ 110 '
984
+ 120 OPEN "CLS.COM" FOR OUTPUT AS #1
985
+ 130 '
986
+ 140 FOR I=1 TO 8
987
+ 150 READ D$
988
+ 160 PRINT #1,CHR$(VAL("&H"+D$));
989
+ 170 NEXT
990
+ 180 '
991
+ 190 DATA 1E,0C,0E,02,CD,05,00,C9
992
+ ```
993
+
994
+ #### Passing arguments to an external command
995
+
996
+ When creating an external command, there are two ways to pass arguments from the command line to the external command. First, when passing the file names to the command line as arguments, use 5CH and 6CH in the system scratch area. COMMAND.COM, which always considers the first and second parameters as file names when external commands are executed, expands them to a drive number (1 byte) + file name (8 bytes) + extension (3 bytes) and stores them in 5CH and 6CH. These are in the same format as the first 12 bytes of FCB, so setting these address as first addresses of FCB permits various operatuons.
997
+
998
+ However, since in this method only 16 bytes differ from the starting addresses of two FCBs, either 5CH or 6CH (only) can be used as a complete FCB. Next, when passing arguments other than file names (numbers, for instance) or creating an external command handling more than three file names, COMMAND.COM stores the whole command line, which invoked the external command, except for the command line itself in the form of number of bytes (1 byte) + command line body, so it can be used by interpreting it in the external command properly. See [List 3.3](#list-33--utility-routines) of section 4 for an example of passing arguments using this DMA area.
999
+
1000
+
1001
+ <p>&nbsp;</p>
1002
+
1003
+ ## 3. STRUCTURE OF DISK FILES
1004
+
1005
+ Information about the structure of data on the disk and how it is controlled is important when acessing the disk using system calls. This section begins with a description about "logical sectors" which are the basic units for exchanging data with the disk on MSX-DOS, and proceeds to the method of handling data with "files" which is more familiar to programmers.
1006
+
1007
+
1008
+ <p>&nbsp;</p>
1009
+
1010
+ ### 3.1 Data units on the disk
1011
+
1012
+ #### Sectors
1013
+
1014
+ MSX-DOS can access most types of disk drives including th 3.5 inch 2DD and hard disks. For handling different media in the same way, the system call consider "logical sector" as the basic units of data on the disk. A logical sector is specified by numbers starting from 0.
1015
+
1016
+
1017
+ #### Clusters
1018
+
1019
+ As long as system calls are used, a sector may be considered the basic unit of data as considered above. In fact, however, data on the disk is controlled in units of "clusters" which consists of multiple sectors. As described later in [the FAT section](#fat-file-allocation-table), a cluster is specified by a serial number from 2 and the top of the data area corresponds to the location of cluster #2. For getting information about how many sectors a cluster has, use the system call [function 1BH (acquiring disk information)](#disk-information-acquisition).
1020
+
1021
+
1022
+ #### Conversion from clusters to sectors
1023
+
1024
+ In a part of the directory or FCB, described later, the data location on the disk is indicated by the cluster. To use system calls to access data indicated by cluster, the relation of the correspondence between the cluster and the sector needs to be calculated. Since cluster #2 and the top sector of the data area reside in the same location, this can be done as follows:
1025
+
1026
+ 1. Assume the given cluster number is C.
1027
+ 2. Examine the top sector of the data area (by reading DPB) and assume it is S0.
1028
+ 3. Examine the number of sectors equivalent to one cluster (using [function 1BH](#disk-information-acquisition)) and assume it is n.
1029
+ 4. Use the formula `S = S0 + (C-2) * n` to calculate sector numbers.
1030
+
1031
+ In MSX-DOS, sectors in the disk are divided into four areas, as shown in [Table 3.9](#table-39--disk-contents). The file data body written to the disk is recorded in the "data area" portion. Information for handling data is written in three areas. [Figure 3.9](#figure-39--relation-of-locations-of-elements-in-the-disk) shows the relation of the locations of these areas. The boot sector is always in sector #0, but the top sectors (FAT, directory, and data area) differ by media, so DPB should be referred to.
1032
+
1033
+
1034
+ ##### _Table 3.9 Disk contents_
1035
+
1036
+ ```
1037
+ ----------------------------------------------------------------------------
1038
+ | boot sector | MSX-DOS startup program and information proper to the disk |
1039
+ | FAT | physical control information of data on the disk |
1040
+ | directory | control information of files on the disk |
1041
+ | data area | actual file data |
1042
+ ----------------------------------------------------------------------------
1043
+ ```
1044
+
1045
+ ##### _Figure 3.9 Relation of locations of elements in the disk_
1046
+
1047
+ ```
1048
+ +- ----------------------- ⟵ sector #0
1049
+ | | boot sector |
1050
+ | |---------------------| ⟵ sector #? -+
1051
+ | | FAT | | Top sectors of these data
1052
+ whole |---------------------| ⟵ sector #? | areas can be acquired by
1053
+ of a | directory | | referring to DPB.
1054
+ disk |---------------------| ⟵ sector #? -+
1055
+ | | |
1056
+ | | data area |
1057
+ | | |
1058
+ +- ----------------------- ⟵ last sector
1059
+ ```
1060
+
1061
+ #### DPB (drive parameter block) and boot sector
1062
+
1063
+ On MSX-DOS, the area "DPB" is allocated in the work area of memory for each connected drive, and information proper to each drive is recorded there. MSX-DOS can handle most types of disk drives, because the differences between media can be compensated for by the process corresponding to each drive.
1064
+
1065
+ Information written on DPB, which is originally on the boot sector (sector #0) of the disk, is read at MSX-DOS startup. Note that the differences between the contents of the boot sector and DPB, as shown in Figures [3.10](#figure-310--information-of-the-boot-sector) and [3.11](#figure-311--dpb-structure). Data is arranged differently in the boot sector and the DPB.
1066
+
1067
+
1068
+ ##### _Figure 3.10 Information of the boot sector_
1069
+
1070
+ ```
1071
+ | |
1072
+ |---------------| -+
1073
+ 0B | | |-- 1 sector size (in bytes)
1074
+ 0C | | |
1075
+ |---------------| -+
1076
+ 0D | | ---- 1 cluster size (in sectors)
1077
+ |---------------| -+
1078
+ 0E | | |-- Number of unused sectors by MSX-DOS
1079
+ 0F | | |
1080
+ |---------------| -+
1081
+ 10 | | ---- Number of FATs
1082
+ |---------------| -+
1083
+ 11 | | |-- Number of directory entries (How many files can be created)
1084
+ 12 | | |
1085
+ |---------------| -+
1086
+ 13 | | |-- Number of sectors per disk
1087
+ 14 | | |
1088
+ |---------------| -+
1089
+ 15 | | ---- Media ID
1090
+ |---------------| -+
1091
+ 16 | | |-- Size of FAT (in sectors)
1092
+ 17 | | |
1093
+ |---------------| -+
1094
+ 18 | | |-- Number of tracks per sector
1095
+ 19 | | |
1096
+ |---------------| -+
1097
+ 1A | | |-- Number of sides used (either one or two)
1098
+ 1B | | |
1099
+ |---------------| -+
1100
+ 1C | | |-- Number of hidden sectors
1101
+ 1D | | |
1102
+ |---------------| -+
1103
+ | |
1104
+ ```
1105
+
1106
+ ##### _Figure 3.11 DPB structure_
1107
+
1108
+ ```
1109
+ -----------------
1110
+ BASE -> | | ---- drive number
1111
+ |---------------|
1112
+ +1 | | ---- media ID
1113
+ |---------------| -+
1114
+ +2 | | |-- sector size
1115
+ +3 | | |
1116
+ |---------------| -+
1117
+ +4 | | ---- directory mask
1118
+ |---------------|
1119
+ +5 | | ---- directory shift
1120
+ |---------------|
1121
+ +6 | | ---- cluster mask
1122
+ |---------------|
1123
+ +7 | | ---- cluster shift
1124
+ |---------------| -+
1125
+ +8 | | |-- top sector of FAT
1126
+ +9 | | |
1127
+ |---------------| -+
1128
+ +10 | | ---- number of FATs
1129
+ |---------------|
1130
+ +11 | | ---- number of directory entries
1131
+ |---------------| -+
1132
+ +12 | | |-- top sector of data area
1133
+ +13 | | |
1134
+ |---------------| -+
1135
+ +14 | | |-- amount of cluster + 1
1136
+ +15 | | |
1137
+ |---------------| -+
1138
+ +16 | | ---- number of sectors required for one FAT
1139
+ |---------------| -+
1140
+ +17 | | |-- top sector of directory area
1141
+ +18 | | |
1142
+ |---------------| -+
1143
+ +19 | | |-- FAT address in memory
1144
+ +20 | | |
1145
+ ----------------- -+
1146
+ ```
1147
+
1148
+ Use the system call [Function 1BH (disk information acquisition)](#disk-information-acquisition) to access the DPB. This system call returns the DPB address in memory and other information for each drive written on the boot sector (see [section 4 "System call usage"](#4--system-call-usage) for the detailed usage).
1149
+
1150
+
1151
+ #### FAT (file allocation table)
1152
+
1153
+ In MSX-DOS, a "cluster" is the data unit for writing to the disk. Files larger than a cluster are written across multiple clusters. But in this case adjacent clusters are not always used. In particular, after creating and deleting files many times, clusters which are no longer used are scattered at random across the disk. When a large file is created for such cases, the file is broken down into several clusters and these clusters are stored where space is available. The linkage information is kept at the beginning so that the file can be recreated. This is the main function of the FAT.
1154
+
1155
+ When a bad cluster is found, FAT is also used to record that location, so access will not be made there any more. Linkage information of clusters and information concerning bad clusters is necessary for managing disk files. Without this information, the whole disk will be unusable. For this reason, more than one FAT is always prepared in case of accidental erasure.
1156
+
1157
+
1158
+ Figure 3.2 shows an example of a FAT. The first byte is called the "FAT ID" which contains the value indicating the type of media (the same value as media ID in [Table 3.1](#table-31--media-supported-by-msx-dos)). The next two bytes contains meaningless dummy values. From the fourth byte (start address + 3), actual linkage information is recorded in an irregular format of 12 bits per cluster. Each 12-bit area containing linkage information is called a FAT entry. Note that the FAT entry begins with number 2. The number of the FAT entry is also the number of the cluster corresponding to it. Read the 12-bit linkage information recorded in the FAT entry in the way shown in [Figure 3.13](#figure-313--reading-fat).
1159
+
1160
+
1161
+ ##### _Figure 3.12 FAT example_
1162
+
1163
+ ![Figure 3.12](https://raw.githubusercontent.com/Konamiman/MSX2-Technical-Handbook/master/pics/Figure%203.12.png)
1164
+
1165
+ The linkage information is the value indicating the next cluster number. FFFH means that the file ends with that cluster. The example of [Figure 3.12](#figure-312--fat-example) shows a file of three clusters, (cluster #2 -> cluster #3 -> cluster #4), and a file of two clusters, (cluster #5 -> cluster #6). The linkage from the cluster with the smaller number is only for easy comprehension. In actual practice, numbers are not necessarily ordered.
1166
+
1167
+
1168
+ ##### _Figure 3.13 Reading FAT_
1169
+
1170
+ ![Figure 3.13](https://raw.githubusercontent.com/Konamiman/MSX2-Technical-Handbook/master/pics/Figure%203.13.png)
1171
+
1172
+ #### Directory
1173
+
1174
+ The FAT as described above, relates the physical location of data on the disk and does not include information about the contents of data written there. Thus, an information resource other than FAT is required to know what kind of data is in a file. This resource is called a "directory". A directory entry is composed of 32 bytes and records file names, file attributes, date created, time created, number of the top cluster of the file, and file size, as shown in [Figure 3.14](#figure-314--directory-construction).
1175
+
1176
+ "File attributes" in the directory are used for specifying the invisibility attribute in a file. Specifying "1" in the second bit from the lowest of this byte prevents files specified in the directory from being accessed by the system call (see [Figure 3.15](#figure-315--invisibility-attribute-of-the-file)). MS-DOS also has a file attribute byte which permits a write-prohibit attribute using another bit, but MSX-DOS does not support this feature.
1177
+
1178
+ The date and time are recorded so that two bytes of each are divided into three bitfields, as shown in [Figure 3.16](#figure-316--bitfield-representing-time) and [Figure 3.17](#figure-317--bitfield-representing-date). Since only 5 bits are prepared for the "time" bitfield, the minimum unit for time is two seconds. The year (1980 to 2079) is specified by using 0 to 99 in 7 bits.
1179
+
1180
+
1181
+ ##### _Figure 3.14 Directory construction_
1182
+
1183
+ ```
1184
+ Directory ----------------- -+
1185
+ header --> | . | |
1186
+ . |-- filename (8 characters)
1187
+ . |
1188
+ +7 | | |
1189
+ |---------------| -+
1190
+ +8 | | |
1191
+ +9 | | |-- extension (3 characters)
1192
+ +10 | | |
1193
+ |---------------| -+
1194
+ +11 | | ---- file attribute
1195
+ |---------------| -+
1196
+ . | . | |
1197
+ . . |-- space for compatibility with MS-DOS
1198
+ . . | (not used by MSX-DOS)
1199
+ | | |
1200
+ |---------------| -+
1201
+ +22 | | |-- time created
1202
+ +23 | | |
1203
+ |---------------| -+
1204
+ +24 | | |-- date created
1205
+ +25 | | |
1206
+ |---------------| -+
1207
+ +26 | | |-- top cluster of the file
1208
+ +27 | | |
1209
+ |---------------| -+
1210
+ +28 | | |
1211
+ +29 | | |-- file size
1212
+ +30 | | |
1213
+ +31 | | |
1214
+ ----------------- -+
1215
+ ```
1216
+
1217
+ ##### _Figure 3.15 Invisibility attribute of the file_
1218
+
1219
+ ```
1220
+ (11th byte of the directory)
1221
+ ---------------------------------
1222
+ | . | . | . | . | . | . | X | . |
1223
+ ---------------------------------
1224
+ |
1225
+ | 0 : enables normal acess
1226
+ +----->
1227
+ 1 : disables access
1228
+ ```
1229
+
1230
+ ##### _Figure 3.16 Bitfield representing time_
1231
+
1232
+ ```
1233
+ (23rd byte of the directory) (22nd byte of the directory)
1234
+ --------------------------------- ---------------------------------
1235
+ | h4| h3| h2| h1| h0| m5| m4| m3| | m2| m1| m0| s4| s3| s2| s1| s0|
1236
+ --------------------------------- ---------------------------------
1237
+ | | | |
1238
+ +-------------------+-----------------------------+-------------------+
1239
+ hour (0 to 23) minute (0 to 59) second /2 (0 to 29)
1240
+ |
1241
+ "second" value when multiplied by 2 --+
1242
+ ```
1243
+
1244
+ ##### _Figure 3.17 Bitfield representing date_
1245
+
1246
+ ```
1247
+ (25th byte of the directory) (24th byte of the directory)
1248
+ --------------------------------- ---------------------------------
1249
+ | y6| y5| y4| y3| y2| y1| y0| m3| | m2| m1| m0| d4| d3| d2| d1| d0|
1250
+ --------------------------------- ---------------------------------
1251
+ | | | |
1252
+ +---------------------------+---------------------+-------------------+
1253
+ year (0 to 99) month (1 to 12) day (1 to 31)
1254
+ |
1255
+ +-- corresponds to 1980 to 2079
1256
+ ```
1257
+
1258
+ The place where this directory information is actually recorded is the directory area on the disk (see [Figure 3.9](#figure-39--relation-of-locations-of-elements-in-the-disk)). The location (top sector) is recorded in the DPB. Directory entries (locations of directory storage) are arranged every 32 bytes in the driectory area, as shown in [Figure 3.18](#figure-318--organisation-of-directory-area). When a file is created, the directory is created at the lowest value of unused directory entries. Deleting a file causes E5H to be written to the first byte of the corresponding directory entry, which is empty. After all direcotry entries are exhausted, new files cannot be created even if there is a lot of unused space on the disk. The number of directory entries, that is, the number of files which can be created on one disk is also recorded in the DPB.
1259
+
1260
+
1261
+ ##### _Figure 3.18 Organisation of directory area_
1262
+
1263
+ ```
1264
+ |------ 32 bytes -------|
1265
+ -------------------------
1266
+ BASE -> | MSXDOS.SYS |
1267
+ |-----------------------|
1268
+ +32 | COMMAND.COM |
1269
+ |-----------------------|
1270
+ +64 | E5H | | ⟵ The directory entry whose first byte is E5H is currently unused
1271
+ |-----------------------|
1272
+ +96 | TEST |
1273
+ |-----------------------|
1274
+ | . |
1275
+ . |
1276
+ .
1277
+ | |
1278
+ |-----------------------|
1279
+ +32 * n | 00H | | ⟵ The directory entry whose first byte is 00H has never been used
1280
+ |-----------------------|
1281
+ | |
1282
+ ```
1283
+
1284
+
1285
+ <p>&nbsp;</p>
1286
+
1287
+ ### 3.2 File Access
1288
+
1289
+ #### FCB (file control block)
1290
+
1291
+ Using information recorded in the directory area allows data to be treated as a "file". The advantage of this method is that the data location is not represented by an absolute number such as sector number or cluster number; instead, the file can be specified with a "name". The programmer need only specify the file name and the system will do all the work concerned with accessing the requested file. In other words, the programmer need not understand the details of which sectors the file occupies. In this case, FCB plays an important role for directories.
1292
+
1293
+ FCB is the area for storing information needed to handle files using system calls. Handling one file requires 37 bytes of memory each, as shown in [Figure 3.19](#figure-319--organization-of-fcb). Although the FCB can be located anywhere in memory, the address 005CH is normally used to utilize MSX-DOS features.
1294
+
1295
+
1296
+ ##### _Figure 3.19 Organization of FCB_
1297
+
1298
+ ```
1299
+ FCB ------
1300
+ bytes | 0 | drive number
1301
+ from |----|
1302
+ top | 1 | file name
1303
+ | | | filename ..... 8 bytes
1304
+ V | 11 | extension .... 3 bytes
1305
+ |----|
1306
+ | 12 | current block
1307
+ | 13 | number of blocks from the top of the file to the current block
1308
+ |----|
1309
+ | 14 | record size
1310
+ | 15 | 1 to 65535
1311
+ |----|
1312
+ | 16 | file size
1313
+ | | 1 to 4294967296
1314
+ | 19 |
1315
+ +-- |----|
1316
+ | | 20 | date
1317
+ | | 21 | same form as directory
1318
+ (1) |----|
1319
+ | | 22 | time
1320
+ | | 23 | same form as directory
1321
+ +-- |----|
1322
+ | | 24 | device ID
1323
+ | |----|
1324
+ | | 25 | directory location
1325
+ | |----|
1326
+ | | 26 | top cluster number of the file
1327
+ (2) | 27 |
1328
+ | |----|
1329
+ | | 28 | last cluster number accessed
1330
+ | | 29 |
1331
+ | |----|
1332
+ | | 30 | relative location from top cluster of the file
1333
+ | | 31 | number of clusters from top of the file to the last cluster accessed
1334
+ +-- |----|
1335
+ | 32 | current record
1336
+ |----|
1337
+ | 33 | random record
1338
+ | | record order from the top of the file
1339
+ | 36 | usually stores the last record made random access
1340
+ ------
1341
+ ```
1342
+
1343
+ **Notes:** FCB usages differ, depending on whether they use CP/M compatible system calls or additional system calls. See the decription below for details.
1344
+
1345
+ (1) When using version 2 of MSX-DOS, here is stored the volume-id of the disk, and should not be modified by the program.
1346
+ (2) When using version 2 of MSX-DOS, here is stored internal information relative to the physical location of the file on the disk. The format of this information is different from shown in figure 3.19, and should not be modified by the program.
1347
+
1348
+
1349
+ * drive number (00H)
1350
+ Indicates the disk drive containing the file.
1351
+ (0 -> default drive, 1 -> A:, 2 -> B:...)
1352
+
1353
+ * filename (01H to 08H)
1354
+ A filename can have up to 8 characters. When it has less than 8, the rest are filled in by spaces (20H).
1355
+
1356
+ * extension (09H to 0BH)
1357
+ A extension can have up to 8 characters. When it has less than 3, the rest are filled in by spaces (20H).
1358
+
1359
+ * current block (0CH to 0DH)
1360
+ Indicates the block number currently being referred to by sequential access (see function [14H](#sequential-readout), [15H](#sequential-writing-to-the-disk) in [section 4](#4--system-call-usage)).
1361
+
1362
+ * record size (0EH to 0FH)
1363
+ Specifies the size of data unit (record) to be read or written at one access, in bytes (see function [14H](#sequential-readout), [15H](#sequential-writing-to-the-disk), [21H](#random-reading-from-the-disk), [27H](#random-readout---2-random-block-access), [28H](#random-writing---3)).
1364
+
1365
+ * file size (10H to 13H)
1366
+ Indicates the size of the file in bytes.
1367
+
1368
+ * date (14H to 15H)
1369
+ Indicates date when a file was last written. The format is the same as the one recorded in the directory.
1370
+
1371
+ * time (16H to 17H)
1372
+ Indicates time when a file was last written. The format is the same as the one recorded in the directory.
1373
+
1374
+ * device ID (18H)
1375
+ When a peripheral is opened as a file, the value shown in [Table 3.10](#table-310--device-id) is specified for this device ID field. For normal disk files, the value of this field is 40H + drive number. For example, the device ID for drive A is 40H (for future expansion, application programs should not use the ID byte).
1376
+
1377
+
1378
+ ##### _Table 3.10 Device ID_
1379
+
1380
+ ```
1381
+ ----------------------------------
1382
+ | Device name | Device ID |
1383
+ |--------------------+-----------|
1384
+ | CON (Console) | 0FFH |
1385
+ | PRN (Printer) | 0FBH |
1386
+ | LST (List=Printer) | 0FCH |
1387
+ | AUX (Auxiliary) | 0FEH |
1388
+ | NUL (Null) | 0FDH |
1389
+ ----------------------------------
1390
+ ```
1391
+
1392
+ * directory location (19H)
1393
+ Indicates the order of the directory entries of a file in the directory area.
1394
+
1395
+ * top cluster (1AH to 1BH)
1396
+ Indicates the top cluster of the file in the disk.
1397
+
1398
+ * last cluster accessed (1C to 1DH)
1399
+ Indicates the last cluster accessed.
1400
+
1401
+ * relative location from top cluster of last cluster accessed (1EH to 1FH)
1402
+ Indicates the relative location from the top cluster of the last cluster accessed.
1403
+
1404
+ * current record (20H)
1405
+ Indicates the record currently being referred to by sequential access (see function [14H](#sequential-readout), [15H](#sequential-writing-to-the-disk)).
1406
+
1407
+ * random record (21H to 24H)
1408
+ Specifies a record to be accessed by random access or random block access. Specifying a value from 1 to 63 for the record size field described above causes all four bytes from 21H to 24H to be used, where only three bytes from 21H to 23H have meaning when the record size is greater than 63 (see function [14H](#sequential-readout), [15H](#sequential-writing-to-the-disk), [21H](#random-reading-from-the-disk), [22h](#random-writing-to-the-disk), [27H](#random-readout---2-random-block-access), [28H](#random-writing---3)).
1409
+
1410
+
1411
+ #### Opening a file
1412
+
1413
+ A special procedure is required to open a file when using FCB. "Opening a file" means, at the system call level, transforming the incomplete FCB whose file name field is only defined for the complete FCB, by using information written in the directory area. [Figure 3.20](#figure-320--beforeafter-opening-fcb) shows the differences between "unopened FCB" and "opened FCB".
1414
+
1415
+
1416
+ ##### _Figure 3.20 Before/after opening FCB_
1417
+
1418
+ ![Figure 3.20](https://raw.githubusercontent.com/Konamiman/MSX2-Technical-Handbook/master/pics/Figure%203.20.png)
1419
+
1420
+ #### Closing a file
1421
+
1422
+ When a file is opened and written to, the contents of each field of FCB, such as size, is also modified. Unless the updated FCB information is returned to the directory area, directory information and the actual contents of the file might be different at the next file access. This operation to return the updated FCB information to the directory corresponds to closing a file at the system call level.
1423
+
1424
+
1425
+ #### Random block access (file management by records)
1426
+
1427
+ MSX-DOS has two system calls dealing with random access, "RANDOM BLOCK READ" and "RANDOM BLOCK WRITE". With these system calls, a file can be divided into data units of any size, which can be handled by numbers, such as 0, 1, 2, ..., from the top. This data unit is called a "record". Record size can be any value of more than one byte. So, treating a whole file as one record (extreme sequential access), treating data with one byte as one record (extreme random access), or treating 128 bytes as one record (the CP/M way) are all possible.
1428
+
1429
+ In this case, the FCB fields, "record size" and "random record" are used to specify the record. The value of the record size field is the number of bytes in one record. Random record fields can have any record number to be accessed (for more detailed usage, see descriptions of each system call).
1430
+
1431
+
1432
+ ##### _Figure 3.21 File and record_
1433
+
1434
+ ![Figure 3.21](https://raw.githubusercontent.com/Konamiman/MSX2-Technical-Handbook/master/pics/Figure%203.21.png)
1435
+
1436
+ #### Sequential access (file management by fixed-length record + current record + current block)
1437
+
1438
+ MSX-DOS can also access files the same way as CP/M for purposes of compatibility. One way is the sequential file which is managed by "current record" and "current block". This uses a 128-byte fixed-length record as the basic unit of data. File access is always done from the top sequentially and the number of records which was accessed is counted at the current record field of FCB. The value of the current record field is reset to 0 when it reaches 128, and the carry is counted in the current block field.
1439
+
1440
+
1441
+ #### Random access (file management by fixed-length record + random record)
1442
+
1443
+ A second method included to keept compatibility with CP/M is a random access method using random record fields. It can access the record of any location but the record size is fixed at 128 bytes.
1444
+
1445
+
1446
+ <p>&nbsp;</p>
1447
+
1448
+ ## 4. SYSTEM CALL USAGE
1449
+
1450
+ The system calls are a collection of general-purpose subroutines which handle the basic input/output operations of MSX-DOS. Having these system calls gathered into BIOS in a predefined manner permits the basic functions of the MSX disk system to be easily accessed.
1451
+
1452
+ There are two purposes of system calls; first, to reduce programming time by preprogramming basic functions; second, to increase portability by the fact that all programs share the same basic functions. Utilizing system calls shortens program development time and makes the developed program highly portable.
1453
+
1454
+ To execute a system call, enter the defined function number in the C register of the Z80 CPU and call one of the following addresses:
1455
+
1456
+ ```
1457
+ 0005H ................. MSX-DOS
1458
+ F37DH (&HF37D) ........ MSX DISK-BASIC
1459
+ ```
1460
+
1461
+ For example, when the function number is 01FH and the system call requires 00H to be set in the A register, the following assembler code can be used with MSX-DOS:
1462
+
1463
+ ```
1464
+ LD A,00H
1465
+ LD C,01FH
1466
+ CALL 0005H
1467
+ .
1468
+ .
1469
+ .
1470
+ ```
1471
+
1472
+ The CALL statement is also used in operations that return values or restore registers from memory. System calls can also be used from DISK-BASIC by using the entry address of F37DH. For this case, store the machine codes in the area allocated by the CLEAR statement and call its start address using the USR function.
1473
+
1474
+
1475
+ ### System call format
1476
+
1477
+ This section introduces system call usages in the following notation:
1478
+
1479
+ * **Function**: function number
1480
+ * **Setup**: value needed to be set in register or memory by programmer
1481
+ * **Return value**: value set in register by system call
1482
+
1483
+
1484
+ #### Function:
1485
+
1486
+ The function number is used to identify the system call. When using a system call, set the function number in the C register.
1487
+
1488
+
1489
+ #### Setup:
1490
+
1491
+ In this section, "setup:" indicates the value to be set in the named register or memory location before executing system calls.
1492
+
1493
+
1494
+ #### Return value:
1495
+
1496
+ The result obtained by a system call is normally set in a register or memory location. This is called output in this section and "return value:" indicates where and how this output is set.
1497
+
1498
+ Is important to note that when using system calls, the contents of registers other than those specified are sometimes destroyed. So, before using system calls, store the contents of registers whose value you do not want to change in an appropriate place (stack, for example) before executing system calls.
1499
+
1500
+ There are forty-two MSX system calls. These are listed in [Table 3.11](#table-311--list-of-system-calls), and are described in this section. There are four categories:
1501
+
1502
+ * Peripheral I/O
1503
+ * Environment setting
1504
+ * Absolute READ/WRITE (direct access to sector)
1505
+ * File access using FCB
1506
+
1507
+
1508
+ ##### _Table 3.11 List of System Calls_
1509
+
1510
+
1511
+ | Function no. | Function |
1512
+ | --- | --- |
1513
+ | 00H | system reset
1514
+ | 01H | get one character from console (input wait, echo back, control code check)
1515
+ | 02H | send one character to console
1516
+ | 03H | get one character from auxiliary device
1517
+ | 04H | send one character to auxiliary device
1518
+ | 05H | send one character to printer
1519
+ | 06H | get one character from console (no input wait, no echo back, no control code check) / one character output
1520
+ | 07H | get one character from console (input wait, no echo back, no control code check)
1521
+ | 08H | get one character from console (input wait, no echo back, control code check)
1522
+ | 09H | send string
1523
+ | 0AH | get string
1524
+ | 0BH | check input from console
1525
+ | 0CH | get version number
1526
+ | 0DH | disk reset
1527
+ | 0EH | select default drive
1528
+ | 0FH | open file
1529
+ | 10H | close file
1530
+ | 11H | search the first file matched with wildcard
1531
+ | 12H | search the second and after the second file matched wildcard
1532
+ | 13H | delete file
1533
+ | 14H | read sequential file
1534
+ | 15H | write sequential file
1535
+ | 16H | create file
1536
+ | 17H | rename file
1537
+ | 18H | get login vector
1538
+ | 19H | get default drive name
1539
+ | 1AH | set DMA address
1540
+ | 1BH | get disk information
1541
+ | 1CH-20H | no function
1542
+ | 21H | write random file
1543
+ | 22H | read random file
1544
+ | 23H | get file size
1545
+ | 24H | set random record field
1546
+ | 25H | no function
1547
+ | 26H | write random block
1548
+ | 27H | read random block
1549
+ | 28H | write random file (00H is set to unused portion)
1550
+ | 29H | no function
1551
+ | 2AH | get date
1552
+ | 2BH | set date
1553
+ | 2CH | get time
1554
+ | 2DH | set time
1555
+ | 2EH | set verify flag
1556
+ | 2FH | read logical sector
1557
+ | 30H | write logical sector
1558
+
1559
+
1560
+ **Note**: System call function numbers are from 00H to 30H; the following seven numbers are blank: 1CH to 20H, 25H, 29H
1561
+
1562
+ Calling these blank function system calls do nothing except setting 00H in the A register. System calls after function 31H are undefined. Using them may cause unpredictable results (not advisable).
1563
+
1564
+
1565
+ ##### List 3.3 Utility routines
1566
+
1567
+ ```
1568
+ ;**************************************************************
1569
+ ;
1570
+ ; List 3.3 utility.mac
1571
+ ;
1572
+ ; these routines are used in other programs
1573
+ ;
1574
+ ; GETARG, STOHEX, PUTHEX, PUTCHR, DUMP8B
1575
+ ;
1576
+ ;**************************************************************
1577
+ ;
1578
+ PUBLIC GETARG Note: Five utility routines included in
1579
+ PUBLIC STOHEX this program list will be used in
1580
+ PUBLIC PUTHEX sample programs later.
1581
+ PUBLIC PUTCHR
1582
+ PUBLIC DUMP8B
1583
+
1584
+ BDOS: EQU 0005H
1585
+ DMA: EQU 0080H
1586
+
1587
+ ;----- DE := address of arg(A)'s copy -----
1588
+
1589
+ GETARG: PUSH AF Note: Nth parameter (N is specified by
1590
+ PUSH BC A register) of the command line
1591
+ PUSH HL stored in default DMA area
1592
+ (0080H to ) is loaded in memory and
1593
+ LD C,A its starting address is returned in
1594
+ LD HL,DMA DE register.
1595
+ LD B,(HL)
1596
+ INC HL
1597
+ INC B
1598
+
1599
+ SKPARG: DEC B
1600
+ JR NZ,NOARG
1601
+ SKP1: LD A,(HL)
1602
+ INC HL
1603
+ CALL TERMCHK
1604
+ JR NZ,SKP1
1605
+ SKP2: LD A,(HL)
1606
+ INC HL
1607
+ CALL TRMCHK
1608
+ JR Z,SKP2
1609
+ DEC HL
1610
+ DEC C
1611
+ JR NZ,SKPARG
1612
+
1613
+ CPYARG: LD DE,BUFMEM
1614
+ CPY1: LD A,(HL)
1615
+ LD (DE),A
1616
+ INC HL
1617
+ INC DE
1618
+ CALL TRMCHK
1619
+ JR NZ,CPY1
1620
+
1621
+ DEC DE
1622
+ LD A,"$"
1623
+ LD (DE),A
1624
+ LD DE,BUFMEM
1625
+ JR EXIT
1626
+
1627
+ NOARG: LD DE,BUFMEM
1628
+ LD A,"$"
1629
+ LD (DE),A
1630
+
1631
+ EXIT: POP HL
1632
+ POP BC
1633
+ POP AF
1634
+ RET
1635
+
1636
+ TRMCHK: CP 09H
1637
+ RET Z
1638
+ CP 0DH
1639
+ RET Z
1640
+ CP " "
1641
+ RET Z
1642
+ CP ";"
1643
+ RET
1644
+
1645
+ ;----- HL := hexadecimal value of [DE] -----
1646
+
1647
+ SOTHEX: PUSH AF Note: Hexadecimal string indicated by
1648
+ PUSH DE DE register is converted into
1649
+ LD HL,0000H two-byte integer and stored in
1650
+ CALL STOH1 HL register.
1651
+ POP DE
1652
+ POP AF
1653
+ RET
1654
+
1655
+ STOH1: LD A,(DE)
1656
+ INC DE
1657
+ SUB "0"
1658
+ RET C
1659
+ CP 10
1660
+ JR C,STOH2
1661
+ SUB "A"-"0"
1662
+ RET C
1663
+ CP 6
1664
+ RET NC
1665
+ ADD A,10
1666
+
1667
+ STOH2: ADD HL,HL
1668
+ ADD HL,HL
1669
+ ADD HL,HL
1670
+ ADD HL,HL
1671
+ OR L
1672
+ LD L,A
1673
+ JR STOH1
1674
+
1675
+ ;----- print A-reg, in hexadecimal form (00-FF) -----
1676
+
1677
+ PUTHEX: PUSH AF Note: Contents of A register is displayed
1678
+ RR A using two hexadecimal digits.
1679
+ RR A
1680
+ RR A
1681
+ RR A
1682
+ CALL PUTHX1
1683
+ POP AF
1684
+ PUTHX1: PUSH AF
1685
+ AND 0FH
1686
+ CP 10
1687
+ JR C,PUTHX2
1688
+ ADD A,"A"-10-"0"
1689
+ PUTHX2: ADD A,"0"
1690
+ CALL PUTCHR
1691
+ POP AF
1692
+ RET
1693
+
1694
+ ;----- put character -----
1695
+
1696
+ PUTCHR: PUSH AF
1697
+ PUSH BC
1698
+ PUSH DE
1699
+ PUSH HL
1700
+ LD E,A
1701
+ LD C,02H
1702
+ CALL BDOS
1703
+ POP HL
1704
+ POP DE
1705
+ POP BC
1706
+ POP AF
1707
+ RET
1708
+
1709
+ ;----- dumps 8bytes of [HL] to [HL+7] in hexa & ASCII form -----
1710
+
1711
+ DUMP8B: PUSH HL Note: Contents of eight bytes after the
1712
+ LD B,8 address indicated in HL register
1713
+ DUMP1: LD A,(HL) are dumped in both hexadecimal
1714
+ INC HL and character codes.
1715
+ CALL PUTHEX
1716
+ LD A," "
1717
+ CALL PUTCHR
1718
+ DJNZ DUMP1
1719
+ POP HL
1720
+
1721
+ LD B,8
1722
+ DUMP2: LD A,(HL)
1723
+ INC HL
1724
+ CP 20H
1725
+ JR C,DUMP3
1726
+ CP 7FH
1727
+ JR NZ,DUMP4
1728
+ DUMP3: LD A,"."
1729
+ DUMP4: CALL PUTCHR
1730
+ DJNZ DUMP2
1731
+ LD A,0DH
1732
+ CALL PUTCHR
1733
+ LD A,0AH
1734
+ CALL PUTCHR
1735
+ RET
1736
+
1737
+ ;----- work area -----
1738
+
1739
+ BUFMEM: DS 256
1740
+
1741
+ END
1742
+ ```
1743
+
1744
+
1745
+ <p>&nbsp;</p>
1746
+
1747
+ ### 4.1 Peripheral I/O
1748
+
1749
+ The following system calls are intended for input/output operations. Some examples include console I/O (screen/keyboard), auxiliary I/O (external input/output), and printer I/O. Since subroutines such as getting information from the keyboard or controlling printers are necessary for most programs, you will find the system calls described in this section useful for general programming.
1750
+
1751
+
1752
+
1753
+ <p>&nbsp;</p>
1754
+
1755
+ #### Console input
1756
+ * **Function**: 01H
1757
+ * **Setup**: none
1758
+ * **Return value**: A register ⟵ one character from console
1759
+
1760
+
1761
+ When there is no input (no key pressed and input buffer empty), an input is wait for. Input characters are echoed back to the console. The following control character input is allowed: Ctrl-C causes program execution to be halted and a return to the MSX-DOS command level; Ctrl-P causes any sucessive input to also echoed to the printer until Ctrl-N is accepted; Ctrl-S causes the display to stop until any key is pressed.
1762
+
1763
+ ```
1764
+ Ctrl-C ........ system reset
1765
+ Ctrl-P ........ printer echo
1766
+ Ctrl-N ........ halt printer echo
1767
+ Ctrl-S ........ pause display
1768
+ ```
1769
+
1770
+
1771
+ <p>&nbsp;</p>
1772
+
1773
+ #### Console output
1774
+ * **Function**: 02H
1775
+ * **Setup**: E register ⟵ character code to be sent out
1776
+ * **Return value**: none
1777
+
1778
+
1779
+ This system call displays the character specified by the E register on the screen. It also checks the four control characters, listed above.
1780
+
1781
+
1782
+
1783
+ <p>&nbsp;</p>
1784
+
1785
+ #### External input
1786
+ * **Function**: 03H
1787
+ * **Setup**: none
1788
+ * **Return value**: A register ⟵ one character from AUX device
1789
+
1790
+
1791
+ This system call checks four control characters.
1792
+
1793
+
1794
+
1795
+ <p>&nbsp;</p>
1796
+
1797
+ #### External output
1798
+ * **Function**: 04H
1799
+ * **Setup**: E register ⟵ character code to send to AUX device
1800
+ * **Return value**: none
1801
+
1802
+
1803
+ This system call checks four control characters.
1804
+
1805
+
1806
+
1807
+ <p>&nbsp;</p>
1808
+
1809
+ #### Printer output
1810
+ * **Function**: 05H
1811
+ * **Setup**: A register ⟵ one character from console
1812
+ * **Return value**: ```
1813
+
1814
+ This system call does not echo back. It treats control characters in the same way as [function 01H](#console-input).
1815
+
1816
+
1817
+
1818
+ <p>&nbsp;</p>
1819
+
1820
+ #### Direct console input/output
1821
+ * **Function**: 06H
1822
+ * **Setup**: E register ⟵ character code to be send to the console. When 0FFH is specified, the character will be input from the console.
1823
+ * **Return value**: When the E register is set to 0FFH (input), the result of input is in the A register. The value set in the A register is the character code of the key, if it was pressed; otherwise, the value is 00H. When the E register is set to a value other than 0FFH (output), there is no return value.
1824
+
1825
+
1826
+ This system call does not support control characters and does not echo back input. This system call checks four control characters.
1827
+
1828
+
1829
+
1830
+ <p>&nbsp;</p>
1831
+
1832
+ #### Direct console input - 1
1833
+ * **Function**: 07H
1834
+ * **Setup**: none
1835
+ * **Return value**: A register ⟵ one character from console
1836
+
1837
+
1838
+ This system call does not support control characters, nor echo back.
1839
+
1840
+
1841
+
1842
+
1843
+ <p>&nbsp;</p>
1844
+
1845
+ #### Direct console input - 2
1846
+ * **Function**: 08H
1847
+ * **Setup**: none
1848
+ * **Return value**: A register ⟵ one character from console
1849
+
1850
+
1851
+ This system call does not echo back. It treats control characters in the same way as [function 01H](#console-input).
1852
+
1853
+
1854
+
1855
+ <p>&nbsp;</p>
1856
+
1857
+ #### String output
1858
+ * **Function**: 09H
1859
+ * **Setup**: DE register ⟵ starting address of string, prepared on memory, to be sent to the console.
1860
+ * **Return value**: none
1861
+
1862
+
1863
+ 24H ("$") is appended to the end of the string as the end symbol. This system call checks and performs four control character functions, as listed previously.
1864
+
1865
+
1866
+
1867
+ <p>&nbsp;</p>
1868
+
1869
+ #### String input
1870
+ * **Function**: 0AH
1871
+ * **Setup**: The address of memory where the maximum number of input characters (1 to 0FFH) is set should be set in the DE register.
1872
+ * **Return value**: Number of characters actually sent from console is set in the address, one added to the address indicated by the DE register; string sent from console is set in the area from the address, two added to the address indicated by the DE register.
1873
+
1874
+
1875
+ Return key input is considered as the end of console input. However, when the number of input characters exceeds the specified number of characters (contents indicated by DE register, 1 to 255), characters within the specified number of characters will be treated as an input string and set in memory, and the operation ends. The rest of characters including the return key are ignored. Editing with the template is available to string input using this system call. This system call checks and performs four control character function, as listed previously.
1876
+
1877
+
1878
+
1879
+ <p>&nbsp;</p>
1880
+
1881
+ #### Console status check
1882
+ * **Function**: 0BH
1883
+ * **Setup**: none
1884
+ * **Return value**: 0FFH is set in the A register when the keyboard is being pressed; otherwise, 00H is set.
1885
+
1886
+
1887
+ This system call checks and performs four control character function, as listed previously.
1888
+
1889
+
1890
+ <p>&nbsp;</p>
1891
+
1892
+ ### 4.2 Environment Setting and Readout
1893
+
1894
+ The following system calls set the MSX system environment; for example, changing the default drive, or setting various default values of the system.
1895
+
1896
+
1897
+
1898
+ <p>&nbsp;</p>
1899
+
1900
+ #### System reset
1901
+ * **Function**: 00H
1902
+ * **Setup**: none
1903
+ * **Return value**: none
1904
+
1905
+
1906
+ When this is called in MSX-DOS, the system is reset by jumping to 0000H. When MSX DISK-BASIC call this, it is "warm started". That is, it returns to BASIC command level without destroying programs currently loaded.
1907
+
1908
+
1909
+
1910
+ <p>&nbsp;</p>
1911
+
1912
+ #### Version number acquisition
1913
+ * **Function**: 0CH
1914
+ * **Setup**: none
1915
+ * **Return value**: HL register ⟵ 0022H
1916
+
1917
+
1918
+ This system call is for acquiring various CP/M version numbers, on MSX-DOS, however, 0022H is always returned.
1919
+
1920
+
1921
+
1922
+ <p>&nbsp;</p>
1923
+
1924
+ #### Disk reset
1925
+ * **Function**: 0DH
1926
+ * **Setup**: none
1927
+ * **Return value**: none
1928
+
1929
+
1930
+ If there is a sector which has been changed but not written to the disk, this system call writes it to the disk, then it sets the default drive to drive A and sets DMA to 0080H.
1931
+
1932
+
1933
+
1934
+ <p>&nbsp;</p>
1935
+
1936
+ #### Default drive setting
1937
+ * **Function**: 0EH
1938
+ * **Setup**: E register ⟵ default drive number (A = 00H, B = 01H, ...)
1939
+ * **Return value**: none
1940
+
1941
+
1942
+ Disk access by the system calls are made to the drive indicated by the default drive number, unless otherwise specified. Note that, when the drive number, which is set in the FCB specified upon calling the system call, is other than 00H, the default drive setting made by this system call is ignored.
1943
+
1944
+
1945
+
1946
+ <p>&nbsp;</p>
1947
+
1948
+ #### Login vector acquisition
1949
+ * **Function**: 18H
1950
+ * **Setup**: none
1951
+ * **Return value**: HL register ⟵ online drive information
1952
+
1953
+
1954
+ The online drive is the drive connected to MSX normally when the disk system is booted up. Executing this system call causes each drive to be examined whether it is online, and the result is returned in the HL register as shown in [Figure 3.22](#figure-322--login-vector). When the bit is "1", the corresponding drive is online; otherwise it is not.
1955
+
1956
+
1957
+ ##### _Figure 3.22 Login vector_
1958
+
1959
+ ```
1960
+ ------------------------------------------------------------------------
1961
+ | register name | H | L |
1962
+ |----------------+--------------------------+--------------------------|
1963
+ | bit number | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |
1964
+ |----------------+--------------------------+--------------------------|
1965
+ | drive name | meaningless on MSX-DOS | H: G: F: E: D: C: B: A: |
1966
+ |----------------+-----------------------------------------------------|
1967
+ | online/offline | 1 is set for online and 0 for offline in each bit |
1968
+ ------------------------------------------------------------------------
1969
+ ```
1970
+
1971
+
1972
+ <p>&nbsp;</p>
1973
+
1974
+ #### Default drive acquisition
1975
+ * **Function**: 19H
1976
+ * **Setup**: none
1977
+ * **Return value**: A register ⟵ defaut drive number (A = 00H, B = 01H, ...)
1978
+
1979
+
1980
+
1981
+
1982
+ <p>&nbsp;</p>
1983
+
1984
+ #### Setting of address to be transferred to
1985
+ * **Function**: 1AH
1986
+ * **Setup**: DE register ⟵ address setting to be transferred to (DMA address)
1987
+ * **Return value**: none
1988
+
1989
+
1990
+ Though DMA address is initialized to 0080H at system reset, it can be reset to any address by using this system call.
1991
+
1992
+
1993
+
1994
+ <p>&nbsp;</p>
1995
+
1996
+ #### Disk information acquisition
1997
+ * **Function**: 1BH
1998
+ * **Setup**: E register ⟵ number of the objective drive (default drive = 00H, A = 01H, B = 02H, ...)
1999
+ * **Return value**:
2000
+ * A register ⟵ number of logical sectors per one cluster (FFH if E register is set inappropriate)
2001
+ * BC register ⟵ logical sector size
2002
+ * DE register ⟵ amount of clusters
2003
+ * IX register ⟵ DPB starting address
2004
+ * IY register ⟵ FAT starting address on memory
2005
+
2006
+
2007
+ This system call gets the information about the disk in the specified drive. Specifying 00H for the drive number specifies the default drive. For other than that, specify 01H for drive A, 02H for drive B, and so on.
2008
+
2009
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2010
+
2011
+
2012
+
2013
+ <p>&nbsp;</p>
2014
+
2015
+ #### Date acquisition
2016
+ * **Function**: 2AH
2017
+ * **Setup**: none
2018
+ * **Return value**:
2019
+ * HL register ⟵ year
2020
+ * D register ⟵ month
2021
+ * E register ⟵ day of month
2022
+ * A register ⟵ day of week
2023
+
2024
+
2025
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2026
+
2027
+
2028
+
2029
+ <p>&nbsp;</p>
2030
+
2031
+ #### Date setting
2032
+ * **Function**: 2BH
2033
+ * **Setup**:
2034
+ * HL register ⟵ year
2035
+ * D register ⟵ month
2036
+ * E register ⟵ day of month
2037
+ * **Return value**: A indicates whether the system call has done succesfully. If successful, the A register is set to 00H; otherwise, 0FFH.
2038
+
2039
+
2040
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2041
+
2042
+
2043
+
2044
+ <p>&nbsp;</p>
2045
+
2046
+ #### Time acquisition
2047
+ * **Function**: 2CH
2048
+ * **Setup**: none
2049
+ * **Return value**:
2050
+ * H register ⟵ hour
2051
+ * L register ⟵ minute
2052
+ * D register ⟵ second
2053
+ * E register ⟵ 1/100 second
2054
+
2055
+
2056
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2057
+
2058
+
2059
+
2060
+ <p>&nbsp;</p>
2061
+
2062
+ #### Time setting
2063
+ * **Function**: 2DH
2064
+ * **Setup**:
2065
+ * H register ⟵ hour
2066
+ * L register ⟵ minute
2067
+ * D register ⟵ second
2068
+ * E register ⟵ 1/100 second
2069
+ * **Return value**: If successful, the A register is set to 00H; otherwise, 0FFH
2070
+
2071
+
2072
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2073
+
2074
+
2075
+
2076
+ <p>&nbsp;</p>
2077
+
2078
+ #### Verify flag setting
2079
+ * **Function**: 2EH
2080
+ * **Setup**:
2081
+ * E register ⟵ 00H, when resetting verify flag
2082
+ * E register ⟵ value other than 00H, when setting the verify flag
2083
+ * **Return value**: none
2084
+
2085
+
2086
+ Setting the verify flag causes successive writing to the disk to be done in mode "verify on". That is, by reading the contents written on the disk, the check is made to compare them with the contents to be written.
2087
+
2088
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2089
+
2090
+
2091
+ <p>&nbsp;</p>
2092
+
2093
+ ### 4.3 Absolute READ/WRITE (direct access to sectors)
2094
+
2095
+ MSX manages the disk with the "logical sector" as a minimum unit. The logical sector is defined independent of the physical secotrs of the disk, and is numbered from 0 to the maximum logical sector (maximum number depends on the kind of the disks).
2096
+
2097
+ Logical sectors enable users of MSX-DOS or MSX DISK-BASIC to access the disk without being concerned about the number of physical sectors per track, where that number depends on the media type of the disk. In fact, by utilizing system calls which use FCB (file control block), the file can be easily handled in detail even without considering logical sectors, so the user does not even need to use logical sectors. But for some purposes, access using logical sectors is desirable, so MSX-DOS ans MSX DISK-BASIC offer system calls which can access logical sectors.
2098
+
2099
+ This section describes the system calls which access the disk by use of logical sectors.
2100
+
2101
+
2102
+
2103
+ <p>&nbsp;</p>
2104
+
2105
+ #### Reading from the disk using logical sectors
2106
+ * **Function**: 2FH
2107
+ * **Setup**: The logical sector number to be read from (for more than one logical sector, the starting logical sector number) should be set in the DE register. The number of logical sectors to be read should be set in the H register, and the drive number (00H for drive A, 01H for drive B, and so on. The same follows for function 30H below) to be used to read should be set in the L register.
2108
+ * **Return value**: The contents read are set in the DMA buffer.
2109
+
2110
+
2111
+ This system call reads out a specified number of continuous logical sectors from the specified logical sector of the specified drive and stores the contents in memory after DMA. It then stores the contents of what it has read in memory after DMA. [Function 1AH](#setting-of-address-to-be-transferred-to) (which specifies the address it is to be transferred to) assures that there is enough available space in memory.
2112
+
2113
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2114
+
2115
+
2116
+
2117
+ <p>&nbsp;</p>
2118
+
2119
+ #### Writing to the disk using logocal sectors
2120
+ * **Function**: 30H
2121
+ * **Setup**: Contents to be written should be set in memory area after the address indicated by DMA. The logical sector number from where the writing begins should be set in the DE register. The number of logical sectors to be written should be set in the H register. The drive number to be written to should be set in the L register.
2122
+ * **Return value**: none
2123
+
2124
+
2125
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2126
+
2127
+
2128
+ ##### _List 3.4 Cluster dump_
2129
+
2130
+ ```
2131
+ ;*********************************************************
2132
+ ;
2133
+ ; List 3.4 cluster dump
2134
+ ;
2135
+ ; this program must link List 3.3
2136
+ ;
2137
+ ;*********************************************************
2138
+ ;
2139
+ EXTRN GETARG Note: The first 128 bytes of an arbitrary
2140
+ EXTRN STOHEX cluster specified in the command
2141
+ EXTRN PUTHEX line are dumped.
2142
+ EXTRN PUTCHR
2143
+ EXTRN DUMP8B
2144
+
2145
+ BDOS EQU 0005H
2146
+
2147
+ ;----- program start -----
2148
+
2149
+ LD A,1
2150
+ CALL GETARG ;[DE] := 1st argument of command line
2151
+ CALL STOHEX ;HL := evaluate [DE] as hexadecimal
2152
+ ; this is the target cluster No.
2153
+ PUSH HL
2154
+ LD E,00H ;requests the default drive
2155
+ LD C,1BH ;get disk information
2156
+ CALL BDOS
2157
+ POP HL
2158
+ CP 0FFH ;fail ?
2159
+ JR NZ,L2 ;if not fail, A := sector/cluster and goto L2
2160
+
2161
+ LD DE,ERMSG1 ;[DE] := 'Cannot get Disk information'
2162
+ LD C,09H ;string putput function
2163
+ CALL BDOS
2164
+ RET ;error return
2165
+
2166
+ L2: LD E,(IX+12) ;DE := 1st sector of data area
2167
+ LD D,(IX+13)
2168
+ DEC HL
2169
+ DEC HL ;HL := Cluster No. - 2
2170
+ LD B,H
2171
+ LD C,L ;BC := Cluster No. - 2
2172
+ LOOP: DEC A ;Count N times
2173
+ JR Z,RESULT
2174
+ ADD HL,BC
2175
+ JR LOOP
2176
+ RESULT: ADD HL,DE ;HL := sector of target cluster
2177
+ PUSH HL ;save target sector
2178
+ LD DE,NEWDMA ;we reserved 1024 bytes area for DMA
2179
+ LD C,1AH ;Set DMA address function
2180
+ CALL BDOS
2181
+ LD C,19H
2182
+ CALL BDOS ;default drive ?
2183
+ LD L,A
2184
+ POP DE ;DE := target sector
2185
+ LD H,1 ;H := 1 (read 1 sector only)
2186
+ LD C,2FH ;absolute read function
2187
+ CALL BDOS ;data will be set into DMA
2188
+
2189
+ DUMP: LD HL,NEWDMA ;HL := DMA address
2190
+ LD DE,0000H ;DE := relative address from cluster top
2191
+ LD B,16 ;dump 16 lines
2192
+ DLOOP: PUSH BC
2193
+ LD A,D
2194
+ CALL PUTHEX
2195
+ LD A,E
2196
+ CALL PUTHEX
2197
+ LD A," "
2198
+ CALL PUTCHR
2199
+ PUSH HL
2200
+ LD HL,8
2201
+ ADD HL,DE
2202
+ EX DE,HL ;DE := DE+8
2203
+ POP HL
2204
+ CALL DUMP8B ;8 bytes dump subroutine (in another file)
2205
+ POP BC
2206
+ DJNZ DLOOP
2207
+ RET ;all work have done.
2208
+
2209
+ ;----- work area -----
2210
+
2211
+ NEWDMA: DS 1024 ;Private DMA area
2212
+ ADRS: DS 2
2213
+
2214
+ ERMSG1: DB "Cannot get Disk information.$"
2215
+ ERMSG2: DB "Cannot read that cluster.$"
2216
+
2217
+ END
2218
+ ```
2219
+
2220
+ <p>&nbsp;</p>
2221
+
2222
+ ### 4.4 File Access Using FCB
2223
+
2224
+ Since accessing a file is difficult when using the system calls described in the previous section (which read and write logical sectors directly), system calls using FCB are needed to easier access the disk by specifying files.
2225
+
2226
+ There are three categories of system calls using FCB. First is sequential file access and second is random file access, both are offered to maintain CP/M compatibility. The third is what gives MSX-DOS its power: random block access. This method is not available in CP/M. Random block access has the following features:
2227
+
2228
+ * Any record size can be specified
2229
+ * Random access can be made to multiple records
2230
+ * File size can be controlled in bytes
2231
+
2232
+ This section describes system calls for file access using FCB, including random block access. Note that the following three functions do not work correctly when FCB is in the address range 4000H to 7FFFH:
2233
+
2234
+ 1. [Function call 11H](#file-search---1)
2235
+ 2. [Function call 12H](#file-search---2)
2236
+ 3. Input/output for devices (CON, PRN, NUL, AUX)
2237
+
2238
+
2239
+
2240
+ <p>&nbsp;</p>
2241
+
2242
+ #### Opening files
2243
+ * **Function**: 0FH
2244
+ * **Setup**: DE register ⟵ starting address of FCB which is not opened
2245
+ * **Return value**: 00H is set in the A register when a file is opened succeessfully; otherwise 0FFH is set. When a file is opened successfully, each field of the FCB is set.
2246
+
2247
+
2248
+ When 00H is specified for a drive number, the default drive set by [function 0EH (default drive setting)](#default-drive-setting) is used. To open a file on another drive, specify 01H for drive A, 02H for drive B and so on.
2249
+
2250
+ When a file is opened by this system call, all FCB fields except record size, current block, current record, and random record are set using information from the directory area on the disk. Fields which are not set should be set by the user after executing this system call, if needed. The state that each field of FCB is set is "the state that file is opened" when using system calls using FCB, and, in this case, system calls which access the file using FCB, described below, can be used.
2251
+
2252
+
2253
+
2254
+ <p>&nbsp;</p>
2255
+
2256
+ #### Closing files
2257
+ * **Function**: 10H
2258
+ * **Setup**: DE register ⟵ starting address of opened FCB
2259
+ * **Return value**: 00H is set in the A register when file is closed scuccessfully; otherwise, 0FFH is set.
2260
+
2261
+
2262
+ By writing the current contents of FCB in memory to the corresponding directory area on the disk, file information can be kept current. When the file is only read, it does not need to be closed by using this system call.
2263
+
2264
+
2265
+
2266
+ <p>&nbsp;</p>
2267
+
2268
+ #### File search - 1
2269
+ * **Function**: 11H
2270
+ * **Setup**: DE register ⟵ starting address of FCB which is not opened
2271
+ * **Return value**: 00H is set in the A register when the file is found; otherwise 0FFH is set. When the file is found, the directory entry (32 bytes) of the file on the disk is set in the area indicated by DMA, and FCB drive number is set (thus, 33 bytes are used).
2272
+
2273
+
2274
+ Wildcard characters can be used in the name of the file. For example, a specification "????????.c" causes any file name with an extension of "c" to be searched for, and the directory information of the file first found is written in after DMA. To find all matching files or to see whether there is only one matching file, use [function 12H](#file-search---2) described below.
2275
+
2276
+
2277
+
2278
+ <p>&nbsp;</p>
2279
+
2280
+ #### File search - 2
2281
+ * **Function**: 12H
2282
+ * **Setup**: none
2283
+ * **Return value**: 00H is set in the A register when the file is found; otherwise 0FFH is set. When the file is found, the directory entry (32 bytes) of the file on the disk is set in the area indicated by DMA, and the FCB drive number is set (thus, 33 bytes are used).
2284
+
2285
+
2286
+ This system call should be used to search for multiple files meeting the file name specification by wildcard characters in [function 11H](#file-search---1). So this function should not be used by itself.
2287
+
2288
+ This system call allows the directory information of files meeting the specifications in [function 11H](#file-search---1) to be listed in order, one by one.
2289
+
2290
+
2291
+
2292
+ <p>&nbsp;</p>
2293
+
2294
+ #### Deleting files
2295
+ * **Function**: 13H
2296
+ * **Setup**: DE register ⟵ starting address of FCB which is not opened
2297
+ * **Return value**: 00H is set in the A register when file is successfully deleted., otherwise 0FFH is set.
2298
+
2299
+
2300
+ Using wildcard characters for the file name may cause more than one file to be deleted. Exercise caution when using wildcards to delete files.
2301
+
2302
+
2303
+
2304
+ <p>&nbsp;</p>
2305
+
2306
+ #### Sequential readout
2307
+ * **Function**: 14H
2308
+ * **Setup**:
2309
+ * DE register ⟵ starting address of opened FCB
2310
+ * FCB current block ⟵ starting block for readout
2311
+ * FCB current record ⟵ starting record for readout
2312
+ * **Return value**: 00H is set in the A register when readout is successful; otherwise 01H is set. When successful, one record which has been read is set in the area indicated by DMA.
2313
+
2314
+
2315
+ The FCB current block and record will be updated automatically after the readout. That is, in successive readouts, the current block and record do not need to be set. The record size for readout is fixed at 128 bytes.
2316
+
2317
+
2318
+
2319
+ <p>&nbsp;</p>
2320
+
2321
+ #### Sequential writing to the disk
2322
+ * **Function**: 15H
2323
+ * **Setup**:
2324
+ * DE register ⟵ starting address of opened FCB
2325
+ * FCB current block ⟵ starting block for writing
2326
+ * FCB current record ⟵ starting record for writing
2327
+ * 128 bytes starting from DMA ⟵ data to be written
2328
+ * **Return value**: 00H is set in the A register when writing is successful; otherwise 01H is set.
2329
+
2330
+
2331
+ The FCB current block and record will be updated automatically after the readout.
2332
+
2333
+
2334
+
2335
+ <p>&nbsp;</p>
2336
+
2337
+ #### Creating files
2338
+ * **Function**: 16H
2339
+ * **Setup**: DE register ⟵ starting address of FCB which is not opened
2340
+ * **Return value**: 00H is set in the A register when the file is created successfully; otherwise 0FFH is set.
2341
+
2342
+
2343
+ The record size, current block and record, and the random record of the FCB should be set after executing this system call.
2344
+
2345
+
2346
+
2347
+ <p>&nbsp;</p>
2348
+
2349
+ #### Renaming files
2350
+ * **Function**: 17H
2351
+ * **Setup**: New file name should be set within 11 bytes after the 18th byte of the FCB (2nd byte of file size field of FCB = 16 bytes after old file name) corresponding to old file name (that is, it should be set in 18th to 28th byte), the FCB address should be set in the DE register.
2352
+ * **Return value**: 00H is set in the A register when the file name is renamed successfully; otherwise 0FFH is set.
2353
+
2354
+
2355
+ Wildcard characters can be used for both the new and old file names. For example, specifying "????????.o" for the old file name and "????????.obj" for the new file name causes the extension of all files having ".o" to be changed to ".obj".
2356
+
2357
+
2358
+
2359
+ <p>&nbsp;</p>
2360
+
2361
+ #### Random reading from the disk
2362
+ * **Function**: 21H
2363
+ * **Setup**:
2364
+ * DE register ⟵ starting address of opened FCB
2365
+ * random record in FCB ⟵ record for readout
2366
+ * **Return value**: 00H is set in the A register when readout is successful; otherwise 01H is set. When successful, the contents of one record which has been read are set in the area indicated by DMA.
2367
+
2368
+
2369
+ The lenght of the record is fixed to 128 bytes.
2370
+
2371
+
2372
+
2373
+ <p>&nbsp;</p>
2374
+
2375
+ #### Random writing to the disk
2376
+ * **Function**: 22H
2377
+ * **Setup**:
2378
+ * DE register ⟵ starting address of opened FCB
2379
+ * random record in FCB ⟵ record to be written to
2380
+ * 128 bytes starting from DMA ⟵ data to be written
2381
+ * **Return value**: 00H is set in the A register when writing is successful; otherwise 01H is set.
2382
+
2383
+
2384
+ The lenght of the record is fixed to 128 bytes.
2385
+
2386
+
2387
+
2388
+ <p>&nbsp;</p>
2389
+
2390
+ #### File size acquisition
2391
+ * **Function**: 23H
2392
+ * **Setup**: DE register ⟵ starting address of FCB which is not opened
2393
+ * **Return value**: 00H is set in the A register when the function is successful; otherwise 00H is set. When successful, the size of the specified file is set in increments of 128 bytes, in the first three bytes of the random record field.
2394
+
2395
+
2396
+ The file size is calculated in increments of 128 bytes. That is, 2 would be set for files ranging in size from 129 bytes to 256 bytes. Thus a file with 257 bytes would return a value of 3.
2397
+
2398
+
2399
+
2400
+ <p>&nbsp;</p>
2401
+
2402
+ #### Random record field setting
2403
+ * **Function**: 24H
2404
+ * **Setup**:
2405
+ * DE register ⟵ starting address of opened FCB
2406
+ * FCB current block ⟵ objective block
2407
+ * FCB current record ⟵ objective record
2408
+ * **Return value**: Current record position, calculated from the current block and record fields of specified FCB, is set in the random record field.
2409
+
2410
+
2411
+
2412
+
2413
+ <p>&nbsp;</p>
2414
+
2415
+ #### Random writing to the disk - 2 (random block access)
2416
+ * **Function**: 26H
2417
+ * **Setup**:
2418
+ * DE register ⟵ the starting address from the FCB
2419
+ * FCB record size ⟵ size of record to be written
2420
+ * FCB random record ⟵ the record ID number
2421
+ * HL register ⟵ the number of records to be written
2422
+ * DMA memory buffer ⟵ the data to be written
2423
+ * **Return value**: 00H is set in the A register when writing is successful; otherwise 01H is set.
2424
+
2425
+
2426
+ After writing to the disk, the value of the random record field is automatically updated and points to the next record. The size of one record can be set to any value from 1 byte to 65535 bytes by setting the desired value in the FCB record size field. When 0 records are to be written, the file lenght is calculated at the record size multiplied by the record number. The rest is discarded.
2427
+
2428
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2429
+
2430
+
2431
+
2432
+ <p>&nbsp;</p>
2433
+
2434
+ #### Random readout - 2 (random block access)
2435
+ * **Function**: 27H
2436
+ * **Setup**:
2437
+ * DE register ⟵ starting address of opened FCB
2438
+ * FCB record size ⟵ record size to be read
2439
+ * FCB random record ⟵ record to start reading
2440
+ * HL register ⟵ number of records to be read
2441
+ * **Return value**: 00H is set in the A register when data is read successfully; otherwise 01H is read. The number of records actually read is set back in the HL register. When this number is almost one, the data which has been read is set in the area indicated by DMA.
2442
+
2443
+
2444
+ After readout, the random record field is automatically updated. After executing this system call, the total number of records actually read is set in the HL register. That is, if the end of file is reached before the specified number of records have been read, the actual number of records read will be returned in the HL register.
2445
+ This system call has been created for MSX-DOS and is not compatible with CP/M.
2446
+
2447
+
2448
+
2449
+ <p>&nbsp;</p>
2450
+
2451
+ #### Random writing - 3
2452
+ * **Function**: 28H
2453
+ * **Setup**:
2454
+ * DE register ⟵ starting address of opened FCB
2455
+ * FCB random record ⟵ record to be written
2456
+ * 128 bytes in DMA buffer ⟵ data to be written
2457
+ * **Return value**: 00H is set in the A register when writing is successful; otherwise, 01H is set.
2458
+
2459
+
2460
+ The lenght of records is fixed at 128 bytes.
2461
+
2462
+ This system call is the same as 22H except for one point. When the file becomes large, 00H is written to the added records coming before the specified record.
2463
+
2464
+
2465
+ ##### _List 3.5 File dump_
2466
+
2467
+ ```
2468
+ ;********************************************************
2469
+ ;
2470
+ ; List 3.5 file dump
2471
+ ;
2472
+ ; this program must link List 3.3
2473
+ ;
2474
+ ;********************************************************
2475
+ ;
2476
+ EXTRN GETARG Note: gets the dump list of the file
2477
+ EXTRN STOHEX specified at the command line
2478
+ EXTRN PUTCHR
2479
+ EXTRN PUTHEX
2480
+ EXTRN DUMP8B
2481
+
2482
+ BDOS: EQU 0005H Note: The file name specified as the first
2483
+ FCB: EQU 005CH parameter of the command line is
2484
+ stored in the default FCB area
2485
+ from (005CH)
2486
+
2487
+ ;----- program start -----
2488
+
2489
+ LD DE,FCB ;DE := default FCB address
2490
+ LD C,0FH ;open file function
2491
+ CALL BDOS
2492
+ OR A ;success ?
2493
+ JR Z,READ ;if so, goto READ
2494
+
2495
+ LD DE,ERMSG1 ;[DE] := 'Cannot open that file'
2496
+ LD C,09H ;string output function
2497
+ CALL BDOS
2498
+ RET ;error return
2499
+
2500
+ READ: LD A,2
2501
+ CALL GETARG ;get 2nd argument of command line
2502
+ CALL STOHEX ;HL := value of the argument
2503
+ LD (ADRS),HL ;set address counter
2504
+
2505
+ LD DE,NEWDMA
2506
+ LD C,1AH ;set DMA address function
2507
+ CALL BDOS
2508
+
2509
+ LD HL,8
2510
+ LD (FCB+14),HL ;record size := 8
2511
+
2512
+ LD HL,0
2513
+ LD (FCB+33),HL
2514
+ LD (FCB+35),HL ;random record := 0
2515
+
2516
+ RD1: LD HL,NEWDMA ;clear DMA area
2517
+ LD B,8
2518
+ RD2: LD (HL)," "
2519
+ INC HL
2520
+ DJNZ RD2
2521
+
2522
+ LD HL,1 ;read 1 record
2523
+ LD DE,FCB
2524
+ LD C,27H ;random block read function
2525
+ CALL BDOS
2526
+ OR A ;success ?
2527
+ JR Z,DUMP ;if so, goto DUMP
2528
+
2529
+ LD DE,ERMSG2 ;[DE] := 'Ok.'
2530
+ LD C,09H ;string output function
2531
+ CALL BDOS
2532
+ RET
2533
+
2534
+ DUMP: LD HL,(ADRS)
2535
+ LD A,H
2536
+ CALL PUTHEX
2537
+ LD A,L
2538
+ CALL PUTHEX
2539
+ LD A," "
2540
+ CALL PUTCHR
2541
+ LD DE,8
2542
+ ADD HL,DE
2543
+ LD (ADRS),HL
2544
+
2545
+ LD HL,NEWDMA
2546
+ CALL DUMP8B ;dump 8 bytes
2547
+
2548
+ JR RD1
2549
+
2550
+ ;----- work area -----
2551
+
2552
+ ADRS: DS 2
2553
+ NEWDMA: DS 8
2554
+
2555
+ ;----- error message -----
2556
+
2557
+ ERMSG1: DB "Cannot open that file.$"
2558
+ ERMSG2: DB "Ok.$"
2559
+
2560
+ END
2561
+ ```
2562
+
2563
+ <p>&nbsp;</p>
2564
+
2565
+ ## Changes from the original
2566
+
2567
+ - Remarks (1) and (2) about [the FCB format](#figure-319--organization-of-fcb) in version 2 of MSX-DOS have been added.
2568
+
2569
+ - Description of [function call 06H](#direct-console-inputoutput) is modified. The name of this function in the original text is "String output", and the setup description is "E register ⟵ starting address of string to send to the console. When 0FF is specified, the character will be sent to the console as character code."
2570
+
2571
+ - In description of function calls [13H (Deleting files)](#deleting-files) and [23H (File size acquisition)](#file-size-acquisition), the original text has "DE register ⟵ starting address of opened FCB" in setup field. Instead of this, the correct setup explanation is set.
2572
+
2573
+ - In description of function [26H (Random writing to the disk 2)](#random-writing-to-the-disk---2-random-block-access), the correct term "FCB" is set instead of "DMA" in DE register setup explanation.
2574
+
2575
+ - In description of function [27H (Random readout 2)](#random-readout---2-random-block-access), the phrase "When this number is almost one, the data which has been read is set in the area indicated by DMA" has been added.
2576
+
2577
+ - In [1.2 MSX-DOS Environment](#12-msx-dos-environment), "see Chapter 3" has been corrected to "see Section 3".