I don't know about you but I'm definitely not a morning person. It takes me about an hour and at least two cups of coffee to wake up. I remember one time, back when I was married, my wife changed the kitchen around one day. I would have been all right if she hadn't left the empty bottle of coke right where the jug kettle used to be. I spent 10 minutes trying to switch on the coke bottle before I realised what was wrong :-)

Thinking about that incident afterward I realised that I have to go through a set routine in the mornings and anything that changes it causes me to crash - just like a PC. Which brings me to what I want to talk about this month.

Waking your PC up in the Mornings

Just like me, your PC goes through a set procedure when you switch it on. This procedure is designed to load the operating system. It is the operating system that allows you do to things such as run programs, read and write files and so on. It also reads characters from the keyboard and writes them to the screen. In fact without an operating system any computer is just some very expensive junk. [Unless, of course you happen to think in machine code and are capable of writing your own operating system from scratch :-)]

The first thing that happens is that the hardware in you PC carries out some simple tests. These test are known as the Power On Self Test or POST. The most noticeable part is the memory test since it is this that is responsible for the numbers in the top left corner of the display. The main function of the POST is to make sure that the hardware, such as hard disk drives, floppy disk drives and so on, that is supposed to be there is in fact present. The PC knows what should be there from looking in a special area of memory called the CMOS.

Once the POST has completed the PC looks for the operating system. Well sort off. What it actually does is find a small program called the 'bootstrap' program. It is the bootstrap program that actually loads the operating system, which is known as 'booting' the PC. Incidentally it is called Booting since the computer is basically lifting itself up by its own boot straps.

The bootstrap program is present on ALL formatted disks, including diskettes, even if the disk is not a boot disk. The bootstrap program is very small and will fit into 512 bytes. This means that it will fit into a single sector on the disk. This sector is known as the Boot Sector. On a diskette it is always the very first sector on the disk. On a hard disk however, the boot sector is the first sector of the primary Dos partition. A hard disk can be divided up into a number of different partitions, each of which Dos thinks is a different hard disk. Since each of these partitions has a boot sector the PC needs to know which one to boot from. [Actually it can get very complicated since it is possible to have different operating systems in each partition. However, for simplicity we will assume that all the partitions are Dos ones.] The answer is to have the information on the hard disk itself. Then all the PC has to do is read it. Since the PC is looking for a bootstrap program all we do is replace the Dos bootstrap program with one that reads the hard disk, finds the required partition and loads the bootstrap program from it. To make things simple, this program is put in the first sector of the hard disk just like the bootstrap program. This sector is known as the Partition Sector or The Master Boot Record [MBR].

Once the PC has found the bootstrap code it can load it and execute it. Now this piece of code is very simple and all it can do is find, and load, the first part of the operating system. This first part is file called IO.SYS, or IBMBIO.Com, and it provides the Basic Input and Output functions. Well, actually that's not exactly true. What it actually does is provide routines which will handle the basic I/O functions. The other thing that IO.SYS does is to load the second part of the operating system, a file called MSDOS.SYS or IBMDOS.Com. MSDOS.SYS provides what is called High Level Interfaces to various things. Basically what that means is that it provides programmers with a “simple” way of doing things. Well it's simpler than writing your own routines anyway :-)

After MSDOS.SYS has started up it will load the Command Processor. This is usually Command.Com but can be something else such as, for example 4dos. Again to make things easier we will assume that Command.Com is the one being used.

Up to this point there has been very little that we can do to change things. While it is possible to make changes to the Partition Sector code, the boot sector code and both IO.SYS and MSDOS.SYS, it is VERY dangerous. Slightly less dangerous is writing your own command processor but even with that you would need to be a good programmer and have a very good knowledge of both DOS and the hardware in you PC to even attempt it. And if you get it wrong you would loose everything.

There are however two other parts to Dos which can be, and indeed are designed to be, modified by you. They are the files Config.Sys and Autoexec.Bat. The idea of these two files is that they allow Dos to be customised. For example you have a set up for each country thus allowing you to have your own currency symbol instead of using, say the dollar sign.

But why have two files? Surely one would do just as well.

Not really. The two files are quite different. The best way to think of them is that Config.Sys makes changes to the operating system, eg changes it for your country etc., while Autoexec.Bat just runs simple Dos commands. In practice Config.Sys is processed much sooner than the Autoexec.Bat file, which is in fact the last part of the boot up sequence.

The original idea of allowing you to set up Dos the way you wanted it was pretty good. Unfortunately, as time went on programmers made different assumptions as to how you would set it up. They also found various problems with Dos and came up with various ways around the problems. The result is that you may find yourself needing a number of different versions of Config.Sys and Autoexec.Bat.

Up to and including Dos version 5 the only ways around this involved either a third party program or a series of batch files. Dos 6, however introduced the [Menu] command. This gives you the ability to have a number of different set-ups and to select the one you want at boot up time. I personally find that this makes live so much easier since I can have one set-up for windows, one for games, one for testing, one for programming, one for the network and so on. To put it another way, I very rarely have trouble installing and running games.

An example Config.Sys is shown below

[Menu]

MenuItem = Standard,Standard Configuration
MenuItem = Games,Minimum setup for Games

MenuDefault = Standard, 20
NumLock = Off

[Common]
Switches /f

[Standard]

Device=c:\Dos\HiMem.Sys
Device=c:\Dos\Emm386.Exe NoEMS 3072 x=ce00-ceff

