China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-19 22:27
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Master Ru Ru explains DOS knowledge View 1,427 Replies 9
Original Poster Posted 2003-07-13 00:00 ·  中国 湖南 湘潭 电信
高级用户
★★
Credits 871
Posts 269
Joined 2003-07-02 00:00
22-year member
UID 6298
Gender Male
Status Offline
Master Rush Talks About DOS Knowledge

When the MS-DOS system starts, it first reads in IO.sys, and then in turn msdos.sys, config.sys, command.com, autoexec.bat... Of course, most of the colleagues in this forum at present can't do much with core startup files like IO.sys like the webmaster wengier... Then let's freely DIY in the config file.

When the PC system starts, it will automatically look for the config.sys file. If it doesn't exist, the system will run in the default way, but this default way is not the most suitable for the system to use in most cases. So we should set up the system startup environment, such as setting the use of extended memory, loading the CD-ROM, USB driver programs, etc. When your system has problems like the system can't be used, insufficient program memory, the device can't be found, the sound card can't be driven, can't connect to the network, etc., reasonably modifying config.sys may solve more than half of the problems.

config.sys is a text file, which can be edited, created and modified with any text editor. (Just create a text file, write the content, and then rename it to config.sys.) Of course, if you call the same content by another name, like autoexec.sys... the system will definitely not recognize it. If you add, change or delete any configuration command in the config.sys file, this change will only take effect when DOS is started next time. Everyone must remember this. The config file is only loaded and executed during system initialization...