Dos=UMB,HIGH

DeviceHigh =c:\Dev\Hit-Ide.Sys /D:MSCD020 /N:1
DeviceHigh =c:\proaudio\mvsound.sys d:5 q:10 s:1,220,1,5 m:0 j:0
DeviceHigh =c:\Mouse\Mouse.Sys
DeviceHigh =c:\Dos\ANSI.Sys

Shell=c:\Dos\Command.Com c:\Dos\ /e:1024 /p
Country=44,,C:\Dos\Country.Sys

Stacks=9,256
Buffers=15,0
Files=60
FCBS=4,0

[Games]

Dos=UMB,HIGH

DeviceHigh =c:\Dev\Hit-Ide.Sys /D:MSCD020 /N:1
DeviceHigh =c:\ProAudio\MvSound.Sys d:5 q:10 s:1,220,1,5 m:0 j:0
DeviceHigh =C:\Mouse\Mouse.Sys

SHELL=C:\DOS\COMMAND.COM C:\DOS\ /e:512 /p
Country=44,,C:\Dos\Country.Sys

Stacks=9,256
Buffers=15,0
Files=60
FCBS=4,0

This Config.Sys will display a menu with two options:-

Standard Configuration
Minimum setup for Games

Selecting the first option will set the PC up for normal working allowing programs such as Windows to be run. The second option on the other hand will set the PC up with a minimum configuration for playing games. Naturally, the actual commands required in each section depends upon the individual PC, but the above will do to explain the Dos menu system.

The important bits are the ones in between the square brackets. These commands divide the Config.Sys up into various sections. In the above example there are four sections, [Menu], [Common], [Standard] and [Games]. The first two will always be executed but only one of the others will be.

The [Menu] section, is used to set up the menu. At its simplest it will consist of the [Menu] section header command and two or more lines starting with the MenuItem= command. The command has two parts, or parameters, after the equals sign. The first of these parameters is the name of the menu item and second is the text that is displayed when the menu is shown. The two parameters are separated by a comma. The names of the menu items, Standard and Games in the above example, are used as the names of sections later in the Config.Sys file and in the Autoexec.Bat.

There are a number of other command which can be in the [Menu] section but none of them are necessary. The above example uses the MenuDefault and NumLock commands. If you tend to select the same option more often than the others then it is possible to have that option selected automatically after a certain time. The above example use the MenuDefault command to select the Standard option if no selection is made within 20 seconds.

The NumLock = Off just turns off the num lock.

The remaining sections all contain standard Config.Sys commands. The [Common] section contains commands that are executed regardless of which menu item is selected. The other two sections contain commands that will only be executed when the corresponding menu item is selected. So, for example, if you select the Standard Configuration option then the code in the [Standard] section will be executed, but the [Games] section will not be.

The Autoexec.Bat file does not have any special menu commands. Instead use is made of the GoTo command in the same way that the Universal Batch does [see The Re-Boot article in issue 2]. The menu system creates a system variable called Config. All that is needed is to have a label for each menu item name and a GoTo %Config% command at the start of the Autoexec.Bat file. An example one is shown below:-

@Echo Off
Rem *****************************************************
Rem * Autoexec.Bat                                      *
Rem * ~~~~~~~~~~~~                                      *
Rem * Batch file to set up initial configuration.       *
Rem *---------------------------------------------------*
Rem * Written by D. Wadler                     01-06-91 *
Rem *****************************************************

GoTo %Config%

Rem *---------------------------------------------------*
Rem * Things required for the normal boot up            *
Rem *---------------------------------------------------*

:Standard

C:\ANTIV\TOOLKIT\GUARD

Set Comspec=c:\Dos\Command.Com
PATH C:\DOS;C:\Windows;c:\;c:\Bat;c:\Bin;c:\scsi;c:\proaudio
Prompt $P$G
set blaster=A220 D1 I5 T3
Mode Con Lines=50

LoadHigh C:\DOS\MSCDEX.EXE /D:MSCD020 /M:8
LoadHigh C:\Dos\SmartDrv.Exe /X

LoadHigh C:\DOS\KeyB.Com UK,,c:\Dos\KeyBoard.Sys /Id:166
LoadHigh C:\DOS\DosKey

DosKey Dir=Hdir $* /2
DosKey Win=Do Win $*
DosKey VDU=Mode Con Lines=50

GoTo Fini

Rem *-------------------------------------------*
Rem * Set up required for Games                 *
Rem *-------------------------------------------*

:Games

C:
PATH C:\DOS;C:\Windows;c:\;c:\Bat;c:\Bin;c:\scsi;c:\proaudio
PROMPT $p$g
SET COMSPEC=C:\DOS\COMMAND.COM
set blaster=A220 D1 I5 T3

C:\DOS\MSCDEX.EXE /D:MSCD020 /M:8
C:\DOS\KeyB.Com UK,,c:\Dos\KeyBoard.Sys /Id:166

GoTo Fini

Rem *---------------------------------------------------*
Rem * Things required for all configurations            *
Rem *---------------------------------------------------*

:Fini

Set TEMP=C:\Windows\Temp
Set WSWWORK=C:\Temp
Set DosX=-WIN30GROW
Set S_Host=CASTLE

Echo On

Hopefully the above will enable you to have a look at the menu system. Next month I'll talk about the standard commands that you can put into Config.Sys and Autoexec.Bat and explain how you can configure your memory.