The above mentioned that when DOS starts, before executing the automatic batch processing commands, it automatically searches for the config.sys file in the root directory where the startup file is located... If this file exists, the system will read this file into memory. And interpret each command in this file line by line (everyone must remember the four words "interpret line by line" to set the current DOS system configuration...

Generally speaking, the config.sys file is an ASCII code text file. Now let's talk about some common commands in the config file and their functions.

1. Check Command
The BREAK command is used to instruct DOS to constantly check whether the user presses the Ctrl_Break key. Its general format is: BREAK=ON/OFF. When break=on, the DOS system checks the Ctrl_Break state at any time. In this state, the user can exit the running program process by pressing the Ctrl+Break combination key (the famous CTRL+C). When break=off, the DOS system only checks whether the user presses the Ctrl+Break combination key when the following conditions are met.
(1) Standard output operation;
(2) Standard input operation;
(3) Standard print operation;
(4) Standard auxiliary operation;

2. Buffer Command
BUFFERS: After DOS starts, it establishes a disk buffer in the system memory. The disk buffer uses a certain area in the memory, and DOS uses it for data operations. The disk buffer is a block of memory area, which is used to store data read from the disk or data written to the disk. When DOS reads or writes a record, it first checks whether the data block containing that record is already in the disk buffer. If not, it reads the data block from the disk into the disk buffer, and then transfers this record to the application program; if the data is already in the disk buffer, there is no need to read from the disk, but directly transfer the data to the application program. Since reading data from the disk is a relatively time-consuming operation, increasing the disk buffer can save a lot of disk reading time. But it should be noted that increasing the disk buffer will occupy memory, thus reducing the memory that the application program can use, which will inevitably increase the number of disk reads and writes, resulting in the software execution speed being slowed down or even unable to execute. Therefore, the number of disk buffers is not set larger is better. The optimal number of disk buffers should be determined according to the user's machine configuration and the type of programs usually run. The general format of the buffers command is: BUFFERS=an integer between 1-99, and its default value is 2, and for ibmdos it is 3.

3. Set the Number of Open Files
The FILES command and the FCBS command generally set the number of files that the DOS system can handle simultaneously. When we want to install some games (like DD's Chinese Paladin), when copying or decompressing a large number of small files, the number of files may be several thousand. At this time, we can increase the upper limit of FILES. This will increase the speed of copying or decompressing by DOS. But remember, this will occupy a lot of memory. The FILES command can only control the number of files that the file manager (word) can open simultaneously, and will not affect the number of files that the file control block (FCB) can open simultaneously.
Its command general format is:
FILES=(an integer between 8-255), and its default value is 8
FCBS=(an integer between 1-255), (an integer between 0-255), and the default value is 40, 0. The number in front of FCBS= must be greater than the number behind. The number in front specifies the maximum number of files that the file control block (FCB) can open simultaneously, and the number behind specifies the number of files that the DOS system cannot automatically close when the file control block (FCB) opens the corresponding files simultaneously. If an error occurs due to DOS closing a certain FCBS file, you can increase the value in front. When the FCBS command statement is used in the config file, the resident space of DOS will increase. Most application software uses FILES to manage open files.

4. Driver Loading
We know that various external devices of the PC have corresponding device driver programs, and the system needs to load their driver programs when using these devices. The DEVICE command is for this job. It loads all the standard device drivers (floppy disk, hard disk, keyboard and other input and output device) that we need when running the DOS system, as well as the device drivers other than those supported. And we can load our own driver files. Its general command format is:
DEVICE=drive letter/path (folder)/device driver file
This command is a very unique command in the config file because it can be used multiple times to specify the driver programs of multiple devices with different functions. In some cases, we can add HIGH after the DEVICE command to load the device driver into the upper memory area to save the conventional memory of DOS.

5. Set the Command Processor
The SHELL command is used to set the command interpreter used by the DOS system. DOS defaults to command.com as the outermost command processing program. If we use other compatible DOS system's command (such as I once used romdos's command.com in msdos), we should use the SHELL command to set it in the config file. We can also use this command to call other more powerful command interpreters, such as 4dos, exe, etc. Of course, if someone develops a better command interpreter by themselves (such as aommand.com or 7dos.exe, etc.), the SHELL command can also be used to load it. The general format of this command is SHELL=drive letter/path (folder)/command manager program. If the command manager and this config file are in the current disk, the path can be omitted.

6. Set Variables
The SET command is used to change the limitation of the string in the DOS system environment. Establish a new DOS environment. This command reflects the real meaning of man-machine interaction. The operator and the system can use the memory area specified by this command to change specific limitations and default settings. This command can be used to establish variables from %0 to %9.
At this time, the format is: SET variable name (string)=any setting value from %0 to %9.
If we want to use this variable, we can use the % symbol before and after this string (variable) in the batch command file. For example: After we set tmp=c:\dos, we can use the DIR %tmp% statement in the batch command to open and view the content in the c:\dos folder. This command was used in the autoexec file before DOS6 mode. Of course, it can also be used in the batch command now.

There are some specific commands in DOS. For example, some instructions included in command such as copy, del, type, etc., which are called internal commands. Some in the autoexec file such as for, call, lh, if... and so on. Similarly, which commands are supported in the config file? I will list the names one by one below, and the explanation work will be done later.
List of config configuration file commands:
ACCDATE BREAK BUFFERS
COMMENT COUNTRY DEVICE
DOS DRIVPARM FCBS
FILS INCLUDE INSTALL
LASTDRIVE LOGO MENUCOLOR
MENUDEFAULT MENUITEM NUMLOCK
REM SHELL STACKS
SUBMENU SWITCHES SET
Among them, commands such as BUFFERS, DEVICE, FCBS, FILES, INSTALL, LASTDRIVE, STACKS, etc., can add the "HIGH" statement to use the extended memory of DOS. Such as: DEVICEHIGH=, of course, it must be when there is extended memory of DOS.

Here, I would like to explain one thing. This explanation is written according to the general usage frequency of the commands. In a sense, it is written according to what I am familiar with and relatively commonly used first... It is not sorted in strict academic order according to the alphabet. Please forgive me... Let's continue to talk below.

7. Set Time and Date Format
Here is a command that we Chinese don't commonly use, COUNTRY. This is a command to set the time and date format. We all know that due to physical reasons of the earth, the races, customs, and times of various countries are all different, so the currencies of various countries are also different. The default of DOS is to use the USA's. COUNTRY can change the default time, date, and currency. The format used is:
COUNTRY=(country codes such as 001-972). There is no Chinese one. So I don't remember the specific code very clearly. I basically don't use this command. I only remember that country E is probably 044. Maybe wengier will know very clearly.

8. Lower Memory Management
This is a very interesting command. The DOS command in DOS. The front DOS refers to the DOS system. The following DOS manages and releases the lower memory for application programs. This DOS establishes and maintains the lower memory and the connection between the lower memory and the upper memory. It can load part of the DOS system into the UMB (upper memory area).
Its general format is:
DOS=HIGH\LOW\AUTO
HIGH: Load part of DOS into the high memory area (HMB)
LOW: Restrict DOS to the low memory area
AUTO: Automatically select where to place DOS.
UMB: Maintain the connection between the lower memory and the reserved memory.
Let DOS be able to use commands such as LOADHIGH and DEVICEHIGH to load devices or programs into the high memory area.
NOUMB: Prohibit DOS from using the high memory area. Restrict the connection between the lower memory and the upper memory. In this command, generally non-contradictory parameters can be used together. When used together, separate them with ",". When using the HIGH and UMB parameters, note that HIMEM.SYS should be loaded at least. This command can exist anywhere in the CONFIG file.

9. Install TSR
Generally, we call the memory-resident program TSR. We know that most program calls are completed through batch processing commands. INSTALL is to install some TSR (memory-resident) programs in memory when the DOS system starts and executes the config file. At this time, the execution of the INSTALL command does not pass through the command (command manager) and does not need to use environment variables. Its general format is:
INSTALL=path/TSR program

10. Include Command
config has a menu function, the purpose of which is to configure the corresponding configuration files for using the machine in different environments. In this way, there will inevitably be some repetitive command statements. And the config file executes the statements one by one. But if we repeat these same statements N times, I believe even the friend with the best temper will scold "bill - damn". But the smart bill provides us with such a command INCLUDE. It indicates that when the option mode exists in the config file, it includes all the contents of another configuration block in a set configuration block. This command allows us to set a set of configuration statements that several configuration blocks commonly use into a single block. Use the INCLUDE command to include this block at the appropriate time. This greatly reduces our repetitive work and the length of the config file. Its command general format is:
INCLUDE=the name of the block that needs to be included.

11. Comment Command
The config file is quite different in the DOS system. In order to let the user understand the meaning, principle, or even purpose of the settings in the config file. We can use the REM command in the config file to add comment statements. Such statements do not participate in execution. Just let the user understand the content of the config file configuration and the operations to be carried out more quickly, etc.
Its command general format is:
REM comment statement.
The rem command allows repeated use. The maximum number of characters after each command statement can reach 123 characters. Characters with special meaning to DOS should be enclosed in double quotes.
This command is common in.bat files and config files. In the batch file (.bat file), it can cooperate with the ECHO command to display the content commented by rem. At this time, ECHO is in the ON state. We can browse the content commented by the rem command through text editors such as EDIT. And we can use the REM command without comments to add blank lines in the.bat file and the config file. But the DOS will ignore the blank lines when starting. So this point is generally not of much significance. (To be continued)
-------------------------------------------------------------------------------------------------------------------
Floor 2 Posted 2003-07-13 00:00 ·  中国 湖南 湘潭 电信
高级用户
★★
Credits 871
Posts 269
Joined 2003-07-02 00:00
22-year member
UID 6298
Gender Male
Status Offline
In the early PC era, computer hardware only supported a 1M-byte addressing space. At that time, hard drives were all luxuries. The operating system operated on floppy disks. It was an era when PCTools and HDCopy ruled the roost. At that time, the main operating system, DOS, was also limited by hardware and could only manage a continuous memory space of up to 1M bytes. Among these 1M bytes of memory, only 640K was left for application programs, which were called conventional memory or base memory. The other 384K was called upper memory, which was reserved for video display, BIOS, etc. In 1982, 640K of memory was more than enough for microcomputers, and people even thought that 640K of memory could be used to do anything. Now it seems a bit funny, but at that time, that was indeed the case. But as times have developed to today, the memory on personal computers is often measured in hundreds of MB. So, do we still have to be limited by the so-called 640K memory limit when using DOS? We can say no. We can use large memory through certain memory management tools. In fact, this problem was well solved by MS in the Windows 95 era. In DOS, there are the following four types of memory in the system:
  Conventional Memory;
  Upper Memory;
  Expanded Memory;
  Extended Memory.

Conventional memory refers to the memory area from 0 to 640K. In DOS, general application programs can only use the system's conventional memory, so they are all limited by 640KB of memory. Moreover, because DOS itself and the device drivers installed in the config.sys file and the memory-resident programs executed in the autoexec.bat file all occupy some conventional memory, the conventional memory that application programs can use is less than 640K. There are many times when we have to try every means to organize memory to leave enough conventional memory for some applications with a relatively large "appetite", which I think is most familiar to many computer enthusiasts in the DOS era.

Upper memory refers to the 384K of memory above conventional memory. Programs generally cannot use this memory area, but EMM386.exe can activate part of the upper memory, and it allows users to load some device drivers and user programs into the upper memory using Devicehigh or LH (that is, loadhigh). dos=high,umb also loads part of DOS into the upper memory. Here, umb is the abbreviation of Upper Memory Block.

Expanded memory is an early standard for increasing memory, and it can be expanded up to 32M at most. To use expanded memory, a special expanded memory board must be installed in the computer, and a management program for the expanded memory board must also be installed. Since expanded memory was introduced before extended memory, most programs are designed to be able to use expanded memory but not extended memory. Since expanded memory is more troublesome to use, it was eliminated soon after extended memory appeared.

Extended memory can only be used on 80286 or higher-end machines. Currently, almost all machines using DOS with more than 1M of memory are extended memory. Extended memory cannot be directly used by DOS either. After DOS 5.0, Himem.sys, an extended memory management program, is provided, and we can manage extended memory through it. EMM386.exe can simulate extended memory (XMS) as expanded memory (EMS) to meet the needs of some programs that require the use of expanded memory.

Finally, it is emphasized again that no matter how large expanded memory or extended memory is, DOS application programs can only run under conventional memory. Some programs can make the CPU enter protected mode through a DOS extender (such as DOS4GW.exe and other programs), so as to directly access extended memory; but it should be noted that after entering protected mode, the computer is out of the DOS state.

How to obtain more conventional memory under DOS? As mentioned earlier, most programs in the DOS environment run in conventional memory. If a program fails to run due to insufficient memory, the most common problem is insufficient conventional memory. So today we introduce several methods to try to free up conventional memory:
1. When the system is configured with extended memory, most of the code of DOS and the resident memory part of Command.com can be installed in the high memory area (HMA). This requires including the following commands in config.sys:       
  device=Himem.sys
  dos=high

Although Himem.sys itself also occupies a small amount of conventional memory, using HMA can save us more conventional memory. And in versions above msdos7, we can use devicehigh=himem.sys to place Himem.sys in the upper memory area. We have already talked about this special command in the config file of DOS earlier. Here, we will briefly talk about Himem.sys.
Himem.sys manages the use of expanded memory and upper memory (HMA). Configure this device driver in the config file through the device command. If we use expanded memory and upper memory, then the device command for installing Himem.sys must be prior to the installation of any other drivers.
Its general command format is:
device=Himem.sys /option
Option:
hmamin=an integer from 0 to 63, the default value is 0
This option specifies the amount of conventional memory that DOS must use before Himem.sys uses HMA (high memory area). Measured in KB.
numhandles=an integer between 1 and 128, the default value is 32
This option specifies the maximum number of EMB (expanded memory block) handles that DOS can use at the same time. Each handle occupies 6 bytes of conventional memory.
int15=an integer from 64 to 65535, the default value is 0
This option specifies the size of expanded memory allocated by the 15h interrupt port. This value must be greater than 64 to ensure sufficient available memory.
machine: The code corresponding to the a20 processor. (I am not very clear about this option)
The a20 processor is a microcomputer component that can access the high memory area.
a20 control:on/off
This option specifies whether Himem.sys gains control of the a20 processor. The default value is on.
shadowram:on/off
This option specifies whether Himem.sys turns off the RAM part of the ROM (read-only memory).
cpuclock:on/off
This option is used to specify whether Himem.sys affects the clock speed of the CPU.
DOS only allows one program to use the high memory area at the same time. If we do not specify /hmamin=xxx, then Himem.sys reserves HMA for the first program that needs it.

RAM is conventional memory that we use now!
ROM, to put it simply, is a piece of memory used by BIOS that is erased and written in a special way. Here, real mode, safe mode, and V86 mode are talked about! And their addressing methods!
0~~640 is called main memory or traditional memory!
640~~1024 is called upper memory!
Above 1024 is called extended memory!
1024~~1088 is called high memory!

Traditional memory!
When DOS starts up, it occupies about 56K of memory! The other 579K is for users to use! Of course, we can use other software to use memory larger than 640K! How can my current dual-channel DDR mix!

Upper memory
This space is reserved for BIOS and hardware interfaces! This 384K of memory is attached to the video rom of the graphics card; video ram and some control cards?! Application programs cannot directly access the data in this area! This is the reason why the computer has a 640K memory limit! Application programs can only use traditional memory! Secondly, 160K of the upper memory is not used! Monochrome monitors can also use more (>160K) and can be used through management programs! This place is what the master said (upper memory blocks) referred to as umb! It is memory that can be used on machines after 80386!

Extended memory
It is located above 2^20 and exceeds the addressing range of 8086, so it can only be used on machines after 80286!
Since DOS can only manage 640K of memory, it must be managed indirectly through an extended memory management program that complies with the XMS specification.
XMS is a specification for extended memory management programs jointly formulated by Intel, Lotus, MS, and AST4. It stipulates a standard interface for determining memory access to extended memory HMA and upper memory, aiming to avoid conflicts caused by random access to this area between programs! Himem.sys and EMM386.exe, etc., all comply!... That is to say, we can only use such software to manage extended memory!


2. Here I emphasize that the contents of the config.sys and autoexec.bat files must be streamlined, and unnecessary memory-resident programs should not be started. These memory-resident programs often occupy a lot of conventional memory. Another reason is that without the skill as proficient as wengier, making these two files concise will reduce the chance of errors. And it is also easy to modify. I often get confused when looking at wengier's configuration.
If the config.sys file contains installation cache programs such as smartdrv.exe or PC-CACHE.COM, as well as virtual disk commands such as ramdrive.sys; xmsdsk.exe, etc., they can be canceled to save conventional memory. Especially smartdrv.exe uses a large amount of conventional memory. So wengier said that PC-CACHE.COM is better. If ramdrive.sys must be used, ensure that the RAM disk is built in extended memory, not in conventional memory. Of course, it is best to use xmsdsk because it will also put itself into XMS.
If the config.sys file contains the buffers command, the number of disk buffers specified by buffers should be reduced. Each buffer occupies 532 bytes of conventional memory. But reducing the number of disk buffers too much will cause some programs to not run normally. Generally, buffers should not be less than 15. This has been mentioned earlier, and it is reiterated here. If the config.sys file contains the lastdriver command, cancel this command or set lastdriver smaller, and do not set it to astdriver=32 or something like that. Because DOS builds a corresponding management block CDS in memory for each logical drive allowed to be accessed, and each CDS occupies about 80 more bytes of conventional memory.
The order of the device and devicehigh commands in the config.sys file is very important, and it will affect the effective use of memory and the correct operation of a series of programs when config.sys starts. It is best to install device drivers in the following order in the config.sys file:
 1. Himem.sys;
 2. Device drivers that use extended memory;
 3. EMM386.exe. If EMM386 is used to simulate expanded memory and provide access to high memory blocks (UMBs), then the EMM386 command line should include the RAM switch instead of NOEMS. NOEMS prohibits EMM386.exe from simulating expanded memory, but it provides the largest available high memory blocks for installing device drivers and running other programs.
 4. Device drivers that use expanded memory;
 5. Device drivers that use high memory blocks (UMBs).
For autoexec.bat, my suggestion is also to streamline: remove those memory-resident programs that users do not need; if the mouse is not used on the command line, do not install any mouse device drivers, such as mouse.com because the mouse can be used by typing mouse.com at any time. The same is true for some other similar programs.

Try to install device drivers and run other TSR (memory-resident) programs in the upper memory area (UMB) as much as possible. That is to say, as long as high can be used, it should be used resolutely. Please also try to use the LH command to load programs in the autoexec file. (End)
---------------------------------------------------------------------------------------------------------------




Floor 3 Posted 2003-07-13 00:00 ·  中国 北京 科技网
银牌会员
★★★
颓废青年
Credits 2,265
Posts 721
Joined 2003-05-12 00:00
23-year member
UID 2032
Gender Male
Status Offline
I've read it carefully, and I've gained a lot of new knowledge! It's suggested that beginners read it carefully! There seems to be a bit of confusion about the various memory designations in the middle.
Floor 4 Posted 2003-07-13 00:00 ·  中国 湖南 湘潭 电信
高级用户
★★
Credits 871
Posts 269
Joined 2003-07-02 00:00
22-year member
UID 6298
Gender Male
Status Offline
Floor 5 Posted 2003-07-15 00:00 ·  中国 江苏 苏州 昆山市 电信
初级用户
想学DOS的人
Credits 179
Posts 26
Joined 2003-06-14 00:00
23-year member
UID 5103
Gender Male
Status Offline
It's quite well organized, better than what I organized myself. Kudos!
也许DOS有些难,可是我很想学会DOS
Floor 6 Posted 2003-07-16 00:00 ·  中国 湖北 武汉 电信
元老会员
★★★★★
步行的人
Credits 9,654
Posts 3,351
Joined 2003-03-11 00:00
23-year member
UID 1113
Gender Male
From 湖北
Status Offline
Thanks. It's not finished yet. ......
弄花香满衣,掬水月在手。
明月鹭鸟飞, 芦花白马走。
我自一过后,野渡现横舟。
青云碧空在,净瓶水不流。
http://dos.e-stone.cn/guestbook/index.asp
======中國DOS聯盟=====
我的新网页http://rsds.7i24.com欢迎光顾
Floor 7 Posted 2003-07-18 00:00 ·  中国 四川 成都 电信
初级用户
Credits 145
Posts 29
Joined 2003-07-16 00:00
22-year member
UID 6983
Gender Male
Status Offline
Thanks! I'll study it in detail.

What I need most at present is to add the function of "boot from hard disk" on the system floppy disk generated in the Win98 system through the guidance and help of netizens. Because this is conducive to me not being in a hurry to take out the system floppy disk when restoring the backup with GHOST.

I specially invite the moderator and netizens to help. Thanks!!
xwx552kx@sina.com
Floor 8 Posted 2003-08-04 00:00 ·  中国 湖南 湘潭 电信
高级用户
★★
Credits 871
Posts 269
Joined 2003-07-02 00:00
22-year member
UID 6298
Gender Male
Status Offline
Finish writing and then organize it
Floor 9 Posted 2003-10-14 00:00 ·  中国 广东 深圳 南山区 电信
初级用户
Credits 105
Posts 1
Joined 2003-10-14 00:00
22-year member
UID 11253
Gender Male
Status Offline
Thank you very much! It saved me a lot of time
Floor 10 Posted 2003-10-15 00:00 ·  中国 山东 烟台 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re: Master Rushi:

I took a quick look and feel there are some issues with the memory part:

UMB is generally translated as "Upper Memory Block" because the high memory is used by another term HMA (High Memory Area, corresponding to "high" in dos=high,umb). The memory concepts related to DOS are complicated and easy to confuse (I still can't remember exactly the correspondence between expanded, extended and 扩充, 扩展), it is suggested to represent it with a diagram, which is clear and effective, but I don't have the time for that.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Forum Jump: