IMPORTANT INFORMATION

If you have IBM applications which ran under DOS
Versions 1.00 or 1.10, please refer to Appendix K
for information about using those applications
under DOS Version 2.00.

--- --- - ----------_.---- --

Personal Computer
Computer Language
SeriesDisk
Operating
Systemby Microsoft, Inc.

First Edition Ganuary 1983)
Version 2.00

International Business Machines Corporation provides this manual "asis" without warranty of any kind, either express or implied, including,but not limited to the implied warranties of merchantability andfitness for a particular purpose. IBM may make improvements and orchange in the product(s) and or the program(s) described in thismanual at any time and without notice.
Products are not stocked at the address below. Requests for copies ofthis product and for technical information about the system should bemade to your authorized IBM Personal Computer Dealer.
This publication could contain technical inaccuracies or typographicalerrors. Changes are periodically made to the information herein; thesechanges will be incorporated in new editions of this publication.
A Reader's Comment Form is provided at the back of this publication.
If this form has been removed, address comments to: IBM Corp.,
Personal Computer, P.O. Box 1328-C, Boca Raton, Florida 33432.
IBM may use or distribute any of the information you supply in any
way it believes appropriate without incurring any obligations
whatever.

© Copyright International Business Machines Corp. 1983
© Copyright Microsoft, Inc. 1983Preface

Read This First

This reference manual comes in two sections.
Sections 1 and 2 explain how to use the IBM
Personal Computer Disk Operating System
Version 2.00 (DOS). Section 1 DOS Guide covers
those topics that apply to all DOS users that areusing developed application programs. Section 2
Advanced DOS Features and Technical Reference covers
those topics that apply to more experienced DOS
users, system programmers, or those who will be
developing their own applications. These two
sections provide information on how to issuecommands to DOS to create, edit, link, debug, andexecute programs. They also explain how to
prepare DOS and your fixed disk for use, and how
to use the new features of DOS Version 2.00.

First Time Users
Before using your DOS diskette for the first timeread the sections "About Diskettes" and "Backing
Up Your DOS Diskettes" in Chapter 1.

iii

Experienced DOS Users
Before you use DOS Version 2.00 for the first time,please read "DOS Version 2.00 Enhancements" in
Chapter 1 and "Appendix A" in Section 2.

About Your DOS Diskettes
DOS Version 2.00 is shipped on two diskettes. The
first labeled "DOS" contains the DOS programs
and commands. It is referred to as the DOS
diskette in this manual. The second diskettelabeled "DOS Supplemental Programs" contains
the LINK Utility, EXE2BIN, DEBUG, and several
BASIC sample programs (see the BASIC manual
for information about the sample programs).

Terms Used
The terms "disk," "diskette," and "fixed disk" areused throughout this manual. Where "diskette" isused, it applies only to diskette drives anddiskettes. Where "fixed disk" is used, it applies
only to the IBM nonremovable fixed disk drive.
Where "disk" is used, it applies to both fixed disks
and diskettes.

ivConsiderations for Using
Applications

If you have any of the following applications,please refer to Appendix K for additional
information about using these applications withDOS Version 2.00:•

Accounting Packages by BPI Systems, Inc.

•

Accounting Packages Version 1.00 by
Peachtree Software, Inc.

•

Accounting Packages Version 1.10 by
Peachtree Software, Inc.

•

Ari thmetic Games 1 and 2•

Asynchronous Communications Support
Version 1.00•

Asynchronous Communications Support
Version 2.00•

EasyWriter Version 1.10•

Fact Track•

PFS:File•

PFS:Report•

SNA 3270 Emulation and RJE Support
Version 1.00•

The Dow Jones Reporter Version 1.00v

•

Typing Tutor•

VisiCalc Version 1.10•

3101 Emulator Version 1.00

Organization of This ManualThis manual has 14 chapters and 11 appendixes.
Section 1. DOS Guide contains:
Chapter 1 contains introductory information
about DOS, DOS diskettes, diskette drives, files,
and automatic program execution.
Chapter 2 contains information about startingDOS, as well as directions on how to use thecontrol keys and DOS editing keys.
Chapter 3 is an introduction to some of the morecommonly used DOS commands.
Chapter 4 contains detailed descriptions of using
fixed disk on your system.
Chapter 5 describes how to use tree-structured
directories.
Chapter 6 contains detailed descriptions of thecommands you can issue to DOS. These
commands enable you to manage files, maintain
disks, and create and execute programs.
Chapter 7 describes how to use the Line Editor(EDLIN) program to create, alter, and display
source language files and text files.
Chapter 8 lists messages generated by the
programs described in this manual.
viSection 2. Advanced DOS Features andTechnical Reference contains:
Chapter 9 describes how to configure your system.
Chapter 10 contains detailed descriptions of theadvanced commands you can issue to DOS.
Chapter 11 describes how to use the linker (LINK)
program to link programs together before
execution.
Chapter 12 describes how the DEBUG programprovides a controlled test environment so you canmonitor and control the execution of a program tobe debugged; by altering, displaying, andexecuting object files.
Chapter 13 contains detailed information about
using extended screen and keyboard functions.
Chapter 14 contains detailed information about
Device Drivers.
Appendix A describes DOS enhancements.
Appendix B contains general technicalinformation, and introduces the technicalinformation in Appendixes C-H.
Appendix C describes allocation of space on disk.
Appendix D describes the system interrupts andfunction calls.
Appendix E describes control blocks and work
areas, including a Memory Map, Program Segment,
and File Control Block.

vii

Appendix F describes how to execute commands
from within an application.
Appendix G contains technical information about
DOS support of fixed disks.
Appendix H contains detailed information about. EXE file structure.
Appendix I describes how to run compilers and themacro assembler with a fixed disk.
Appendix J describes how to run the Pascalcompiler with a fixed disk.
Appendix K describes how to use applications withDOS Version 2.00.

viii

Contents

Section 1. DOS Guide
Chapter 1. Introduction .................
What Is DOS? ..........................
Why You Should Use DOS ..............
DOS Version 2.00 Enhancements ........
Backing Up Your DOS Diskettes ........
About Diskettes ........................
Formatting Your Diskettes ..........
Single- and Dual-Sided Diskettes .....
Protective Jacket ....................
How It Works ......................
Tracks, Bytes, and Sectors ...........
Careful Does It .....................
Write-Protect Notch ................
About Diskette and Drive
Compatibility .........................
Single Diskette-Drive Systems. . . . . . . . . . .
Automatic Program Execution ..........
Chapter 2. Getting DOS Started ........
Loading (Starting) DOS .................
If Your Computer Is Off .............
If Your Computer Is On .............
Telling DOS the Date ...............
Telling DOS the Time ...............
The DOS Prompt ...................
Specifying the Default Drive .........
Files and Filenames .....................
Bad, Okay, and Good Names
for Files ...........................
File Specifications ...................

1-1
1-3
1-4
1-5
1-6
1-7
1-7
1-8

1-9
1-9
1-10
1-12
1-12

1-14
1-14
1-16
2-1
2- 3

2-4
2-5
2-6
2-8
2-11
2-12
2-12

·2-16
2-16

ix

x

Using Global Filename Characters ......
The? Character .....................
The * Character .....................
Some Keys You Use with DOS ..........
Characters That Look Alike-Oh's andZeros, Ones and Els ................
The Spacebar .......................
The Shift and Caps Lock Keys... . .. . .
To Enter a Command ................
To Stop a Command ................
To Correct a Typing Mistake .........
To Stop the Screen Long Enough toRead It ............................
To Print What Is on the Screen ......
To Print Whatever You Type ........
To Start DOS Again .................
Control Keys ...........................
DOS Editing Keys ......................
Examples of Ways To Use DOS
Editing Keys .......................
To Start EDLIN .....................
To Stop the Editing Session .............

2-18
2-18
2-19
2-21

Chapter 3. Using DOS ..................
Introduction ............................
Giving DOS a Command ............
Getting a Diskette Ready to Be Used ....
Using the FORMAT Command.......
Before You Begin ...................
If You Want DOS on Your
Diskette ...........................
With One Drive ................
With Two Drives ...............
If You Do Not Want DOS on Your
Diskette ...........................
Formatting Several Diskettes ........
Backing Up a Diskette ..................
Using the DISKCOPY Command ....
Before You Begin ...................
Protecting Your Original Diskette ....
Backing Up with One Drive. . ... ... . .
Backing Up with Two Drives .........

3-1

2-22
2-23
2-24
2-25
2-25
2-26
2-27
2-27
2-28
2-28
2-29
2- 35
2-40
2-41
2-52

3- 3
3- 3
3-4
3-4
3- 5

3- 5
3-5
3-8
3-9
3-9
3-10
3-10
3-11
3-11
3-12
3-15

Backing Up One File... . .. ... . . . . . . . .. . .
Using the COpy Command..........
Before You Begin ...................
Copying a File to the Same
Diskette ...........................
Copying a File to Another Diskette
Using One Drive ...................
For You to Try .................
Copying a File to Another Diskette
Using Two Drives ..................
For You to Try ................
Backing Up More Than One File ........
Using the COpy Command ..........
Finding Out What Is on a Diskette ......
Using the DIR Command ............
Before You Begin ...................
To List All the Files .................
With One Drive ...............
With Two Drives ..............
To List One File ....................
With One Drive ...............
With Two Drives ..............
Displaying What Is in a File .............
Using the TYPE Command ..........
Before You Begin ...................
Here's How You Do It ..............
Changing a File's Name .................
Using the RENAME Command.......
Before You Begin ...................
With One Drive ...............
With Two Drives ..............
For You to Try ................
Removing a File from a Diskette ........
Using the ERASE Command .........
Before You Begin ...................
With One Drive ...............
With Two Drives ..............
Global Filename Characters. . . . . . . . . .
Shifting the Display on the Screen ......
Using the MODE Command .........
Before You Begin ...................
Shift Right. . . . . . . . . . . . . . . . . . . . . . . . .

3-18
3-18
3-20
3-20
3-22
3-26
3-26
3-28
3-29
3-29
3-30
3-30
3-30
3-30
3-30
3-32
3- 32
3-32
3-33
3-34
3-34
3- 34
3- 34
3-37
3-37
3-37
3-38
3- 39
3-40
3-41
3-41
3-41
3-42
3-43
3-43
3-44
3-44
3-44
3-44
xi

Helps and Hints ........................
Summary ...............................

3-46
3-48

Chapter 4. Preparing Your Fixed Disk. ..
Introduction. . . . . .. . . . . . . . . . . . . . . . . . . . . .
Fixed Disk Qrive Letters ................
Preparing Your Fixed Disk ..............
Setting Up the DOS Partition .......... '.
Partitioning Your Fixed Disk ...........
Creating the DOS Partition(Option 1) .........................
Changing Active Partition(Option 2) .........................
Deleting DOS Partition(Option 3) .........................
Displaying Partition Data
(Option 4) .........................
Selecting Next Fixed Disk Drive(Option5) .........................

4-1
4-3
4-5
4-6
4-8
4-12

Chapter 5. Using Tree-Structured
Directories ............................
Introduction ............................
Directory Types .........................
The Current Directory ..............
Specifying the Path to a File .............
Directory Commands ...................
Creating a Sub-Directory ............
Deleting a Directory ................
Displaying and Changing theCurrent Directory ..................
Displaying the Directory
Structure ..........................
Where DOS Looks for Commands andBatch Files ............................
Chapter 6. DOS Commands.............
Introduction. . . . . . . . . . . . . . . . . . . . . . . . .. . .
Types of DOS Commands ...............
Format Notation .......................

xii

4-15
4-19
4-20
4-22
4-23

5-1
5- 3
5 -5
5-6
5-7
5-11
5 -11
5 -12
5-12
5-12
5-13
6-1
6-5
6-6
6-8

DOS Command Parameters ............ .
6-9
Reserved Device Names ............ . 6-13
Global Filename Characters ......... . 6-14
Detailed Descriptions of the
DOS Commands ...................... . 6-17
Information Common to All DOS
Commands ....................... . 6-17
ASSIGN (Drive) Command ............. . 6-21
BACKUP (Fixed Disk) Command ...... . 6-24
Batch Commands ...................... . 6-28
The AUTOEXEC.BAT File ......... . 6-31
Creating a .BAT File with Replaceable
Parameters ....................... . 6-32
Executing a .BAT File with
Replaceable Parameters ........... . 6-34
ECHO Subcommand ............... . 6-35
FOR Subcommand ................. . 6-37
GOTO Subcommand ............... . 6-38
IF Subcommand ................... . 6-40
SHIFT Subcommand ............... . 6-45
PAUSE Subcommand .............. . 6-47
REM (Remark) Subcommand ....... . 6-49
BREAK (Control Break) Command ..... . 6-50
CHDIR (Change Directory) Command .. . 6-52
CHKDSK (Check Disk) Command ..... . 6-54
CLS (Clear Screen) Command .......... . 6-58
COMP (Compare Files) Command ...... . 6-59
COpy Command ...................... . 6-65
DATE Command ...................... . 6-80
DEL Command ........................ . 6-82
DIR (Directory) Command ............. . 6-83
DISKCOMP (Compare Diskette)
Command ............................ . 6-90
DISKCOPY (Copy Diskette)
Command ............................ . 6-94
ERASE Command ..................... . 6-98
FORMAT Command ................... . 6-100
GRAPHICS (Screen Print) Command ... . 6-106
MKDIR (Make Directory) Command .... . 6-107
MODE Command ...................... . 6-109

xiii

PATH (Set Search Directory)
Command ............................ . 6-117
PRINT Command ..................... . 6-120
RECOVER Command .................. . 6-126
RENAME (or REN) Command .......... . 6-129
RESTORE (Fixed Disk) Command ..... . 6-131
RMDIR (Remove Directory)
Command ............................ . 6-134
SYS (System) Command ................ . 6-135
TIME Command ...................... . 6-136
TREE (Display Directory) Command ... . 6-138
TYPE Command ....................... . 6-141
VER (Version) Command .............. . 6-143
VERIFY Command .................... . 6-144
VOL (Volume) Command .............. . 6-145
Summary of DOS Commands .......... . 6-146
Chapter 7. The Line Editor (EDLIN) ... .
Introduction ........................... .
How to Start the EDLIN Program ...... .
Editing an Existing File ............. .
Editing a New File ................. .
The EDLIN Command Parameters ..... .
The EDLIN Commands ................ .
Information Common to All EDLIN
Commands ....................... .
Append Lines Command ............... .
Copy Lines Command .................. .
Delete Lines Command ................ .
Edit Line Command ................... .
End Edit Command .................... .
Insert Lines Command ................. .
List Lines Command ................... .
Move Lines Command ................. .
Page Command ........................ .
Quit Edit Command ................... .
Replace Text Command ................ .
Search Text Command ................. .
Transfer Lines Command .............. .
Write Lines Command ................. .
Summary of EDLIN Commands ........ .

xiv

7-1
7-3
7-4
7-4
7-5
7-7
7-9
7-9
7-12
7-13
7-14
7-18
7-21
7-23
7-27
7-32
7-33
7-34
7-35
7-39
7-44
7-45
7-46

Chapter 8. Messages ....................
Introduction ............................
Device Error Messages ...................
Other Messages ..........................

8-1
8-3
8- 3

8-7

Section 2. Advanced DOS Features andTechnical Reference
Chapter 9. Configuring Your System
Introduction ........................... .
Configuratio1'\ Commands ............. .
BREAK Command ................. .
BUFFERS Command ............... .
DEVICE Command ................ .
FILES Command ................... .
SHELL Command .................. .

9-1
9-3
9-3
9-4
9-4
9-7
9-9
9-10

Chapter 10. Advanced DOS
Commands ........................... . 10-1
Introduction ........................... . 10-3
Redirection of Standard Input andOu tpu t Devices ....................... . 10-4
Piping of Standard Input and Output ... . 10-6
DOS Filters ............................ . 10-7
Detailed Descriptions of Advanced
DOS Commands ...................... . 10-9
CTTY (Change Console) Command .... . 10-11
EXE2BIN Command ................... . 10-13
FIND Filter Command ................. . 10-16
MORE Filter Command ................ . 10-18
PROMPT (Set System Prompt)
Command ............................ . 10-19
SET (Set Environment) Command ...... . 10-22
SORT Filter Command ................ . 10-26
Summary of Advanced DOS
Commands ........................... . 10-28

xv

Chapter 11. The Linker (LINK)
Program .............................. . 11-1
Introduction ........ '................... . 11-3
Files ................................... . 11-4
Input Files ......................... . 11-4
Output Files ....................... . 11-5
VM. TMP (Temporary File) .......... . 11-5
Definitions ............................ . 11-6
11-6
Segm~nt ........................... .
Group ............................. . 11-7
Class .............................. . 11-7
Command Prompts .................... . 11-8
Detailed Descriptions of the
Command Prompts ................... . 11-10
Object Modules [.OB]]: ............. . 11-10
Run File [filename. EXE] : ........... . 11-12
List File [NUL.MAP]: ............... . 11-12
Libraries [.LIB]: .................... . 11-13
Linker Parameters ................. . 11-15
How to Start the Linker Program ....... . 11-19
Before You Begin .................. . 11-19
Option 1 - Console Responses ...... . 11-19
Option 2 - Command Line .......... . 11-20
Option 3 - Automatic Responses .... . 11-22
Example Linker Session ................ . 11-25
How to Determine the Absolute
Address of a Segment .............. . 11-28
Messages .............................. . 11-30
Chapter 12. The DEBUG Program ...... . 12-1
In troduction ........................... . 12-3
How to Start the DEBUG Program ..... . 12-4
The DEBUG Command Parameters .... . 12-7
The DEBUG Commands ............... . 12-14
Information Common to All
DEBUG Commands ................ 12-14

xvi

Assemble Command ................... .
Compare Command ................... .
Dump Command ...................... .
Enter Command ....................... .
Fill Command ......................... .
Go Command ......................... .
Hexarithmetic Command .............. .
Input Command ....................... .
Load Command ........................ .
Move Command ....................... .
Name Command ....................... .
Output Command ..................... .
Quit Command ........................ .
Register Command .................... .
Search Command ...................... .
Trace Command ....................... .
Un assemble Command ................ .
Write Command ....................... .
Summary of DEBUG Commands ....... .

12-16
12-21
12-22
12-25
12-29
12-30
12-34
12-35
12-36
12-40
12-42
12-44
12-45
12-46
12-53
12-55
12-57
12-62
12-67

Chapter 13. Using Extended Screen
and Keyboard Control ................ .
Introduction ........................... .
Cursor Control ........................ .
Cursor Position .................... .
Cursor Up ......................... .
Cursor Down ...................... .
Cursor Forward .................... .
Cursor Backward ................... .
Horizontal and Vertical Position .... .
Device Status Report ............... .
Cursor Position Report ............. .
Save Cursor Position ............... .
Restore Cursor Position ............ .
Erasing ................................ .
Erase in Display .................... .
Erase in Line ....................... .

13-1
13-3
13-4
13-4
13-4
13-5
13-5
13-5
13-6
13-6
13-6
13-7
13-7
13-8
13-8
13-8

xvii

Mode of Operation ..................... . 13-9
Set Graphics Rendition ............. . 13-9
Set Mode .......................... . 13-10
Reset Mode ........................ . 13-10
Keyboard Key Reassignment ........... . 13-11
Chapter 14. Installable Device
Drivers ............................... .
Introduction ........................... .
Device Driver Format .................. .
Types of Devices ................... .
Device Header ..................... .
Creating a Device Driver ............... .
Installation of Device Drivers .......... .
Request Header ........................ .
Unit Code ......................... .
Command Code .................... .
Status Word ....................... .
Function Call Parameters ........... .
MEDIA Descriptor Byte ............ .
The CLOCK$ Device ................... .
Sample Device Driver .................. .

14-1
14-3
14-3
14-3
14-5
14-8
14-9
14-11
14-11
14-12
14-13
14-16
14-21
14-26
14-27

Appendix A. DOS Version 2.00
Enhancements.......................... A-I
For All Users ........................ A-I
For Programmers .................... A-I0
Appendix B. DOS Technical
Information ............................
DOS Structure .......................
DOS Initialization ...................
The Command Processor .............
Available DOS Functions .............
File Management Notes ..............
The Disk Transfer Area (DTA) ........
Error Trapping ......................

xviii

B-1
B-1
B-2
B- 3
B-5
B-5
B-6
B-7

Appendix C. DOS Disk Allocation .......
DOS Disk Directory .................
DOS File Allocation Table.. .. . . .. . . ..
How to Use the File Allocation
Table ..............................

C-l
C- 3
C-6
C-9

Appendix D. DOS Interrupts andFunction Calls ......................... D-lInterrupts ........................... D-l
Function Calls ....................... D-12
Invoking DOS Functions ............. D-16
Appendix E. DOS Control Blocks
and Work Areas ......................... E-l
DOS Memory Map ................... E-l
DOS Program Segment............... E-3
Program Segment Prefix ............... E-8
File Control Block ................... E-10
Appendix F. Executing Commands
from Within an Application .............

F-l

Appendix G. Fixed Disk Information....
Fixed Disk Architecture ..............
System Initialization .................
Boot Record/Partition Table .........
Technical Information ...............

G-l
G-l
G-2
G-4
G-6

Appendix H. EXE File Structureand Loading ...........................

H-l

Appendix I. Running Compilers andAssemblers with Fixed Disk .............
Running Compilers and Macro
Assembler With a Fixed Disk .........
Exceptions ...........................

I-I
I-I
1-3

xix

Appendix]. Running the Pascal
Compiler with Fixed Disk .............. .
Pascal Hex Patch .................... .

J-1
J-1

Appendix K. Considerations for
Using Applications .................... . K-1
Accounting Package by BPI
Systems, Inc. ...................... . K-3
Accounting Packages Version 1.00 by
Peachtree Software, Inc. . .......... . K-3
Accounting Packages Version 1.10 by
Peachtree Software, Inc. . .......... . K-3
Arithmetic Games 1 and 2 ........... . K-4
Asynchronous Communications Support
Version 1.00 ...................... . K-5
Asynchronous Communications Support
Version 2.00 ...................... . K-7
EasyW riter Version 1.10 ............ . K-10
Fact Track ......................... . K-12
PFS:File ........................... . K-14
PFS: Report ........................ . K-18
The Dow Jones Reporter
Version 1.00 ...................... . K-22
SNA 3270 Emulation and RJE Support
Version 1.00 ...................... . K-23
Typing Tutor ....................... . K-25
VisiCalc Version 1.10 by VisiCorp. . .. . K-26
3101 Emulator Version 1.00 ......... . K-28

xxFigures

1. DOS Batch Processing Commands .... . 6-146
2. DOS Commands ..................... . 6-147

3. EDLIN Commands .................. . 7-46
4. DOS Advanced Commands ........... . 10-28
11-4
5. Input files used by the Linker ........ .
6. Output files used by the Linker ...... .
11-5
7. Alphabetic Flag Settings .............. . 12-50
8. DEBUG Commands ................. . 12-67

xxi

Notes:xxii

Section 1. DOS Guide

Contents
Chapter 1. Introduction. Chapter 2. Getting DOS Started .
Chapter 3. UsingDOS
Chapter 4. Preparing Y our Fixed Disk
Chapter 5. Using Tree-Structured Directories. Chapter 6. pas Co~mands
Chapter 7. The LirieEclitot (EDLIN)
ChapterS. Messages

Notes:l-ii

Chapter 1. Introduction

Contents
What Is DOS?

1-3

Why You Should Use DOS ...............

1-4

DOS Version 2.00 Enhancements

1-5

Backing Up Your DOS Diskettes

1-6Abou t Diskettes ......................... 1-7
Formatting Your Diskettes ........... 1-7
Single- and Dual- Sided Diskettes ...... 1-8
Protective Jacket ..................... 1-9
How It Works ....................... 1-9
Tracks, Bytes, and Sectors ............ 1-10
Careful Does It ....... . . . . . . . . . . . . . . .. 1-12
Write-Protect Notch ................. 1-12
Abou t Diskette and Drive
Compatibility .......................... 1-14
Single Diskette-Drive Systems ............ 1-14
Automatic Program Execution ............ 1-16

1-1

Notes:1-2

What Is DOS

The IBM Personal Computer Disk Operating
System (DOS) is a group of programs that you can
use to do work with your computer. DOS is a disk
operating system, meaning that the DOS programs
are to be used with diskettes or with fixed disks.
The programs that DOS contains are importantbecause they provide a way to organize and use theinformation you place on disks.
The DOS programs control the way yourcomputer uses other programs, such as
application programs. DOS tells your computer
how to use or read information that you supply tothe programs. DOS also tells your computer how
to return or write information that the programs
supply to you.

1-3

Why you should use DOS

DOS gives you an easy way to use applications andcreate and manage files for your applications. DOS
also lets you use devices such as printers and disk
drives with your computer.
You should use DOS if you are doing any of thefollowing:•

Using applications that need DOS•

Using new disks with applications that use
DOS•

Copying disks that have been used with DOS
or with DOS applications•

Performing other tasks on disks that havebeen used with DOS or with DOS
applications

Your applications will tell you if you need to use
DOS with them. If you are using DOS, this bookwill help you learn more about the tasks that you
can perform with DOS to organize and maintainthe information you place on your disks.

1-4

DOS Version 2.00 Enhancements

DOS Version 2.00 contains significant functional
enhancements and some minor operational andtechnical differences from previous versions ofDOS. We strongly recommend that you take thetime to review the information in Appendix A(Section 2), whether you are an experienced DOS
user or are about to use DOS for the first time.
Because of the significant amount of function
added, DOS Version 2.00 is considerably larger
than previous versions. We recommend aminimum memory size of 64K bytes for DOS
Version 2.00 (128K bytes if you are using afixed disk).

1-5

Backing Up Your DOS Diskettes

Making a copy of your DOS diskette and yourDOS Supplemental Program diskette should be
one of the first things you do with your IBM
Personal Computer after you get DOS. That way
you won't be "shut down" if your DOS diskette
becomes misplaced or accidentally damaged. This
copy is called a backup and making the copy isusually called backing up. Refer to "Backing Up
a Diskette" in Chapter 3 and follow the procedure
to backup your DOS diskette and DOS
Supplemental Program diskette. Label and datethe backup diskette. Use a felt-tip pen. Store theoriginal DOS diskette properly and use the backup
diskette in your daily operations.

1-6

About Diskettes

Formatting Your Diskettes
You must format every diskette before it can beused by DOS. You do not need to use FORMAT
every time you want to put information on adiskette. (Only the first time you use a diskette.)
The DOS FORMAT command writes on every
sector of your diskette, sets up the directory andFile Allocation Table, and puts the boot record
program at the beginning of your diskette.
FORMAT also creates a copy of DOS on a new
diskette if you specify it in your command. Thisway, you can create a diskette containing DOS andhave plenty of space for your own data on thesame diskette. Keep in mind that only DOS systemfiles are copied when you run FORMAT - none ofthe other files you may have on your DOS diskette
are copied.
For more information about formatting diskettes,
refer to "Getting a Diskette Ready to be Used" in
Chapter 3. For more information about FORMAT,
refer to Chapter 6.

1-7

Single- and Dual-Sided Diskettes
Your IBM Personal Computer uses 5% inch
(133 mm) diskettes for storing information. (Youmay also have heard the terms "floppy disk,""mini-floppy," or "disk" - we will use "diskette.")If you have single-sided drives, a diskette can hold
either 163,840 or 184,320 characters of
information. If you have dual-sided drives, you canformat your diskette to hold either 327,680 or
368,,640 characters of information.
The reason for showing two sets of numbers foreach type of diskette is that diskettes formatted by
DOS Version 1.00 or 1.10 contain only the lower
number of characters. DOS Version 2.00, though,allows more data to be put on a single diskette byusing more of the diskette's recording surface.
You can use diskettes formatted by DOS Version
1.00 and 1.10 with DOS Version 2.00, but you can
not use diskettes formatted by DOS Version 2.00
with earlier versions of DOS, unless you use the
FORMAT 18 or IB parameter when you format
them.

1-8

Protective Jacket
The permanent protective jacket contains aflexible diskette that is coated with a magnetic
substance. When in use, the diskette spins inside
the jacket. The read/write head comes into contact
with the recording surface through the long holein the protective jacket, called the head slot.
Temporary label
Permanentlabel
Diskette In
permanent
protective
jacketWrlta-protect notch(Some diskettes do
not have this notch.)
Exposed recording
surface(DO NOT TOUCH)
Head slot
Diskette
envelope

How It Works
Information is written on or read from themagnetic surface of the diskette, similar to the way
an ordinary tape recorder operates.
The information on a diskette can be read by thecomputer as often as it needs, or the computer canwrite new information on the diskette in an
unused space.

1-9

The computer can also replace old information withnew information by writing over it. In this case,the old information is erased and can no longer beread. Similarly, if you record a Chicago Symphonyprogram on an Elvis Presley tape, you can nolonger listen to Elvis.

Tracks, Bytes, and Sectors
Information is written on the diskette alongconcentric circles called tracks. The read/write headof the diskette drive moves back and forth from
one track to another as the diskette spins over it.
This lets the head find certain data to read or find aplace to write some new information.
There are 40 tracks on a diskette, numbered fromo to 39. DOS reserves portions of track 0 of eachdiskette. The rest of the diskette is available foryour information and for a copy of DOS, if you
want.

"...------ .......

" .,---- ......... ,
"',,"
/,.
,--- . . ..... .,.".', \
I I,'
I

I

,.

- - ....

"\\::' ('/(9)'0"\ -.. \ ':" ~\ \:zm''; Track 39
I

One sector ~ \. \, ~ , , ,of track 19" \ \,.... ~ ,
I
\ \"
,,

I

I I

, " , ..... -~'"" ....." ' ...--Y- .. ..-. ....-'" '" '"
,/

-

1-10

/

,

•

.

Track 19/

Track 0You'll also hear the words byte (pronounced like"bite") and sector used in talking about diskettes.
Space on a diskette (and the computer's memory,too) is measured in bytes. One byte can hold one
character; thus, for diskettes formatted by DOS
2.00 the 5 X inch diskettes can hold up to 184,320
characters for a single-sided diskette and up to368,640 characters for a dual-sided diskette.
Each track is divided into eight or nine sectors thatare 512 bytes long. One or more sector's worth of
information can be sent back and forth between
the computer and a diskette at one time.
Information on a diskette can be quickly locatedby its side, track, and sector numbers - just as thepost office can locate your home by using the town(side number 0 or 1), street name (track number),and the address (sector number).
As long as you use DOS provided functions, youwill never have to know (or use) this side, track, or
sector, information- DOS will take care of it for
you.

1-11

Careful Does It
Be careful with your diskettes. We'd like toemphasize these things here:•

Do not touch the exposed recording surfaces.

•

Protect the diskettes from dust by putting
them back in their envelopes as soon as you
remove them from the diskette drive.

•

Store often-used diskettes in their envelopes.
Don't lay heavy objects on top of them. If you
stand them on edge, make sure they aren't
bending or sagging.

•

Store seldom-used diskettes in storage boxes,
away from heat and magnetic field sources
such as telephones, dictation equipment, andelectronic calculators.

•

Because each piece of information occupies
such a tiny spot on the diskette, small
scratches, dust, food or tobacco particles may
make the information unusable.

Take care of your diskettes because running yourcomputer without programs and data is likerunning your car without gasoline.

Write-Protect Notch
Besides making sure your diskettes aren't
scratched or dirtied, you can make sure thecomputer cannot write over information alreadyon a diskette.

1-12

If your diskette has no write-protect notch, it isalready write protected. This means that thecomputer cannot store (write) any information
on it. Your DOS diskette does not have awrite-protect notch.
If your diskette has a write-protect notch, you cancover this notch with a tab supplied with thediskette, or use a piece of tape. Then the computer
cannot write on the diskette. In this case,information can only be read from the diskette;
information already on the diskette cannot
accidentally be erased by being overwritten withnew information.
Important diskettes (for example, purchased
program diskettes) are often protected this way.

Tab

Just for reading

1-13

About Diskette and Drive
Compatibility

DOS supports both single- and dual-sided diskette
drives in any combination. Your drives do notneed to be of the same type.
Diskettes formatted for single-sided use (seeFORMAT Command in Chapter 6) can be used ineither single- or dual-sided drives. However,diskettes formatted for dual-sided use are usable
only in dual-sided drives, because data is recorded
on both surfaces, and the method of allocating
space is different. Therefore, you should neverattempt to use a dual-sided diskette in asingle-sided drive. Also, diskettes formatted by
DOS Version 2.00 can not be properly used byprior DOS versions, if they are formatted at 9
sectors per track.

Single Diskette-Drive Systems

On a single diskette-drive system, you enter thecommands the same way you would on a multiple
diskette-drive system.

1-14

You should think of the single diskette-drive
system as having two diskette drives (drive A anddrive B). But, instead of A and B representing two
physical drives as on a multiple diskette-drive
system, the A and B represent diskettes.
If you specify drive B when the drive A diskette
was last used, you are prompted to insert thediskette for drive B. For example:
A>COPY COMMAND.COM B:
Insert diskette for drive B:
and strike any key when ready
1 File( 5) copiedA>_
If you specify drive A when the drive B diskette
was last used, you are again prompted to change
diskettes. This time, the system prompts you to
insert the drive A diskette.
The same procedure is used if a command is
executed from a batch file. The system waits foryou to insert the appropriate diskette and press
any key before it continues. Remember that theletter displayed in the system prompt represents
the default drive where DOS looks to find a filewhose name is entered without a drive specifier.
The letter in the system prompt does not
represent the last diskette used.
For example, assume that A is the default drive. If
the last operation performed was DIR B:, DOS
believes the drive B diskette is still in the drive;
however, the system prompt is still A>, because
drive A is the default drive, and you did not specify
another drive in the DIR command.

1-15

Automatic Program Execution

You may want to start a specific program every
time you start DOS. You can do this with the DOS
command processor by using automatic program
execution.
Every time you start up DOS, the commandprocessor searches for a file named
AUTOEXEC.BAT in the root directory on the diskthat DOS was started from. This filename is special
because it refers to a batch file that is automatically
executed whenever you start the system. With thisfacility, you can execute programs or commands
immediately every time you start DOS.
If the system finds the AUTOEXEC.BAT file, thefile is immediately executed by the commandprocessor. The date and time prompts are
bypassed.
If DOS does not find the AUTO EXEC. BAT file,
DOS issues the date and time prompts. Refer to"Batch Processing" in Chapter 6 for details on how
to create an AUTOEXEC.BAT file.

1-16

Chapter'2. GettingDO~S Started

Contents
Loading (Starting) DOS .................. 2,.. 3
If Your Computer Is Off .............. 2-4
If Your Computer Is On ~.:............ 2-5
Telling DOStheDat~ ................ 2-6
Telling DOS the Time ............. .... 2-8
The DOS Prompt ................. '. . .. 2-11
Specifying the Default Drive .......... 2;.12
Files and Filenar:ries .......... ~ .......... .
Bad'0lcay, and.C;oodNames
farEiles,. ~: .,'~ ... · ..•• :. .. . ••. .
2:~~~ljI~;!~iit~~l~
FileSp~~~f~~~~~~n$~.. ,~ ..... "~... ~ ........ ' 2
Using GlcibalF:ile'llame Chara~ters ....... .
The? Character ...................... 2-18
The * Character ... ~ ..: . '.' ...."..... . .... 2~ 19
Some Keys'Yo'ulJse withI)OS.;;.~ .~ ... ;,.. 2;,021
Charactets~ That: Laok Alike' ~Oh's
a,ndZef<)"s,: Ories and EIs '...............'~rheSt>acebar ...•.•.•...•.. ,....••........
The ,Shift: and C~psLock Keys' ..,...... '.
To Enter a Command' ••.............. :To ,Stopa COPlmand .•..:.••.~ •• ~~,: '.....•... ,.•To Correcta'typlngMistalce ....... ~ .... 2':'26
To Stop the Screen Long Enoughto Read It. ,.,~. ... "..... .. ~... . . . . .. .
To PrintWhatls, on the Screen ........ .
To PrintWhateveiYOll Type .......••
T()StartDOSAgain

Control Keys ............................ 2-29
DOS Editing Keys ....................... 2-35
Examples of Ways to Use DOS
Editing Keys ........................ 2-40
To Start EDLIN ...................... 2-41
To Stop the Editing Session .............. 2-52

2-2

Loading (Starting) DOS

You will usually want to start DOS whenever you
start your computer. For example, you must have
DOS loaded before you can start the Disk BASIC
or Advanced BASIC programs.
When you start or restart your computer, it will
first check to see if it can load an operating systemfrom diskette drive A. If a diskette is present, it
will be read. If it is not present or the diskette
drive door on drive A is open, one of the following
two things will happen:1.

If your system does not have a fixed disk, thesystem will enter Cassette BASIC.

2.

If your system does have a fixed disk, then an
attempt will be made to load an operating
system from it. If the fixed disk has not been
initialized with an active partition (seeChapter 4), then Cassette BASIC will beentered.

The examples shown in this chapter describe using
DOS in a diskette-only environment, and areintended to serve as an introduction to DOS. If
you have afixed disk, please refer to "Preparing
Your Fixed Disk" in Chapter 4 after reviewing thischapter.

Starting DOS or loading DOS means that a copy of
the DOS programs is read from the DOS disketteand placed in the computer's memory. Once thecomputer finishes its self-checks, you will hear thediskette drive whirring and clicking while the DOS
programs are being read and transferred tomemory.
2-3

DOS tells you it is ready when it asks you for thecurrent date and time. After that, DOS is ready for
you to type a command - that is, to tell DOS what
you want it to do.
Let's look at starting DOS, step-by-step.
There are two ways to start DOS, depending onwhether your computer is off or on.

If Your Computer Is Off
1.

Insert the DOS diskette into drive A and closethe diskette drive door.

DOS diskette

2-4

2.

Turn on the printer, if you have one, thevideo monitor or TV, and then the computer.

3.

Wait a moment while the system checks itself
out. The length of the pause depends on theamount of memory in your computer. The
more memory, the longer the pause. Then
you will hear the diskette drive clicking andsee the drive light come on while DOS isbeing read into the computer's memory.

If Your Computer Is On
1.

Insert the DOS diskette in drive A and closethe drive door.

'---- DOS diskette
2.

Press and hold Ctrl and Alt, and then press
Del. Then release them all:

OBJ] + [I,OJ])
3.

and then[IGJJ J

You will see the diskette drive light on while
DOS is being read, and you may hear someclicks and whirs.
Note that you will see these three keys usedagain in the section "To Start DOS Again"
later in this chapter. This is the same-that is,
use Ctrl + Alt + Del to start DOS or to restart
DOS if your computer was already on and you
were running something else. This is called

System Reset.

2-5Telling DOS the Date
When DOS is loaded and ready, you will see
something similar to this on the screen:

Current date is Tue 1-01-1980
Enter new date:_

The cursor shows where thefirst number you type willappear.
It's an excellent idea to fill in the current datewhenever you start (or restart) DOS because then
any files that you create or change will have thecorrect date stored in the file directory-helpful
information months later, if you can't remember
exactly which file has the most current
information. (Y ou'lllearn about files anddirectories in a little bit.)
To set the date, use the number keys across the
top of the keyboard:

2-6

1.

Type one or two numbers between 1 and 12
for the month.

2.

Type a dash

3.

Type one or two numbers between 1 and 31
for the day.

4.

Type another dash or slash.

g or a slash B .

5.

Type the last two numbers of the year
between 80 and 99 or a four-digit number
between 1980 and 2099.

6.

Press the Enter key~3

For example, suppose the current date is June 8,
1982.

Type this:or this:or this:or this:or this:or this:or this:6-8-82
6/8/82
6·08-82
6/08/8206·08-82
06/08/82
06/8/82

DOS checks the date that is typed. If the date thatis typed does not check out, DOS displays thismessage:

Invalid dateEnter new date: _2-7

These are some dates that would not check out:

Date

Reason060882No dashes or slashes

APR-02-80

Letters instead of numbers

13-08-83

Month too big

9-32-82

Day too big

10 15 82

Spaces, not slashes or dashes

If DOS tells you that the date is invalid, try again.
Or if you do not wish to enter a new date, thenpress the Enter key when this is displayed:

Current date is 1-01-1980
Enter new date:_

Telling DOS the Time
After you have entered the date, DOS displays
something similar to this:Current time is 0:01 :43.53
Enter new time:_

2-8

The time displayed is:
HOURS:MINUTES:SECONDS.HUNDREDTHS OF SECONDS

To set the time, use the number keys across the
top of the keyboard:
1.

Type one or two numbers between 0 and 23
for the hours.

2.

Type a colon

B

Note: A dash
not work.

g or a slash g will

3.

Type one or two numbers between 0 and 59
for the minutes. If you wish to enter theseconds and hundredths of a second, you canproceed with step 4, but if the hours andminutes are sufficient, proceed to step 8. DOS
will set the remaining values to zero for you.

4.

Type another colon.

5.

Type one or two numbers between 0 and 59
for the seconds.

6.

Type a period

g to separate seconds andhundredths of a second.
Note:

Only a period will work.

2-9

7.

Type two numbers between 00 and 99 for thehundredths of a second.

8.

Press the Enter keym

For example, suppose the time is 8: 30 a.m.
exactly.
Type this:or this:or this:or this:8:30:0.00
08:30:0.00
8:30:0
8:30

DOS checks the time that you type. If the timethat you type does not check out, DOS displays
this message:

Invalid time
Enter new time: _This is a time that would not check out:

2-10

Time

Reason8/30/0/0

Only colons between hours,
minutes, and seconds; and a period
between seconds and hundredths ofa second will work.

If DOS tells you the time is invalid, try again.
However, if you do not wish to enter a new time,then press the Enter key when this is displayed:

Current time is 0:00: 13.89
Enter new time: _After you have entered the time, DOS displays
this:

The IBM Personal Computer DOS
Version 2.00 (C) Copyright IBM Corp 1981,1982, 1983

A>_

The DOS Prompt
The A> is the DOS prompt. A prompt tells you that
it is your turn to type information; that is, to tell
DOS what to do by entering a command.
This prompt tells you some other things besides
saying that DOS is waiting for you to enter acommand.

It tells you that DOS has completed the previous
command, and that it is DOS that is waiting. Other
programs have different prompts; for example,
BASIC's prompt is: Ok
Ok lets you know that you should respond with aBASIC command.

2-11

Specifying the Default Drive
The A in the prompt designates the default drive.
DOS searches the diskette located in the default
drive to find any filenames that you enter unless
you specify another drive.
You can change the default drive in the prompt byentering the new designation letter followed by acolon. For example:
.
A>
A>B:
B>

(original prompt)(new drive designation)(new prompt)

Now, B is the default drive. DOS searches thediskette located in drive B to find any filenamesthat you enter, unless you specify a drive.
Remember, if you do not specify a drive when you
enter a filename, the system automatically searches
the diskette located in the default drive. Anothername for the default drive is the current drive.

Files and Filenames

Related information on a disk is grouped into/iles,
just as information in a book about particular
topics may be grouped into chapters.
Each file has a name-when you want DOS to find afile, you give DOS its name (not the name that's
on the diskette's label).
2-12

Some examples of files:
A file containing a
program to calculate
bowling team averages.

:- A,=(Gi~-G2-11
I!- _______+63)/3I

A file containing the textof a form Jetter yourcompany sends out.

1- iear Valued - I

Customer,

1

I

I

I
I

I

1
,_ ~i~e~IY~,------I
I

Gail

Walt
John

l_ ~'~I_

A file containing names
and birthdays of yourfriends.

4-2
I
2-23 I
9-18

I

6-29 J

1-------1
I

June 1
1 Happy BirthdayI
Heldlll!

..... _-----

1

I
1

A file containing a
program to print abirthday message to all
your friends born thismonth.

2-13

Files are used so that DOS can find specificinformation easily, and so that information that
isn't needed isn't taking up room in the computer.
(For example, you don't need your bowling teamaverages at the same time as you need the form
letter.)You usually have a number of files on a diskette.
You can have up to 64 files in the system directoryof a single-sided diskette and 112 files on adual-sided diskette. The number of files on a fixed
disk is determined by the amount of space
allocated to DOS. Sometimes the files on one disk
are related to each other (like the programs anddata files to keep track of a company's inventory),and sometimes the files have been put on whateverdiskette was handy.
It doesn't matter what combination of files is on a
disk. What matters is that each file has a unique
name.
That means that every name on a disk has to bedifferent-but you can have the same name on two
different disks.
For our examples a little earlier, the names ofthese files might be:
BOWL
LETTER

BIRTHDAYBIRTH DAY. BAS

A file's name is made up of afilename and an
extension.

2-14

In DOS,jilenames are from one to eight characterslong. The characters in a filename can be:•

the letters of the alphabet•

the numbers•

and these special characters $#&°through 9@!

% ( ) - {} ' - 'Note: Prior versions of DOS allowed thecharacters: , <, >, and to be used within afilename. However, these characters havespecial meaning to DOS Version 2.00, and canno longer be used in filenames.
A filename can be followed by an optional shortname called an extension. An extension starts with aperiod, has one, two, or three characters, andfollows immediately after the filename.
Here are some filenames with extensions:81 PRICES.JUL
81 PRICES.AUG
AVRG.$&%
WEATHER.80

Important: If a filename is followed by anextension, you must use both parts when telling
DOS about that file.

2-15

Bad, Okay, and Good Names for Files
With all the possibilities, filenames can be
unusual, to say the least.
DOS likes names that follow the rules. These files
have names that DOS will not accept:
Name

Why DOS Won't Accept It

AANDBSpaces in it

A,B, & C

Commas and spaces in it.PGM

Filename missing

ANDTHISONEISTOO.LONG
These names are okay for DOS:oo·xxx#1#2#A3B@@.---

Z
but can you guess what is in any of these files?
A good name for a file will help you remember whatkind of information is in the file, and perhaps
whether it's a file that contains a program or only
data. For example, ADDRLIST.BAS is a goodname for a BASIC program file that prints anaddress list.

File Specifications
The other thing that DOS needs to know to findinformation is "Where" -that is, which drive tosearch for a particular file.

2-16

The drive specifier is a letter and a colon, like A:, andft tells where the file is. You always need to typethe colon after th~ drive specifier letter.
The filename and extension immediately follow thedrive specifier, like this:
A:81 PRICES.JUL

Don't put any spaces between the three parts.
These three parts together-the drive specifier, thefilename, and the extension-are called aftle
specification.
Sometimes you don't have to type the drive
specifier; whenever the drive specifier is the sameas the default drive, you don't have to type it.
For example, assume A is the default drive(remember you can tell by looking at the
prompt-A> in this case). Then you could type:- - - - - - Look-no drive
specifier!

A:address OR ~ddress

They are exactly the same to DOS when A is thedefault drive.
Here are some more file specifications:
A:81 PRICES.AUG
A:KIKI.J
B:BOWL.BAS
B:MINEYOURS .....-With this kind of file specification,
DOS assumes that the file (YOURS)

can be found on the default drive.

2-17

Using Global Filename Characters

Sometimes you will want to do the same thing withseveral files-for example, copying a group of files
at one time, or listing the names of a group of files
that are somehow related.
Two special global filename characters let you indicate
a number of files with one specification. These
characters are the question mark (?) and theasterisk (*). They are used in a filename and! or an
extension to mean" any character."
These characters can save you a lot of typing if
your files are named appropriately. Let's look atsome examples to tell you about global filename
characters.
In the examples that follow, you need to knowthat the DOS command DIR displays information
about files that match the file specification you
type.

The? Character
The? in a filename or extension means that any
character can be in that position. So, all files thathave a name that matches in all except the?
positions are selected. For example, suppose thediskette in drive A has these files on it:
79PRICES.AVG
80PRICES.AVG
81 PRICES.JAN
81 PRICES.JUL
81 PRICES. AUG
791NVTRY

2-18

If you type:dlr ??prices. ???

all the files except the last one (79INVTRy) arelisted on the screen. These are the files that matchand are listed:
79PRICES.AVG
80PRICES.AVG
81 PRICES.JAN
81 PRICES.JUL
81 PRICES. AUG

For another example, suppose you give DOS thiscommand:dir ??prices.a?g

Then these files match and are listed:
79PRICES.AVG
80PRICES.AVG
81 PRICES.AUG

The * Character
The * in a filename means that any character canbe in that position and in the rest of the filename.
Likewise, a * in an extension means that any
character can be in that position and in the rest of
the extension. Using an asterisk is like typing
several ?' s, two or more * are never used together.
One is enough!
Assume that the same diskette we saw with "the?
character" is in drive A. If you give DOS thiscommand:dir 81*.j*

2-19

Then these files are selected and displayed:
81 PRICES.JAN
81 PRICES.JUL

For another example, perhaps we try this:dir 8*.*

These files would be listed:
80PRICES.AVG
81 PRICES.JAN
81 PRICES.JUL
81 PRICES. AUG

And if you type:dir *.*

all the files would be listed.
You can use both global filename characters
together. For example, if you type:
dir ??p*.a*you would see these files listed:
79PRICES.AVG
80PRICES.AVG
81 PRICES.AUG

Global characters are fun, but you need to becareful both in naming your files and in using
them-you may get results you didn't expect!

2-20

So far we have discussed:•

how to get DOS started•

the DOS prompt and default drive•

formatting your diskettes•

files and filenames•

glo bal filename characters

Let's take a closer look at the keyboard keys
before we go any further.

Some Keys You Use with DOS

In addition to the keys you'd find on a typewriter,
your keyboard has some special keys you'll use
with DOS.
Before we get to the special keys, here are a few
differences between your keyboard and a
typewriter that you need to know.

2-21Characters That Look Alike Oh's and Zeros, Ones and Els
Computers are fussy about
the number zero and the letterO-they want what they want
and you can't fool them into
taking the wrong one. Make
sure you type the right key incommands and filenames.
On our printer, the letter 0
looks a little squarer than thenumber o.
On our screen, the number zerohas a diagonal line through it,
something like this: g.
If you are used to typing alowercase L for the number 1 (ifyou have used a portabletypewriter a lot, for example),you'll have to break that habit.
Again, the computer knows thedifference. Use the number key
when the number 1 is required,as in a filename such as
DATA123. (Now if you were touse lowercase L when creating afilename, that's okay. Just be
sure to use it again when you
want to use that file!)

2-22

The Spacebar

[[

)J

t

This is the Spacebar. Use it to
put a blank (a space) in a line
you are typing. Sometimes
people want to use it formoving the cursor. It will movethe cursor, but it will also replace
any characters with blanks as it
moves across the screen.
To the computer, blanks areimportant; a blank is as much acharacter as A or B. Many times
blanks are used to separate what
you type for the computer justas we use them to separate
words in everyday writing. You
have to make sure when you're
typing that the computer allows
a blank. Otherwise, it may notunderstand what you havetyped.

2-23

The Shift and Caps Lock Keys
There are two Shift keys on the
keyboard, located about where
you find them on a typewriter
keyboard.
Use them to type uppercase(capital) letters or to type thesymbol shown in the upper
position on the key tops for all
keys except the numeric key
pad on the right. That's just as
you would expect.

[lf~]JJThe Caps Lock key lets you type
capital letters (only) until youpress it again. Only the letter
keys are affected.
You still have to press one of
the Shift keys to type thesymbols in the upper position of
the number keys at the top of
the keyboard. For example, youmust press and hold the Shift
key to type a #.

[fJI] + ~ =#Unlike a regular typewriter,pressing one of the Shift
keys [QED does not get you outof Caps Lock mode. You mustpress the Caps Lock key again
to type lowercase letters.

2-24

Remember that DOS will accept lowercase lettersin all commands and filenames; so you'll be using
these Shift keys mostly for special symbols.

To Enter a Command
Use the Enter key when you
have finished typing a wholecommand.

To Stop a Command

[Ell]
+

Scrolllock
BreakPress and hold the Ctrl
(Control) key, and then press
the Break key. Then release
both keys to stop a commandfrom finishing its job normally.
(This is sometimes called
terminating a program).

DOS shows you a prompt; then
you can type your next
command.

2-25

To Correct a Typing Mistake
Here are several ways to correcta mistake that you notice before
you press the Enter key.

[I.EJ]JJ

One of the easiest is to movethe cursor backward, under theleftmost wrong character. The
Backspace key deletescharacters as it moves the
cursor to the left. (The
Backspace key is located on the
top row next to the N urn Lockkey.)
Now type the correctcharacters, and press the Enter
key when everything is the way
you want it.
Another way, if the line is just
too messed up to worry about,is to press the Esc (Escape) key.
A backslash (\) is displayed, andthe cursor moves down one lineon the screen. This cancels themessed-up line and you canthen type the commandcorrectly.

More ways to correct typing mistakes, which wecall editing, are discussed in Chapter 3; but thesetwo keys should be enough to get you started.

2-26

To Stop the Screen Long Enoughto Read It(81][IL§]J]+

If information is appearing on
the screen too fast for you toread, press and hold the Ctrl
(Control) key and then press the
Num Lock (Number Lock) key.
Then release both of them.
When you are ready to see somemore information, press any
key.

(Scrolling is the term used todescribe how a line of
information is displayed on thescreen and then is pushed
upward until it is pushed off the
top of the screen by new lines of
information being displayed at
the bottom.)

To Print What Is on the Screen
If you have a printer and wantto print what is currently on thescreen, first make sure theprinter is on. Then press andhold either Shift key, and thenpress the PrtSc (Print screen)
key; then release both of them.
What is printed is often called ahard copy.

2-27

To Print Whatever You TypeIf you have a printer and wantto print whatever you type andwhat the computer displays,press and hold the Ctrl
(Control) key and then press the
PrtSc (Print Screen) key. Thenrelease them both. Now, eachtime you press the Enter key, or
the computer displays a line, theline will be printed or echoedon the printer.
To stop echoing to the printer,press the Ctrl and PrtSc keys
again.
This is different from Shift and
PrtSc. Shift and PrtSc prints awhole screen's worth and then isdone. But Ctrl and PrtSc prints
one line at a time, line afterline, until you press Ctrl and
PrtSc again to stop the printing.

To Start DOS Again(ElIJ+[ltJ]J+[lbJJ]

If you want to start DOS overfrom the beginning, put yourDOS diskette into drive A.
Then press and hold down the
Ctrl (Control) and Alt(Alternate) keys and then press
the Del (Delete) key. Thenrelease all three. Remember,you may see this called System
Reset.
After a bit, you'll see the DOS
startup messages.

2-28

Control Keys

Use the control keys when you are enteringcommands or input lines to any program. Where
two keys are specified, for example Ctrl-Break,you must press and hold down the first key andthen press the second key.
Here is a summary of the control keys, theirfunctions, and their locations on the keyboard:

Control Key

Function
This is the Enter key. You press theEnter key to send the displayed line to
the requesting program.

2-29

Control Key

Function

Ctrl-BreakEnds (cancels) the current operation.

Ctrl-Enter

Allows you to go to the next displayedline on the screen to continue entering
the line you are typing.

2-30

Control Key

Function

Ctrl-Num Lock

Suspends system operation. You mustpress any character key to resume
operation. This is useful when a large
amount of screen output is being
generated. You can press Ctrl-Num
Lock to temporarily suspend thedisplay of your output so you canreview it. You can then press any othercharacter key to restart the display.

2-31

Control Key

Function

Ctrl-PrtSc

These keys serve as an on! off switch
for sending displayed output to theprinter as well as to the screen.
You can press these keys to print
displayed output on the printer andpress them again to stop printing
displayed output on the printer.
Although this allows the printer tofunction as a system log, it slows downsome operations because the computerwaits during the printing.

2-32

Control Key

Function

Esc

Cancels the current line and moves tothe next displayed line. A backslash (\)
is displayed to indicate the canceled
line.

Shift- PrtSc

Sends a copy of what is currently
displayed on the screen to the printer.
This, in effect, prints a "snapshot" ofthe screen.

:"•.•...

; ".. '~.

..~rtSc:....;.
:.<:"' . <:,. <.

".

" ~

'~:

"

,

~.'»

,

',.",..".. ,>:,..

:;«".; ,"."

Il:~~

2-33

Control Key

FunctionBackspaces and removes a characterfrom the screen. This is the key to theleft of Num Lock, not key 4 on the
numeric key pad.

•~..

1111J.---\111J-.-\IHI}---'lf--\IHIi---\1t

2-34

DOS Editing Keys

Use the DOS editing keys to make corrections tocommands and input lines as they are being
entered. Note that the meaning of these keys canchange if you alter their assignments throughextended keyboard control, refer to "Using
Extended Cursor and Keyboard Control" in
Chapter 13 for additional information.
The DOS editing keys are used to edit within a line.
The Line Editor (EDLIN) program operates oncomplete lines within a file or document. When you
are working with EDLIN and want to edit within aline, however, use the DOS editing keys. For more
information about EDLIN, refer to Chapter 7.
Note: Some word processing programs
define special editing rules; therefore, theDOS editing keys may not work as describedin this chapter. You can also define special
editing rules when using the BASIC Program
Editor while programming in BASIC.
Any line you enter from the keyboard is retainedin an input buffer when you press Enter. The lineis then made available to your program forprocessing.
Since the line remains in the input buffer, you can
use that line as a template for editing purposes. The
DOS editing keys operate on that copy of the line.
You can repeat or change the line by using the
DOS editing keys, or you can enter an entirely new
line.

2-35

Here is a summary of the DOS editing keys, theirfunctions, and their locations on the keyboard:
DOS Editing Key Function
Del

Skips over one character in thetemplate. The cursor does not move.

Esc

Cancels the line currently being
displayed. The template remains
unchanged.

2-36DOS Editing Key Function
Fl or -+

Copies one character from thetemplate and displays it.

F2

Copies all characters up to a specified
character.

2-37

DOS Editing Key

Function

F3

Copies all remaining characters fromthe template to the screen.

F4

Skips over all characters up to a
specified character. (F4 is the
opposite of F2.)

2-38

DOS Editing Key

Function

F5

Accepts an edited line for continued
editing - the currently displayed line
becomes the template, but it is notsent to the requesting program.

I:~\':S0:'G:HJ:.':::::: :Ins

Allows you to insert characters within
a line.

IllJI-\lJ1HIHIHI!--\IHIHI>-\IHIHIf-\IJ-\Ii-

2-39

Examples of Ways to Use DOS
Editing Keys
The following examples show how you use the
DOS editing keys with the Line Editor (EDLIN)
program.
If you want to try these examples, you must use
the EDLIN program. The EDLIN program is on
your DOS diskette and is discussed in Chapter 7.
You do not need to review the EDLIN chapter tocomplete these examples - just follow the steps
provided.
Notes:

2-40

1.

Because the DOS diskette shipped with your
IBM Personal Computer is write protected, you
cannot create the file used in the following
examples on that diskette. You must use acopy of your DOS diskette to complete theseexamples. Refer to the section called"w rite-Protect Notch" in Chapter 1, for more
information about write protected diskettes.

2.

In the following examples, to enter somethingmeans that you should type the informationand then press the Enter key.

3.

If you finish one or more of the following
examples and you do not want to try the restof the examples, go to "To Stop the Editing
Session" at the end of this chapter.

To Start EDLIN
1.

Insert your DOS diskette into drive A.

2.

Create a file named EXAMPLES.
If you want the EXAMPLES file to reside on
the diskette in your default drive, enter:
EDLIN EUMPLESor
If you want the EXAMPLES file to reside on
the diskette in another drive, you must specify
the drive, as in:
EDLIN B:EUMPLESThis command tells DOS to load the EDLIN
program and create a file called EXAMPLES.
The following message and prompt will be
displayed:
New file*
Notice that the prompt for EDLIN is anasterisk (*).
3.

Now, enter the letter I.
This tells EDLIN that you want to begin
inserting lines in the file named EXAMPLES.
The screen looks like this:New file*. 1:*_
2-41

4.

Type This is a mailorder file. on line 1 andpress Enter.

5.

Type Editing is easy. on line 2 and press
Enter.
You now have two lines of text in your
EXAMPLES file.

6.

Press the Ctrl-Break keys.
Pressing Ctrl-Break will end the insert modeof operation and return you to the EDLIN
prompt.

7.

Enter the number 1.
This tells EDLIN that you want to display line
1 on the screen.
The screen should look like this:
1:'hThis ~$ I mliDorder file.
1~~~

You are now ready to begin the examples.
Note: If you encounter any problems while
trying these examples, press the Ctrl-Breakkeys. The EDLIN prompt will be displayed
and you can start over.

2-42

Example 1
Let's delete the first two characters in the word
This and then copy the remainder of the line.
1.

Press the Del key twice to delete the first two
characters.

2.

Press F3 to copy the remainder of the line tothe screen. The screen looks like this:
1:*This is a mailorder file.
1:*is is a mailorder file._

If you want to continue with the next example:
1.

Press Ctrl-Break to return to the EDLIN
prompt. (The changes you made to line 1 will
not be saved.)

2.

Enter the number 1.

Example 2
N ow we'll change line 1; then, using Esc, we willcancel the change. A backslash (\) will be displayed
to indicate that the displayed line has beencancelled.
Note: If the insert mode is on, the system
automatically turns it off when you use Esc.
The screen looks like this:
1:*This is a mailorder file.
1:*_

2-43

To change line 1 to Sample file:
1.

Type Sample file, but do not press Enter.
1:*Thls Is a mallarder file.
1:*Sample fll_2.

To cancel the line we just entered, press theEsc key.
1:*This is a mailarder file.
1:*Sample file \Now we can continue to edit the original line
This is a mail order file.
3.

Press F3 to copy the original line to thescreen.
The screen looks like this:
1:*This is a mailarder file.
1:*Sample file \This is a mailarder file __If you want to continue with the next example:

2-44

1.

Press Ctrl-Break to return to the EDLIN
prompt.

2.

Enter the number 2.

Example 3
Now let's copy one character by using Fl or ~ .
(Fl or ~ is the opposite of Del. Del skips over
one character in the template.)
The screen looks like this:
2:* Editing is easy.
2:*_

1.

Press the Fl or~

key three times.

The screen looks like this:
2:*Editing is easy.
2:*EdL

Each time you press the Fl or
more character appears.

~

key, one

If you want to continue with the next example:
1.

Press Ctrl-Break to return to the EDLIN
prompt.

2.

Enter the number 2.

Example 4
N ow let's use the F2 key. Remember, the F2 key
copies all characters from the template to thescreen up to, but not including, the firstoccurrence of a specified character.
You must always specify a character when using
this key. If the specified character is not present in
the template, nothing is copied.

2-45

The screen looks like this:
2:*Editing is easy.
2:*_

1.

Press the F2 key and enter the letter g.
The screen looks like this:
2:* Editing is easy.
2:*EditiL-

N ow we'll copy all the remaining characters in
the template to the screen by using the F3
key.
(If you pressed Enter now, only Editin would
be saved in the EXAMPLES file as line 2.)2.

Press the F3 key.
The screen looks like this:
2:* Editing is easy.
2:* Editing is easy~

If you want to continue with the next example:

2-46

1.

Press Ctrl-Break to return to the EDLIN
prompt.

2.

Enter the number 1.

Example 5
N ow let's scan and locate specific characters within
the template by using the F4 key. This is a way toskip over characters. The cursor does not movewhen you use this key, and no characters are
displayed.
You must always specify a character after you press
the F4 key. If the specified character is not present
in the template, no characters in the template will
be skipped.
We will also use the F3 key to copy the remaining
characters in the template to the screen.
The screen looks like this:
1:*This is a mailorder file.
1:*_

1.

Press the F4 key and enter the letter o. (Nocharacters are displayed.)2.

Press the F3 key to copy the remainder of theline.
The screen looks like this:
1:*This is a mailorder file.
1:*order file __If you want to continue with the next example:
1.

Press Ctrl-Break to return to the EDLIN
prompt.

2.

Enter the number 1.

2-47

Example 6
Now we'll move the currently displayed line into
the template by using the F5 key. Pressing F5 isthe same as pressing Enter, except that the line is
not sent to your program. An @ character isdisplayed to indicate that the new line is now the
template.
Note: If the insert mode is on, the system
automatically turns it off when you use F5.
Once you press F5, you can continue to makechanges to a line. When you are finished, press
Enter to send the line to your program.
The screen looks like this:
1:*This is a mailorder file.
1:*_

1.

Type This is not a sample file.
The screen looks like this:
1:*This is a mailorder file.
1:*This is not a sample file __2.

Press F5.
The result is:
1:*This is a mailorder file.
1:*This is not a sample file.@

The replacement line This is not a sample
file. is now in the template. The replacement
line is acceptable, but let's continue to edit it.

2-48

3.

To remove the word not from thereplacement line, press F1 eight times:
1:*Thls Is a mallorder file.
1:*This is not a sample flle.@

4.

Press Del four times to remove one blankspace and the word not.

5.

Press F3 to copy the remaining characters to
the screen.
The screen looks like this:
1:*This is a mailorder file.
1:*This is not a sample file.@
This is a sample file._

6.

Press Enter to make the replacement line
This is a sample file. the template in place ofthe original line and to send the line to yourprogram.
(If you want to do more editing without
sending the line to your program, press F5
again to put the displayed line into thetemplate.)
Note: Pressing Enter immediately afterpressing F5 empties the template.

If you want to continue with the next example:
1.

Press Ctrl-Break to return to the EDLIN
prompt.

2.

Enter the number 1.

2-49

Example 7
Let's look at an example using the Ins key. The Ins
key serves as an on/off switch for entering andleaving insert mode. You can press the Ins key toenter insert mode, and press the Ins key again toleave the insert mode.
While in the insert mode of operation, any
characters that you enter are inserted in the line
being displayed. The characters do not replacecharacters in the template.
When you are not in the insert mode of operation,
any characters that you enter replace characters in
the template. If you are entering characters at theend of a line, the characters will be added to theline.
The screen looks like this:
1:*This is a sample file.
·*1'

Let's change the word sample to salary.
1.

Press the F2 key and enter the letter m.
The screen looks like this:
1:*This is a sample file.
1:*This is a s_

2.

Press the Ins key and enter the characterslary.
The screen looks like this:
1:*This is a sample file.
1:*This is a salarL

2-50Notice that the characters lary were inserted,
but no characters from the template were
replaced.
3.

Now, press Ins again to leave the insert mode.

4.

Enter one blank space and the threecharacters tax.
1:*This is a sample file.
1:*This is a salary tIX..-

5.

Press F3 to copy the remaining characters in
the template to the screen.
1:*This is a sample file.
1:*This is a salary tax file __Notice that we inserted lary and we replaced
mple with a blank space and tax.
6.

Now press Enter to make the replacement
line the template in place of the original line
and send the line to the requesting program.

2-51

To Stop the Editing Session

You have now completed the examples.
To return to the A> prompt:
1.

Press Ctrl-Break.

2.

Enter the letter Q.

Q tells EDLIN that you don't want to save the
EXAMPLES file and that you want to quit theediting session. EDLIN will prompt you withthis message:
Abort edit (YIN)?

to make sure you don't want to save the file.
3.

2-52

Enter the letter Y.

Chapter 3. Using DOS

Contents
Introduction ....... .; ................... .;.
Giving DOS a' Command
"0 •

•• •

•

•

•

•

•

•

•

•

•

3-3
3-3

Getting a Diskette .Ready to Be Used ..... .
Using the FORMAT Command ....... .
Before YouBegin ..................... .
If You Want DOS on Your Diskette .•.
With ,One Drive ................. .
With Two Drives ..•.............
IfXou })oN.of\V~ntDOS on Your
, Diskette ...... ~ .•.. ~••.
! •••'
FormattingSever~1 I>i~kette~' ~ .... :' ... .
'd • . • • • • • • • •BackirtgUp a Dlskette' ................... .
Using the DISKCOPY Com~and ..... .
B~fore You·Begitf~: ..,..•.... ~ ...•...... ~.
ProtectingYouiOrigina~ Di$~ette .";." .
Backing Up~ith0n.e Drive <' ••••••••••
Backing Vp",yith Two Drives ......... .
Backing Up One File ......,~... .... .... . ... 3-18
Using the COpy Command .. .. • . . . ... 3-18
Before You Begin. . .. .. ... . .... . .. ... 3- 20
Copying a File to the Same Diskette ... 3~20
Copying a File to Another Diskette
Using' Oh¢Drive .. :~ ......... ~. . . . .. 3-22
ForYoutoTry ... ·• ~L""~T'~""" 3-26
Copying a rile toAnoth,~r Diskette
Using.Two Drives •.... ·. '.: .. '...•.. " .. 3-26
ForYo\ltoTry ...
3~.28

Backing Up More Than One File .......... 3-29
Using the COpy Command ........... 3-29
Finding Out What Is on a Diskette .......
Using the DIR Command .............
Before You Begin ....................
To List All the Files ..................
With One Drive .................
With Two Drives ................
To List One File ........... . . . . . . . . . ..
With One Drive .................
With Two Drives ................

3- 30
3-30
3- 30
3- 30
3- 30
3-32
3- 32
3- 32
3- 33

Displaying What Is in a File ..............
Using the TYPE Command ...........
Before You Begin ....................
Here's How You Do It ................

3-34
3- 34
3- 34
3- 34

Changing a File's Name ..................
Using the RENAME Command ........
Before You Begin ....................
With One Drive .................
With Two Drives ................
For You to Try ..................

3-37
3-37
3- 3 7
3- 38
3- 39
3-40

Removing a File from a Diskette .........
Using the ERASE Command ..........
Before You Begin ....................
. With One Drive .................
With Two Drives ................
Global Filename Characters ...........

3-41
3-41
3-41
3-42
3-43
3-43

Shifting the Display on the Screen ........
Using the MODE Command ..........
Before You Begin ....................
Shift Right. . . . . . . . . . . . . . . . . . . . . . . . . ..

3-44
3-44
3-44
3-44

Hel ps and Hints ......................... 3-46
Summary ................................ 3-48

3-2

Introduction

This chapter steps you through procedures that dosome everyday tasks. Read it now to get familiar
with these commands and then you can use it torefer to when you really have to do that task.
The examples shown in this chapter describe using
DOS in a diskette-only environment, and areintended to serve as an introduction to DOS. If
you have afixed disk, please refer to "Preparing
Your Fixed Disk" in Chapter 4 after reviewing thischapter.
Just remember, you will have to substitute the names
ofyour own files for those we have used here-it's that
easy.

Giving DOS a CommandTo give DOS a command:
1.

Wait until you see the DOS prompt, A>.

2.

Type the command and any other parts thecommand requires (for example, a drive
specifier or a file specification).
You can type in uppercase or lower caseletters (or a combination). Use a blank (theSpacebar) to separate the parts of thecommand from each other.

3.

Press the Enter key when you have finishedtyping.

3-3

Getting a Diskette Ready to Be Used

Using the FORMAT Command
The FORMAT command gets a diskette ready toreceive information. FORMAT checks the diskettefor bad spots, builds a directory to holdinformation about the files that will eventually be
written on it, and optionally, copies the DOS
system files onto the diskette.
Sometimes the terms initializing and preparing areused instead offormatting.
You must use FORMAT before you try to use a new
diskette unless you are copying from anotherdiskette using the DISKCOPY command.
You can use FORMAT if a diskette has developed
defective areas. FORMAT makes sure these areas
are not used for your files. FORMAT and
CHKDSK will tell you if there are defective areas
on your diskette.
You can also use FORMAT as a way to prepare adiskette that has information you no longer need foruse again.

DO NOT use FORMAT each and every time youwant to put information on a diskette, because
FORMAT wipes off what was already there.

3-4

To sum up, you need to use FORMAT once per
diskette, when it is new. Very occasionally you will
re-FORMA T a diskette if it has defective areas or if
you want to forget what was on it and use it as if itwere new.
Note: If you have a fixed disk, it will alsoneed to be initialized. Refer to "Preparing
Your Fixed Disk" in Chapter 4 for a
description of the initialization procedure.

Before You Begin
Have on hand your DOS diskette and the diskette
you want to format.
Also decide whether you want a copy of DOS on
your new diskette. Sometimes you will want DOS
on a diskette if you will be putting major programs
on it. On the other hand, if the diskette is going to
be used for data files, you will probably not want
DOS on the diskette.

If You Want DOS on Your Diskette
With One Drive
1.

Make sure DOS is ready and A> is displayed.

2.

Insert your DOS Diskette into drive A, if it is
not already there.

3-5

3.

Type:
format a:/sand press the Enter key. If the target drive isdual-sided, this will create a diskette fordual-sided use only. If you want to format adiskette that can be used in either asingle-sided or a double-sided drive then type:format a:/s/1

4.

N ow you will see this message:

Insert new diskette for drive A
and strike any key when ready5.

When the drive A "in use" light is off, remove
the DOS diskette from drive A.

6.

Put your new diskette into drive A.

7.

Press any key- the Spacebar for instance.

8.

You will see this message:

Formatting...

3-6

9.

After some whirring and clicking, you will see
this:Formatting... Format complete
System transferredxxxxxx bytes total disk space
xxxxxx bytes used by system
xxxxxx bytes available on disk
Format another (YIN)?

10. Type:n

You don't have to press the Enter key.
11. Now you will see the DOS prompt, A>, andyou can remove your newly formatted
diskette.
The diskette is now ready to be used. It has a
copy of the DOS system on it (that's because
in step 3 you typed Is-the s stands for system).

3-7

With Two Drives
If you have two diskette drives, insert your DOS
diskette into drive A and put your new diskette
into drive B.
Then, for step 3, type:format b:/s(format b:/s/l for single-sided)orformat b:(format b:/l for single-sided)
depending on whether you want the DOS systemon your diskette.
In step 4, the message is now going to be:Insert new diskette for drive B
and strike any key when readyThe rest of the steps are the same except you will
not have to remove the DOS diskette.

3-8

If You Do Not Want DOS on Your
Diskette
If you don't want DOS on your diskette, in step 3
you can type instead:format a:orformat a:/1 for single-sided format

and press the Enter key. Then the line that says
System transferred (step 9) does not appear.

Formatting Several Diskettes
If you want to format several diskettes in a row,follow steps 1 through 9. But do this at stepJO.
Type:y(Y ou probably already guessed.)
You will again see the message at step 4. Follow
the same steps for each diskette you want toformat at this time.

3-9

Backing Up a Diskette

Using the DISKCOPY Command
Backing up a diskette means to make a copy of thediskette's data on another diskette. Similarly,
backing up a file means to make a copy of the file(usually on a different diskette). (Backing up one
file is discussed in the next part of this chapter.)
A backup, that is, the copy, saves you the time,
trouble, and sometimes, the expense of recovering
the information on a diskette that has been lost,
damaged, or accidentally written over. A backup
often saves your temper, too.
It is a good habit to back up your important program
diskettes as soon as you purchase or create them.
Then, store your original diskettes properly in aplace where you can find them if you need to. And
then use the backup diskettes for everyday
operations.
Note: Some purchased program diskettes
cannot be copied. In these cases, thedocumentation that comes with the programs
will explain the best methods of backing
them up.
Your diskettes should be backed up every time you
add or change information on them.

3-10

Before You Begin
You will need these diskettes:•

The diskette you want to back up-we're goingto call this your original diskette. You may also
see it called the source diskette.

•

The diskette that will become the backup
diskette. Other names for this diskette are thetarget diskette, or the destination diskette.

Protecting Your Original Diskette
Hint: It's a good idea to put a tab over the writeprotect notch in order to make sure your original
diskette is not aCcidentally written on. Then you
can remove it when the backup has been made, if
you want to.
With the write-protect notch covered, if thediskettes get mixed up, a message similar to this isdisplayed:

Target diskette write protected
Correct, then strike any key

The cursor is here

3-11

If you get this message:
1.

Remove the original diskette from the drive.

2.

Insert the backup diskette into the drive.

3.

Press any key.
(Y ou do not have to press the Enter key.)

Backing Up with One Drive
If you have only one diskette drive, you must
remove the original diskette and insert the backup
diskette. You will have to make this switch(" swap") four or more times. How many times you
must exchange diskettes depends on whether
you're using DISKCOPY or COPY, or how large
the files being copied are, and on how muchmemory your computer has. DOS will tell you
when you must exchange diskettes. DISKCOPY
gives you these messages:

Insert source diskette in drive A:

Insert target diskette in drive A:

3-12

So you should:
InsertWhen

Original diskette"source" message is displayed

Backup diskette"target" message is displayed

1.

Make sure DOS is ready and A> is displayed.

2.

Insert the DOS diskette into the drive, if it is
not already there.

3.

Type this:diskcopy

and press the Enter key.
4.

This message appears:

Insert source diskette in drive A:
Strike any key when readyBefore You Press a Key:a.

Remove the diskette that is in the drive.

h.

Insert your original diskette into the drive.

c.

Now press a key.

3-13

5.

You will see the" in use" light come on while
the original diskette is being read, and thenthis is displayed:

Insert target diskette in drive A:
Strike any key when readyBefore You Press a Key:

6.

a.

Remove your original diskette.

b.

Insert the backup diskette.

c.

Now press a key to tell DOS the correct
diskette has been inserted.

You will see the "in use" light come on while
the backup diskette is being written. Then themessage shown in step 4 appears again.
Hint: For this procedure, you can remember
which diskette to insert, if you remember, "Original=Source." Insert your original
diskette when DISKCOPY asks for the source
diskette.

7.

Keep repeating steps 4 and 5 until thismessage appears:

Copy complete
Copy another (Y/N)?

3-14

8.

Type this:n

You don't have to press the Enter key.
9.

The DOS prompt, A>, is displayed. Remove
the backup diskette from the drive. With afelt-tip pen, mark the label with the contents,
the date, and perhaps the word "Backup."

Backing Up with Two Drives
1.

Make sure DOS is ready and A> is displayed.

2.

Insert your DOS diskette into drive A.

3.

Type this:diskcopy a:b:and press the Enter key.
4.

You will see this message:

Insert source diskette in drive A:
Insert target diskette in drive B:
Strike any key when ready5.

Remove your DOS diskette from drive A.

6.

Insert your original diskette into drive A.
3-15

7.

Insert your backup diskette into drive B.

Orlglna. diskette
8.

Backup diskette

Press any key.
This tells DOS you are ready and this message
is displayed:

Copying 9 sectors per track, 1 side( s)Formatting while copying

The number 8 or 9 may appear in the firstline, indicating the number of sectors per
track that could be read from the original
diskette.
The Formatting while copying message will
only appear if the diskette had not previously
been formatted with the same format as thesource diskette.

3-16

9.

Now all information is being copied from thediskette in drive A to the diskette in drive B.

You will see one "in use" light go on and thenthe other.
10. When the copy has been made, you will see amessage similar to this:Copy complete
Copy another (Y/N)?_T he cursor is here.
11. Type:nand press the Enter key. The DOS prompt,
A>, is displayed.
12. Remove both diskettes.

Use a felt-tip pen to label and date the backup
diskette. You may also want to write"Backup" on the label to remind yourself that
this is a copy of another diskette.

3-17

Backing Up One File

Using the COpy Command
Sometimes you will find it useful to copy only one
file. You might want to copy one file instead of awhole diskette when:•

Only one file of a whole diskette has beenchanged and needs to be backed up.

•

You want to make extensive changes to a file,or you're not too sure of the effect of thechanges. It is safer to change a copy of the filerather than the original.

•

You want to build a new file based on thecontents of an "old file" -similar to copying a
letter and then marking up the copy to makea new letter.

•

You need two copies of a file. For example, if
you want to give a program you wrote to afriend, you'd probably want to give a copy ofthe program and not your original program.

Let's use some diagrams to illustrate the various
possibilities with COPY.
Assume that two of the files on the original
diskette are LlCORS and DIARY, and that the file
to be copied is L]CORS.

3-18

•

The file (LlCORS) is copied to anotherdiskette and the name is the same on bothdiskettes:
Original~

BackupILdCORS II WeORS I•

The file (L]CORS) is copied to anotherdiskette and the name of the copy is changed:
Original~

BackupI COURSE I

IUCORS]•

The file (LlCORS) is copied onto the original
diskette with a changed name:
Original

EJ

IUCORS II COURSE I

3-19

•

The file (L]CORS) is copied onto the original
diskette with a name that is already being
used:
Orilinal.~---...
IUCORS

Before You Begin
Decide which kind of copy you want to make.
Then collect:•

The diskette that contains the file you want tocopy. We'll call this the original diskette.

•

The diskette that will contain the copy of thefile when you are done.
This may be the same diskette as your original
diskette. Or it may be a different diskette, inwhich case we will call it your backup diskette.

Also decide on the name for the copied file.

Copying a File to the Same Diskette
For this example, let's assume that LETTER is thename of the file you want to copy, and that the
copy's name will be MEMO.

3-20

Recall that you need a different name because
every name on a diskette must be unique. Youmight want to check that the name you havechosen isn't already being used, unless you reallymean to replace that file. For this example, checkby typing: dir memo.
Let's do it:
1.

Make sure DOS is ready and A> is displayed.

2.

Insert the original diskette (the diskette with
LETTER on it) into drive A.

3.

Type this:copy letter memo

and press Enter.
Notice that in the command, you type theoriginal filename first and the backup
filename second. Separate the filenames witha space.
4.

After a few seconds (depending on how longthe file LETTER is), you will see this on thescreen.

r
1 FUe(s) copied

1>_

3-21

5.

LETTER has been copied and the copy has
been given the filename MEMO.
You can use the DIR command to check, by
typing this:dir memo

Now press the Enter key.
6.

Remove the diskette and put it away in its
envelope because we are through with thisexample.

Copying a File to Another Diskette
Using One Drive
Remember, with only one diskette drive, you willneed to exchange diskettes while COpy isrunning. DOS will tell you when the change must
be made by showing you a message.
COPY's messages sound as if you had two-drives
instead of one. You should think of the messages
as referring to diskettes instead of drives.
For our examples, think of your original disketteas the drive A diskette. Think of the backup
diskette as the drive B diskette. (Even though you
have no drive B, the command is the same for one
drive or two. The computer keeps track of thereal drive A and the" imaginary" drive B.)

3-22

Ifyou had two drives

Original
diskette

Backupdiskette

But with one drive

Original disketteinsert when drive
A is called for.

Backup disketteinsert when drive
B is called for.

Let's assume that the fil~ you want to copy is
LETTER. For this example, we are going to copy
LETTER to another diskette without changing its
name.

3-23

1.

Make sure DOS is ready and A> is displayed.

2.

Insert the diskette with LETTER on it (theoriginal diskette) into your drive.

3.

Type this:copy letter b:

and press the Enter key.
Notice again where the spaces are.
4.

This message is displayed:

Insert diskette for drive B: and strikeany key when ready

3-24

5.

Remove the original diskette. (But don't put
it away-you may need it soon.)

6.

Insert the previously formatted backup
diskette into the drive.

7.

Now press a key to tell DOS that the diskettes
have been switched.

8.

Depending on the size of the file being copied(LETTER, in this example) and yourcomputer's memory, you may see thismessage:

Insert diskette for drive A: and strikeany key when readyIf you do see the message, do this:a.

Remove the backup diskette from thedrive.

b.

Insert the original diskette into the drive.

c.

Press a key.

d.

N ow go back to step 4.

Hint: It's easier to remember which disketteto insert if you think "B is for backup." Insert
the backup diskette when the drive B message
appears.
9.

When the copy has been made, this message isdisplayed:

1 File(s) copied

3-25

10. Remove the backup diskette from the drive

and label it with a felt-tip pen.
11. Now you can put both diskettes away-

LETTER has been copied to the second
diskette.

For You to Try
Select a file on your DOS Diskette to copy toanother diskette-how about COMP.COM? Keep
the name the same (unless the diskette you'll put
the copy on already has a file called COMP.COM).

Copying a File to Another Diskette
Using Two Drives
Let's assume you want to copy LETTER (again!).
But this time, you want to put the copy on anotherdiskette.
What name do you want it to have? For thisexample, we have picked the filename
CORESPND for you. Here are the steps:

3-26

1.

Make sure DOS is ready and A> is displayed.

2.

Insert the diskette with LETTER on it into
drive A.

3.

Insert the diskette that you want the copy
(CORESPND) to be written on, into drive B.

Original diskette(LEnER)

4.

Backup dlskeHe(for CORESPND)

Type this:copy letter B:corespnd

and press the Enter key.
Notice the spaces between copy and letterand between letter and b:corespnd. Do not put
a space between b: and corespnd
Also notice that you must indicate thediskette drive (b:) of the target diskettebecause it is not the same as the default drive.
(Look back at "The DOS Prompt" in Chapter
2 for information about the default drive.)5.

One "in use" light will come on and then theother.

3-27

When the copy has been made, this isdisplayed:

1 File(s) copied

6.

You can now remove both diskettes and use afelt-tip pen to label the backup diskette.
Now you can put both diskettes awayLETTER has been copied to the second
diskette (and has been retired from use in all
future examples).
If you want the copied file to have the" same
old name" on the other diskette, this is what
you'd type in step 4:
copy letter b:orcopy letter b:letter

For You to Try
Practice this exercise by copying the file
DISKCOPY.COM to another diskette. Change thename, if you wish. Remember, the backup disketteneeds to have been formatted if it's brand new.

3-28

Backing Up More than One File

Using the COpy Command
Sometimes you will find it useful to copy morethan one file at a time. For example, you want tobuild a new diskette file based on the contents ofan old diskette file.
To backup all the files on a diskette, enter:
COpy *.* B:

The COpy command with the global filename
characters *. * in the command line will copy all thefiles from the diskette in default drive A to thediskette in drive B, with no change in thefilenames or in the extensions.
The filenames of the files being copied are
displayed as the files are copied (refer to the"COpy Command" in Chapter 6 for additional
information).

3-29

Finding Out What Is on a Diskette

Using the DIR Command
It is often handy to find out what files are on adiskette-perhaps because you need to find out
how a particular filename is spelled, or because
you can't recall what's on a seldom-used diskette.
The Directory command (DIR) displays a list of all
the files that match a name you specify. You've
seen this command before in the section "Using
Global Filename Characters." Let's see how you
might use it.

Before You Begin
All you need for DIR is the diskette that you want
to see the directory.

To List All the Files
With One Drive

3-30

1.

Make sure DOS is ready and A> is displayed.

2.

Remove the DOS diskette from drive A, if it isthere.

3.

Insert into drive A the diskette whose
directory you want to list.

4.

Type:
dir

and press the Enter key.
5.

Watch the screen.
The first message to appear will display thevolume label of the diskette (if it has one),
followed by the name of the directory that isbeing listed. Refer to Chapter 5, "Using TreeStructured Directories" for more information.
Then the files on the diskette are listed.
The screen displays the/ilename, the extension,
the size of the file (in bytes), the date and thetime that information was last written in the
file. One line is displayed for each file on thediskette.
After the files have been listed, DIR displays
the amount of free space left on the diskette(in bytes).
Remember, if the information is moving too
fast for you to read it, press and hold the Ctrl
key and then press the N urn Lock key. Thenpress another key when you're done reading
to start displaying again. It is also a good idea
to print a copy of a diskette's directory(Ctrl + PrtSc) to keep with the diskette.

6.

When all the files have been displayed, theDOS prompt appears:

A>

3-31

With Two Drives
If you have two diskette drives, you can keep the
DOS diskette in drive A, if it is there, and insert
your diskette into drive B. Then at step 4, typethis:
dir b:and press the Enter key.
You have to tell DOS where to find the diskettein this case the one in drive B. Otherwise, DOS
assumes you mean the default drive diskette if you
type only the command (dir) without a drive
specifier.

To List One File
With One Drive
For this example, let's assume that you think you
have a file named FACT&FIG on a diskette. Here's
how you make sure:
1.

With DOS ready (A> is displayed), insert thediskette into drive A.

2.

Type:
dir lacillig

and press the Enter key.

3-32

3.

If FACT&FIG is indeed on the diskette, its
filename (FACT&FIG), its extension (in thiscase, none), its size, and its update date andtime are shown.
If the diskette does not have a file named
FACT&FIG, then after a second or two themessage:

File not foundA>_

is displayed.

With Two Drives
You can insert the diskette with the file into drive
B and type this for step 2:
dir b:fact&fig

Now press the Enter key.
See, the only difference is that you have to tell
DOS where (what drive) the file is.

3-33

Displaying What Is in a File

Using the TYPE Command
The TYPE command lets you" look into" a file;that is, it displays the contents of a file on thescreen.
As the example will show, you can also print thecontents if you have a printer.

Before You Begin
Locate the diskette that has the file you want todisplay. You also need to know the exact name of
the file (use D IR again).

Here's How You Do It
For this example, assume that the file you want todisplay is ITEMS. DAT.

3-34

1.

Make sure DOS is ready for a command; A> isdisplayed.

2.

Insert the diskette with ITEMS.DAT into
drive A.

3.

If you have a printer:a.

Make sure that the printer is turned on, is
online, and has paper in it.

b.

Press and hold the Ctrl key and thenpress the PrtSc key.

DBD+g

4.

c.

Release both keys.

d.

Check to see that" echo to the printer"has been turned on by pressing the Enter
key.

e.

Both the screen and the printer should
show the prompt, A>.

£

If the printer didn't print A>, do steps 3b
through 3e again.

Now type:
type items. dat

and press the Enter key.

5.

The command you just typed and contents of
ITEMS.DATwill be displayed and printed.

6.

When you see the DOS prompt, A>, you canremove the diskette and put it away.

3-35

7.

Stop the printer from printing what isdisplayed on the screen by pressing andholding the Ctrl key and then pressing the
PrtSc key.
Some files contain information that you won't
be able to read. These are programs or certain
data files that the computer can read-but wecan't. The printer information might look
similar to this::r:s......
••••!laij;u~<t}8 ul}7u~{t)j.~! )u'\}]U'7I'F)

And the information on the screen looks evenstranger!

3-36

Changing a File's Name

Using the RENAME Command
The RENAME command lets you change a file's
name-either its filename, its extension, or both.
This may be useful if you've found that you simply
cannot type a name the way you've spelled it. Moreoften, the reason for changing is that you just want
to refer to a file with a different name.

Before You Begin
Have on hand the diskette with the file that you
want to rename. You also need to know its exact"old" filename and extension, if it has one.
(Remember, you can use the DIR command tofind out the filename and extension.)

3-37

With One Drive
For this example, let's assume that a diskette has afile named STOCKS.DAT on it, but that we havedecided that ASSETS. SO is a more descriptive
name for this information. Also assume that wehave checked this diskette's directory and foundthat this diskette does not already have a file named
ASSETS.so on it.
~.,

01
I-cree::. :!! f~J- - ASSETS.80

Here's how to change the name:1.

Make sure DOS is ready and A> is displayed.

2.

Insert the diskette with STOCKS.DAT on it
into drive A.

3.

Type this:rename stocks. dat assets.80

Check your typing, and then press Enter.
Notice that the" old" name is first, then aspace, and then the" new" name.
4.

In a moment, DOS displays the prompt, A>,
and the file has been renamed.

5.

You can check to see that the file has reallybeen renamed by typing:
dir stocks. dat

3-38

This should be displayed:A>_

File not found

Then type:dir assets.BO

Now the information about that file should be
displayed.
Remove your diskette and put it back in its
envelope.

6.

Be careful about using global filename
characters in the" old" file specification. You
may get unexpected results. Changing back to
the names you want may be more tediousthan renaming the files one by one in the firstplace.

With Two Drives
If you have two diskette drives and already haveanother diskette in drive A, then insert thediskette with STOCKS.DAT on it into drive B,
then type:b:

This changes the default drive to drive B. Now
press Enter.

3-39

Then repeating step 3, type:
rename stocks. dat assets.BO

N ow press Enter.
Repeat step 5 also, thus:
dir stocks.dat

anddir assets.BO

To switch the default drive back to drive A, type:a:then press Enter.

For You to Try
Try using the RENAME command on one of thefiles that you copied (in a previous "practice"
exercise).

3-40

Removing a File from a Diskette

Using the ERASE Command
One of the housekeeping chores associated withdiskettes is to remove files that you no longer needfrom diskettes. The ERASE command does this foryou.
Removing old files makes room for new
information on a diskette. It can eliminate apotential source of confusion too-you are lesslikely to use an old version of a program or an olddata file for processing.
Butplan ahead and check your typing when you use
ERASE.

After a file is erased, the data is gone. Unless you
have made a backup, the only way to recreate a filethat has been erased is by repeating the steps thatyou took to create it in the first place.

Before You Begin
You need the diskette with the file that you wantto erase. Again, you need to know the exact
filename and extension of that file (use DIR if you
need to).
And make sure you really will not need this file.

3-41

With One Drive
For this example, assume that the file to be
removed is ASSETS.sO (the one we just used in the
RENAME example).
1.

Make sure DOS is ready with A> displayed.

2.

Insert the diskette with the file you no longer
need into drive A.

3.

Type this:erase assets.80

and check your typing. Now press Enter.

4.

In a moment, DOS shows you the prompt,
A>. The ASSETS. SO file has been removed
from the diskette.

5.

To assure that the file has been erased, try the
DIR command again, like this:dlr assets.80

and press Enter.
The message File not found and the DOS
prompt, A>, should appear.
6.

3-42

Remove the diskette and put it back into its
envelope.

~

With Two Drives
If you can use drive B, insert the diskette into
drive B, and type this for step 3:
erase b: assets.80

and this for step 5:
dir b:assets.80

Again, the only difference is that you have toremember to type the drive specifier (b:) because
it is not the default drive.

Global Filename Characters
BE CAREFUL WITH GLOBAL FILENAME
CHARACTERS.
We recommend that you DO NOT USE global
filename characters in the file specification of the
ERASE command until you are familiar withexactly what they will do.
For example, typing
erase *.*

Removes all the files from the diskette (except the
DOS system files, if present).
If the files that are removed by using global
characters are not the ones that you expected, you
can recover this information only if you havepreviously made a backup diskette.

3-43Shifting the Display on the Screen

Using the MODE Command
If you have the Color/Graphics Monitor Adapter,then you may find that the first two or threecharacters on a line of the display do not show up
on the screen. If your display does not h{ave ahorizontal adjustment control, you can use the
DOS MODE command to shift the displayed lines
to the right.

Before You Begin
You need only your DOS diskette to do this.

Shift Right
1.

Make sure that DOS is ready and A> isdisplayed (although you probably can't see it).

2.

Type this:mode ,r,t

Check your typing-did you put the space andthen the comma before the r?
When it's okay, press the Enter key.

3-44

3.

Now a test pattern will appear on your screen.

0123456789012345678901234567890123456789
Do you see the leftmost O? (YIN)

4.

If your screen looks okay, type this:yand press the Enter key.
If you want your screen moved over to theright a little more still, type this:nand press the Enter key.

3-45

Helps and Hints

Weare ending this chapter with a few hintsmaybe they will save you some trouble or help you
as you use your IBM Personal Computer.
•

Make backups regularly.
(We have repeated this already, but since thisis our last chance, we are saying it one moretime.)•

Sometimes, commands do not work as you
expected because a file specification was
typed incorrectly.
Check your typing.
Do you have the correct diskette in thedrive?
Check the directory of the diskette.
Has the correct diskette drive been
specified or is it being assumed? Has thecolon been included?
Has the filename been spelled correctly?
Have you forgotten to use the extension?
(In the case of BASIC program files, forexample, it is easy to forget the .BAS thatBASIC uses for an extension.)

•

3-46

If a command still doesn't work, refer to thepage in Chapter 6 that fully describes thecommand.

•

Be careful with global filename characters,
especially in the ERASE command. If you
insist on using them:Use the DIR command first with theglobal filename specification, to test theresults.
Check to see that these are really thefiles you want to delete.
Then, go ahead.

•

Print a directory frequently (if you have aprinter) and store the listing with the diskette.
The labels on the diskettes are usually too
small to hold everything you want to write on
them.

•

All commands (except DISKCOPY andDISKCOMP) that use files will work on bothdiskettes and fixed disks.

•

The date and time shown with each directory
entry are the date and time of the last additionor change to that file. The date and time are
not changed during a COpy or a DISKCOPY.
At first glance,
diskcopy a: b:

andcopy a:*.* b:

may appear to have the same purposecopying an entire diskette. They do, only
when copying to a diskette with no files on it.

3-47

With COPY, if files already exist on the
backup diskette, they will either be replaced(if files being copied have the same name) orleft alone. This is because COpy goes
through the original diskette, copying eachfile, one at a time. COpy does not disturb old
files on the backup diskette as long as theirnames aren't the same as files being copied.
DISKCOPY, however, makes a "carbon copy"of the original diskette, wiping out all old files
on the backup diskette during the COpy
process.

Summary

We've covered a lot in this chapter. We have told
you about:

3-48

•

Making a backup copy of your DOS diskette•

Diskettes and terms that are used with them•Finding out what files are on the DOS
diskette•

Making a backup copy of your diskettes

We have provided step-by-step procedures forusing these DOS commands:•

FORMAT•DIR•DISKCOPY

•

COpy

•

TYPE

•

RENAME

•

ERASE

•

MODE

We hope you're well on your way to feelingcomfortable with your computer and DOS. No
matter how much we've covered, there's always
more-in particular, we haven't given you ,theshortcuts that you'll start to pick up as you
continue through the Disk Operating System bookand use the commands.

3-49Notes:3-50

Notes:4-2

Introduction

If your IBM Personal Computer has a fixed disk,
there are several facts you need to know, andseveral steps to take before DOS is able to use it.
If you try to use your fixed disk before you takethe following steps, you will get the error message:
Invalid drive specification

The first section in this chapter, "Fixed Disk Drive
Letters" describes how drive letters are used withthe fixed disk. The remaining sections describe
how to prepare your fixed disk for DOS.
Note: If your fixed disk is in an expansion
uRit (not in the system unit), the expansion
unit must be turned on before you turn on thesystem unit.
A fixed disk can be divided up into separate areas
called partitions. There can be from one to four
partitions on a fixed disk. These partitions can bedifferent sizes. Each partition is set up through aFixed Disk Setup Program provided by theoperating system that will use it.
You will use the DOS Fixed Disk Setup Program
to set up the DOS partition. Fixed disk drives arereferred to in the same way you refer to diskette
drives, using the fixed disk drive specifier when
you want to read from or write to the fixed disk.

4-3

If DOS is the only operating system that you
intend to use with the fixed disk, you will want toassign all of the fixed disk space for use with DOS.
Follow the steps in "Preparing Your Fixed Disk"
to assign all of the fixed disk space to the DOS
partition.
If you do intend to use part of the fixed disk withother operating systems, then you will need todivide up the available fixed disk space among
them. Follow the steps in "Partitioning Your
Fixed Disk" to assign a specific amount of disk
space to DOS.
If you are not sure whether you will be using anyother operating system with the fixed disk, you
should go ahead and assign all of the fixed disk
space to DOS as described in "Preparing Your
Fixed Disk". If you decide later to use anotheroperating system, you can use the BACKUP
command to backup your files in your DOS
partition, reassign the DOS partition, and then use
the RESTORE command to restore your files fromdiskettes. After you have followed the instructionsin "Preparing Your Fixed Disk" or "Partitioning
Your Fixed Disk," you will need to follow the
instructions in "Setting Up the DOS Partition" inorder to make the partition you have createduseable by DOS.
The menus and screens that make up the Fixed
Disk Setup Program have been designed to makeit easy for you to set up your fixed disk. When the
Fixed Disk Setup Program asks you to entersomething, it displays a default answer for you. If
that is the answer you want, you need merely press
the Enter key. If you want to enter something else,
simply type in the entry you want and then press
the Enter key.

4-4

Fixed Disk Drive Letters
You already know that if you have two diskette
drives on your system, they are known to DOS as
A and B. If you have only one diskette drive on
your system, there are still two diskette drives (Aand B) known to DOS. But in this case, they are
simulated on the same physical drive. (If you are
not yet familiar with this concept, please refer to"Single Diskette-Drive Systems" in Chapter 1
before you continue.)
When DOS starts, it first assigns letters to all of
the diskette drives it knows about, then assigns thefollowing letters to your fixed disks. For example,
if you have one or two diskette drives, and one
fixed disk, the letters A and B apply to thediskettes, and your fixed disk is known to DOS
as C (if you had a second fixed disk, it would
become D).

4-5

Preparing Your Fixed Disk

If DOS is the only operating system that you
intend on using with your fixed disk, follow the
instructions in thissectioh. All of the fixed disk
space will be assigned for use with DOS.
If you intend to use part of the fixed disk withanother operating system, then you should go to"Partitioning Your Fixed Disk" in this chapter.
In order to prepare the fixed disk for use with
DOS, you must first use the FDISK command as
follows:
1.

With your DOS diskette in drive A and the
DOS prompt (A» on the screen, type:
FDISK

and press Enter. The following screen
appears:
IBM Personal Computer
Fixed Disk Setup Program Version 1.00
(C)Copyright IBM Corp. 1983
FDISK Options
Current Fixed Disk Drive: 1
Choose one of the following:
1.
2.
3.
4.
5.

Create DOS Partition
Change Active Partition
Delete DOS Partition
Display Partition Data
Select Next Fixed Disk Drive

Enter choice: [1)4-6The current fixed disk drive and option 5 will
only be shown if your system has more than
one fixed disk drive. If you want to set up the
DOS partition on the next drive, type:5

and press Enter. The Fixed Disk Setup
Program will allow you to create an active
partition on a fixed disk other than the first
fixed disk. However, DOS can only be started
from the first fixed disk (refer to "Changing
the Active Partition" in this chapter to change
the partition status). You will see the drive
number change on the screen after you press
Enter.
2.

Type:
1

and press Enter to set up the fixed disk for use
with DOS. If the fixed disk has not alreadybeen set up for DOS or another operating
system, then the following screen appears:
IBM Personal Computer
Fixed Disk Setup Program Version 1.00
(C) Copyright IBM Corp. 19S3
Create DOS Partition
Current Fixed Disk Drive: 1
Do you wish to use the entire fixed disk
for DOS (Y/N) .....................? [V]If your fixed disk has already been set up,then you will see a different screen that shows
how the fixed disk partitions have been
assigned, and you will get a different prompt.
If this happens, you should follow the steps in"Partitioning Your Fixed Disk" in thischapter.
4-7

3.

You should press Enter since you want to use
the entire fixed disk for DOS. The Fixed Disk
Setup Program will then assign the fixed disk
to DOS, and display the following message:
Insert DOS diskette in drive A:
Press any key when ready ...

4.

You must now restart DOS so that it willrecognize your fixed disk and assign a drive
letter to it. With your DOS diskette in driveA, press any key to restart DOS.

Your fixed disk has now been set up with a DOS
partition. But before DOS can use it, DOS needs
to create a directory and other information in thepartition. To do this, follow the instructions in"Setting Up the DOS Partition."

Setting Up the DOS Partition

The DOS fixed disk partition must be formatted
by the DOS FORMAT command before it can beused. You should only follow these instructions if
the DOS partition has been created, but has notalready been formatted and used to store data.
This is because any data in the partition will be
destroyed by the format operation.

4-8

1.

Make sure your DOS diskette is in drive A andthe DOS prompt (A» is on the screen.
If DOS is to be started from the fixed disk,
enter:FORMAT d:/S/V

If the partition is not to contain a copy of
DOS (not to be automatically started), enter:
FORMAT d:/VIn either case, substitute the correct fixed
disk drive letter for the d in the command (forexample, if you have 1 or 2 diskette drives,
you would enter C, as shown in the following
screens). This prompt now appears:
Press any key to begin formatting drive C:
2.

Press any key. The red light on your fixed disk
drive will light up, and the message:
Formatting ...

appears on the screen. Do not be alarmed if
several minutes go by before you see any
more messages. DOS is checking the data inevery location in the DOS partition and it
takes several minutes. You will see themessage:
Format complete

and, if you used /S in your FORMAT
command, you also see the message:
System transferred

4-9This tells you that a copy of DOS has beenplaced on the fixed disk.
Then the following message appears:
Volume label (11 characters, ENTER for none)?

3.

Enter a 1-11 character volume label (forexample, MYFIXEDDISK) that is used to
identify the fixed disk when DIR and
CHKDSK displays information. If you do notwant to label the fixed disk, just press Enter;however, please note that you cannot add a
volume label later, so we recommend entering
one now.
FORMAT then displays the disk spacestatistics and the DOS prompt:
A>Your fixed disk is now completely usable byDOS.
If you have placed a copy of DOS on the fixed
disk, we recommend that you do thefollowing two steps:
4.

With your DOS diskette still in drive A,
enter:
COpy *.* d:Remember to use a correct fixed disk letterfor your system. This copies all the programson the DOS diskette to your fixed disk. Oncethese programs are copied, all DOS
commands can be run from the fixed disk andyour DOS diskette can be stored away in asafe place.

4-10

Also, remember to copy the programs fromyour DOS Supplemental Program diskette in
the same manner, if you will be using these
programs.
5.

Remove the DOS diskette from drive A (leave
the diskette drive door open) and press theCtrl, Alt, and Del keys simultaneously(Systems Reset). If you have correctly
followed the steps above, and a copy of DOS
was stored in the DOS partition, DOS will
start from the fixed disk and you will be asked
to enter the date and time.
Note: Drive A must be empty (nodiskette or the diskette drive door open)
in order for this to work correctly. This isbecause the computer will first try to.
load an operating system from drive A. If
a diskette cannot be read from drive A,
then (and only then), the computer
will try to load an operating system fromthe first fixed disk on the computer.
When you have entered the date and time,
you will notice that the DOS prompt (A» has
now changed. Instead of the letter A>, youwill see the drive letter of your fixed disk.
DOS remembers which drive it was started
from, and makes that drive the default drive.
If you have followed the instructions above,
your fixed disk is now completely initialized.

4-11

Partitioning Your Fixed Disk

In order that more than one operating system canuse the fixed disk, the fixed disk must be divided
into separate areas called partitions. There can befrom one to four partitions on the fixed disk.
These partitions can be different sizes and can be
set up in any order. You can specify which
partition the system will get control of when you
start or restart your computer. An operating
system can only access one partition. You cannot
transfer data directly from one partition toanother.
Each operating system that supports the fixed disk
provides a program to allow you to create apartition for use under that system. If you try toread from, or write to, the fixed disk using asystem that has no partition assigned to it, you will
get an error message.
The DOS Fixed Disk Setup Program can only be
used to create or delete the DOS partition. A
partition set up for another operating system canonly be created or deleted from that operating
system.
You can set up one partition for use under DOS atthe location and size you choose. You can alsodelete the DOS partition if, for example, you wantto create it again at a different size or location on
the fixed disk. The following functions aresupported by the DOS Fixed Disk Setup Program:

4-12

•

Create the DOS partition.

•

Change the active partition (the one that will
be started when the system is restarted).

•

Delete the DOS partition.

•

Display fixed disk partition data.

•

Select next fixed disk drive.

These functions are described below in separate
sections. In order to get access to them, you needto start the Fixed Disk Setup Program as follows:
1.

To start, type:d~FDISKand then press Enter. Where d: is the drive
where the FDISK. COM program resides.
2.

If it is on the default drive, just type:
FDiSKand press Enter. You will then see thefollowing screen:
IBM Personal Computer
Fixed Disk Setup Program Version 1.00
(C) Copyright IBM Corp. 19S3FDISK Options
Current Fixed Disk Drive: 1

Choose one of the following:
1.
2.
3.
4.
5.

Create DOS Partition
Change Active Partition
Delete DOS Partition
Display Partition Data
Select Next Fixed Disk Drive

Enter choice: [1]4-13The current fixed disk drive and option
number 5 will be shown only if your system
has mote than one fixed disk drive. Option 5
selects the next fixed disk drive.
The Fixed Disk Setup Program will allow you
to create an active partition on a fixed diskother than the first fixed disk. However, DOS
can only be started from the first fixed disk.
The partition's status is shown as A for active
and N for not active (refer to "Changing the
Active Partition" in this chapter to change thepartition status).
Type the number of the option you want andpress the Enter key. Note that option 1 is thedefault and will automatically be selected if
you don't type an option number before
pressing Enter. Proceed to the section belowthat describes the option you selected.

4-14Creating the DOS Partition (Option 1)
You can use this option to create the DOS
partition. In order to do so, you need to determine
where it should be located and how large it shouldbe. If there is already a partition assigned to DOS,
you will see an error message.
A fixed disk is divided into parts called cylinders.
The number of cylinders and their sizes can varydepending on the fixed disk. A 10-megabyte disk
contains 305 cylinders and each cylinder contains
34,816 bytes or characters of information. If you
wanted to assign the whole fixed disk for use underDOS, you would specify the size as 305 cylinders
and the starting cylinder number as 000.

The screen you see depends on whether the fixed
disk has any partitions. If it has been initialized, go
to step 2. If not, the following screen appears:
IBM Personal Computer
Fixed Disk Setup Program Version 1.00
(C) Copyright IBM Corp. 1983
Create DOS Partition
Current Fixed Disk Drive:

Do you wish to use the entire fixed
disk for DOS (Y/N) .............................? [V)

4-15

1.

If DOS is the only operating system that you
intend on using with the fixed disk, then you
should follow the instructions in "Preparing
Your Fixed Disk" in this chapter. Otherwise,
type:n

and then press the Enter key. The following
message appears:
Total fixed disk space is xxxx cylinders.
Maximum available space is xxxx.
cylinders at cylinder xxxx.

These lines show the total number ofcylinders on your fixed disk. Proceed tostep 3.
2.

You will see a screen similar to the following
if your fixed disk has already been set up:
IBM Personal Computer
Fixed Disk Setup Program Version 1.00
(C)Copyrlght IBM Corp. 1983
Create DOS Partition
Current Fixed Disk Drive:

Partition
1
2
3

Status

N

A
N

Type
non-DOS
non-DOS
non-DOSTotallixed disk space is 305 cyls.
Max avail space is 150 cyls at cyl 100.

4-16

Start
000
050
250

End
049
099
304

Size
50
50
55

The "Create DOS Partition" screen shows asample fixed disk with 3 partitions. Note that
this is not necessarily a recommended setup.
I t is shown only as an example.
The line with the current fixed disk drive will
only appear if you have more than one fixed
disk drive.
There will be one line shown for eachassigned partition.
The Partition column shows the relative
number of the partition (in the order it
appears on the fixed disk).
The status column shows which partition's
system gets control when the system unit isstarted from the fixed disk. That partition's
status is shown as A (for active), the others areshown as N (for not active).
The Type column shows which partition, if
any, is the DOS partition.
The Start and End columns show the startingand ending cylinder numbers for a partition
and the Size column shows its size incylinders.
The next line shows you the total amount of
space on the fixed disk, and the line after thatshows you the size of the largest available
space that you could use for a partition andwhere it is located on the fixed disk.

4-17

3.

The following prompt appears:
Enter partition size............ : [xxxx]

The partition size entry defaults to the largest
available space on the fixed disk. If you wantyour DOS partition to use the largest
available space, simply press the Enter key.
Otherwise, type in the size you want (incylinders) and press the Enter key. The next
prompt is:Enter starting cylinder number..: [xxxx]

4.

The starting cylinder number default depends
on the partition size you specified above. It is
the first cylinder of the largest space on the
fixed disk large enough for the partition. If
you want the DOS partition to be locatedthere, press the Enter key. Otherwise, type inthe starting cylinder number you prefer andpress the Enter key. The cursor is placed at
the bottom of the screen and you see thismessage:
Press Esc to return to FDiSK Option [ ]Note that the lines on the screen change toshow the new active partition. The DOS
partition has now been created. With yourDOS diskette in drive A, press the Ctrl, Alt,and Del keys simultaneously (System Reset).
If you need the partition you just created tobe active (startable), follow the steps in"Changing Active Partition (Option 2)."Your DOS partition has been created but you
still need to follow the instructions in "Setting
Up the DOS Partition" in this chapter before
you can use the DOS partition.
4-18

Changing the Active Partition (Option 2)
Select this option when you want to start adifferent operating system in another partition.
You will see a screen similar to the following:
IBM Personal Computer
Fixed Disk Setup Program Version 1.00
(C)Copyright IBM Corp. 1983
Change Active Partition
Current Fixed Disk Drive: 1
Press Esc to return to Utility Options
Partition
1
2

3

StatusN
N
A

Type
non-DOS
non-DOS
DOS

Start
000
050
150

End
049
149
304

Size
50
100
155

Total disk space is xxxx cylinders.
Enter the number of the partition you wantto make active....................... : ( ]1.

Enter the number of the partition whose
operating system you want to get control
when the system is started from the fixed
disk. The following message appears:
Press Esc to return to FDISI Options ( ]Note that the lines on the screen change toshow the new active partition.
2.

Press the Esc key to return to the FDISK
options menu and press it again to return to
DOS.

4-19

If you want to start the operating system inthe partition you just made active, performthe following steps:a.

Open the diskette drive A door.

h.

Press and hold Ctrl and Alt, and thenpress Del.

The operating system in the active partition
should then start.

Deleting the DOS Partition (Option 3)
Note: This option destroys all data in the
DOS partition so make sure you have backed
up all of your files before you proceed.
1.

You will need to insert a DOS diskette andrestart the system from diskette drive A if you
want to continue processing under DOS.
If you want to start a system in another fixed
disk partition, you should change the active
partition to that partition number before you
delete the DOS partition.

4-20

You will see a screen similar to the following:
IBM Personal Computer
Fixed Disk Setup Program Version 1.00
(C)Copyright IBM Corp. 19S3
Delete DOS Partition
Current Fixed Disk Drive: 1

Partition
1
2

3
4

Status
N
N
N
A

Type
non-DOS
non-DOSDOS
non-DOS

Start End000 049050 099
100 249
250 304

Size
50
50
150
55

Total fixed disk space is xxxx cylinders

Warning! All data in the DOS partition
will be DESTROYED. Do you wish tocontinue................................... ? [ ]2.

If you have backed up all of your files and areready to continue, type Y and press Enter. If
you decide to cancel the operation, press
either the Enter key or the Esc key to returnto the FDISK options menu.
If you type Y and press Enter, the partition
information displayed on the screen is
updated, and the following message appears:
Press Esc to return to FDISK Options [ ]The DOS partition has now been deleted. You
will need to start another system from thefixed disk or restart DOS from a diskette toproceed.

4-21

Displaying Partition Data (Option 4)
You can use this option to display fixed disk status
information. Your screen appears similar to thefollowing:
IBM Personal Computer
Fixed Disk Setup Program Version 1.00
(C) Copyright IBM Corp. 19S3
Display Partition Information
Current Fixed Disk Drive: 1

Partition

Status

1

A

2

N

Type
DOS
non-DOS

Start End000 199
200 304

Size
200
105

Total fixed disk space is xxxx cylinders

The line with the current fixed disk drive appears
only if you have more than one fixed disk drive.
One line is shown for each assigned partition.
The Partition column shows the relative numberof the partition (in the order it appears on the
fixed disk).
The Status column shows which partition's systemgets control when the system unit is started fromthe fixed disk. That partition's status is shown as A(for active), the others are shown as N
(non-active).
The Type column shows which partition, if any, isthe DOS partition.

4-22

The Start and End columns show the starting andending cylinder numbers for a partition, and theSize column shows its size in cylinders.
The next line shows you the total amount of spaceon the fixed disk.
Press the Esc key when you are ready to return to
the FDISK options menu.

Selecting Next Fixed Disk Drive(Option 5)
Select this option when you want to use the DOS
Fixed Disk Setup Program with the next fixed disk
drive.
After you have entered the option, you see thecurrent fixed disk drive number change on the
FDISK options menu.
This option is available only if your system has
more than one fixed disk drive.

4-23

Notes:4-24

Notes:5-2

Introduction

Prior to Version 2.00, DOS used a simple directory
structure that was adequate for managing files on
diskettes. Each diskette contained a single
directory that could hold a maximum of 64 or 112
files, depending on whether the diskette was single
or dual sided.
With the added support for fixed disks in DOS
Version 2.00, however, a single fixed disk can holdliterally thousands of files. Keeping a large numberof files in one directory becomes inefficient for
both you and DOS (the larger a directory is, thelonger it can take DOS to search for a file).
DOS Version 2.00 gives you the ability to betterorganize your disk by placing groups of related
files in their own directories-all on the same disk
(fixed disk or diskette).

5-3For example, let's assume that the XYZ company
has two departments (sales and accounting) thatshare an IBM Personal Computer. All of thecompany's files are kept on the computer's flxed
disk. The logical organization of the file categories
could be viewed like this:Disk

Acctng

Sales

/\
T

~

David

JoanneDon

Reports

Reports

T

Customer.lst

Reports

Karol

Reports
Accounts.rec

With DOS Version 2.00, it is possible to create a
directory structure that matches the fileorganization. With this ability, all of DAVID's
report files can be grouped together in a single
directory (called REPORTS), separated from all
the other files on the disk. Likewise, all of theaccounts receivable files can be in a unique
directory, and so on.

5-4

Directory Types

As in previous versions of DOS, a single directoryis created on each disk when you FORMAT it.
That directory is called the root directory, or
system directory.
A root directory on diskette can hold either 64 or
112 files-the maximum number of files in a fixed
disk root directory depends on the size of the DOS
partition on the disk.
In addition to containing the names of files, theroot directory can also contain the names of otherdirectories; and these in turn can contain thenames of other files and directories; and so on.
Unlike the root directory, these other directories
called sub-directories are actually files, and are
therefore not restricted in size-- they can containany number of files and sub-directories, limited
only by the amount of available space on the disk.
The sub-directory names are in the same format asfilenames-a name of 1-to-8 characters optionallyfollowed by a period and an extension of 1-to-3
characters. All characters that are valid for afilename are also valid for a directory name. Eachdirectory can contain file and directory names that
also appear in other directories. In other words,
two or more files or directories can have the same
name, as long as they are defined in separate
directories.

5-5

The Current Directory

Just as DOS remembers a default drive, it can also
remember a default directory for each drive on
your system. This is called the current directory, andis the directory that DOS will search if you enter afilename without telling DOS which directory thefile is in. You can change the current directory orfind out what your current directory is for any
drive by issuing the CHDIR command ( describedin Chapter 6). When DOS is started, it willautomatically use the root directory as the current
directory for each drive until you issue a CHDIR
command.

5-6

Specifying the Path To a File

When you want DOS to create or search for a file,
DOS must know three things- the drive, the nameof the file, and the name of the directory
containing the file.
If the file is in the current directory, you don't
need to specify a directory- DOS willautomatically look in the current directory.
But if the file is not in the current directory, youmust supply DOS with the path of directory names
leading to the desired directory. The path you
specify can be either the path of names startingwith the root directory, or the path from thecurrent directory.
The path consists of a series of directory names
separated by backslashes (\). If a filename isincluded, it must also be separated from the last
directory name by a backslash.
If a path begins with a backslash, DOS starts its
search from the root directory; otherwise, thesearch begins at the current directory.

5-7

For example, if the current directory is DAVID,
and you want to find file ANNUAL. FIG in
DAVID's REPORTS directory, you can specify it
in either of these ways:\SALES\OAVIO\REPORTS\ANNUAL.FIG

or
REPORTS\ANNUAL FIG

In the first case, the full path from the root
directory (leading backslash) was specified. In thesecond case (no leading backslash), the path fromthe current directory was given.
Each sub-directory contains two special entriesyou'll see them listed when you use the DIR
command to list a sub-directory. The first contains
a single period instead of a filename-it identifies
this "file" as a sub-directory. The second entry
contains two periods instead of a filename, and isused by DOS to locate the higher level directorythat defines this directory, the parent of thisdirectory. For example, in the file organization
illustration shown on the first page of this chapter,the parent of the directory named JOANNE is the
one named SALES.
.

5-8

This second special entry can be quite useful when
you specify a path to DOS, because entering two
periods is a shorthand way of telling DOS to backup one directory level. For example, if the current
directory is DAVID, and you want to find file
SUMMARY in]OANNE's REPORTS directory,
you can specify it in either of these ways:\SALES\JOANNE\REPORTS\SUMMARYor..\ JOANNE\REPORTS\SUMMARY

The second case causes DOS to backup one levelfrom the current directory (to the current
directory's parent), and to continue the path fromthere. The double period can be used more thanonce in a path-it simply causes DOS to back up
one level each time it is specified.
You can specify which drive to use by including adrive specifier ahead of the path and filename
string. For example:
B: \LEVELl \ MYFILE

Notice that when defining a path, the drive is
specified ahead of the path, rather than thefilename.

5-9

Nearly all of the DOS commands that accept
filenames also accept path names. For example, if
you enter:
DIH \ACCTNG\KAHOL\HEPOHTS

all of the files in KAROL's REPORTS directory
are listed. Similarly, if you enter:
DEL \ACCTNG\KAHOL\HEPORTS

DOS assumes you want to erase all the files in
KAROL's REPORT directory.
In all cases, to refer to a specific file, simply add
the filename to the end of the path (separated
from the path by a backslash, of course).
To refer to the root directory (if the root is not thecurrent directory), enter one backslash. For
example, if the current directory is DAVID,
issuing:
DlH\

will list all the files in the root directory.
You can create as many sub-directories as you
wish. However, you should ensure that the longest
path you create (from the root to the last directory
in a single path) can be expressed in 63 charactersor less.

5-10

Directory Commands

The following commands are new in DOS Version
2.00, and are included to help you create andmanage your directory structure. A brief
explanation of each is presented here-for moredetailed information, please refer to the individualcommand descriptions in Chapter 6.
System programmers and application developers
should also refer to the technical appendixes (inSection 2) for descriptions of the DOS function
calls.

Creating a Sub-Directory
The MKDIR (MD) command is used to create new
directories. Be sure to include the appropriate
drive and path, ending with the name of the new
directory you want created. Also, be sure that thefull path from the root to the new directory nameis 63 characters or less.

5-11

Deleting a Directory
Directories can be deleted (removed) only with the
RMDIR (RD) command. They cannot be deletedwith the ERASE or DEL commands. A dir-ectory
can be removed only if it is empty-that is, it has nofiles or sub-directories other than the two special
entries shown as. and .. in the DIR command
display. The last directory name in the specified
path is removed-only one directory at a time canbe deleted. The root directory and the current
directory cannot be deleted. Entering CHDIR or
CD with no parameters (or only a drive
specification) causes DOS to display the current
directory for the drive.

Displaying and Changing theCurren t Directory
The CHDIR (CD) command is used to tell DOS
which directory path it should "remember" as thecurrent directory. Enter just a backslash for theroot, or a full path for any other directory. The
current directory is where DOS will look to findfiles whose names are entered without path
specifiers.

Displaying the Directory Structure
The TREE command will produce a report
describing the entire directory structure of a disk.
Included in the report are all directory paths and,optionally, the names of all files in eachsub-directory.

5-12

Where DOS Looks for Commands
and Batch Files

When you enter a command, DOS searches thecurrent directory for it (if the command is not
built-in). The PATH command allows you to
specify a series of additional paths that DOS cansearch if it does not find the command in thecurrent directory. The PATH command is
described in Chapter 6.

5-13

Notes:5-14

Chapter 6. DOS Commands

Contents
Introduction ............................

6-5

Types of DOS Commands ...............

6-6

Format Notation .......................

6-8

DOS Command Parameters .............
Reserved Device Names .............
Global Filename Characters ..........
The? Character ............. . . . .
The * Character ................
Examples of Ways to Use? and * ........................

6-9
6-1 3
6-14
6-14
6-15

Detailed Description of the
DOS Commands .......................
Information Common to All DOS
Commands ............. ~ . .. . . . . . . .

6-16
6-1 7
6-17

ASSIGN (Drive) Command ............... 6-21
BACKUP (Fixed Disk) Command .......

6-24

6-1

6-2

Batch Commands .......................
TheAUTOEXEC.BATFile .. ........
Creating a .BAT File with
Replaceable Parameters ............
Executing a . BAT File with
Replaceable Parameters ............
ECHO Subcommand ................
FOR Subcommand ..................
GOTO Subcommand ................
IF Subcommand ....................
SHIFT Subcommand................
PAUSE Subcommand ...............
REM (Remark) Subcommand ........

6-28
6-31

6- 34
6-35
6- 37
6- 38
6-40
6-45
6-47
6-49

BREAK (Control Break) Command ......

6-50

CHDIR (Change Directory) Command ...

6-52

CHKDSK (Check Disk) Command ......

6-54

CLS (Clear Screen) Command ...........

6-58

COMP (Compare Files) Command .......

6-59

COpy Command

6-65

DATE Command

6-80

DEL Command .........................

6-82

DIR (Directory) Command ..............

6-83

DISKCOMP (Compare Diskette)
Command .............................

6-90

DISKCOPY (Copy Diskette)
Command .............................

6-94

6- 32

ERASE Command ......................

6-98

FORMAT Command .................... 6-100
GRAPHICS (Screen Print) Command

6-106

MKDIR (Make Directory) Command

6-107

MODE Command .....................

6-109

PATH (Set Search Directory)
Command ............................

6-117

PRINT Command .....................

6-120

RECOVER Command..................

6-126

RENAME (or REN) Command..........

6-129

RESTORE (Fixed Disk) Command

6-131

RMDIR (Remove Directory)
Command ............................. 6-134
SYS (System) Command ................. 6-135
TIME Command ........................ 6-136
TREE (Display Directory) Command .... 6-138
TYPE Command. . . . . . . . . . . . . . . . . . . . . . .. 6-141
VER (Version) Command ............... 6-143
VERIFY Command ..................... 6-144
VOL (Volume) Command ............... 6-145
Summary of DOS Commands ........... 6-146

6-3

Notes:6-4

Introduction

This chapter explains how to use the DOS
commands. You can use DOS commands to:•Compare, copy, display, erase, rename files,
and format fixed disks and diskettes.

•

Execute system programs, such as EDLIN and
DEBUG, plus your own programs.

•

Set various printer and screen options.

•

Request DOS to pause.

•

Transfer DOS to another diskette.

•

Set options for the Asynchronous
Communications Adapter.

•

Cause printer output to be directed to the
Asynchronous Communications Adapter.

•

Recover a specific file from a damaged disk,
or recover the entire disk or diskette.

•

Print the contents of a graphics display screen
on a printer.

•

Print files on the printer while the system isdoing other work.

•

Backup and restore files on a fixed disk.

6-5

Types of DOS Commands

There are two types of DOS commands.
•

Internal•

External

Internal commands execute immediately because
they are built-in to DOS.
External commands reside on disk as program
files; therefore, they must be read from disk before
they execute. This means that the disk containing
the command must already be in a drive, or DOS isunable to find the command. For example, if you
entered the command:
B:GRAPHICS

you must be sure that the diskette containing
GRAPHICS.COM is in drive B. If you entered:
GRAPHICS

then DOS will look on the default drive (the one inyour system prompt) for the GRAPHICS
command.

6-6

Any file with a filename extension of .COM or.EXE is considered an external command. This
allows you to develop your own unique commands
and add them to the system. (For example,
programs such as FORMAT.COM and
COMP.COM are external commands.)
When you select an external command, do notinclude the filename extension.
For Application Developers: DOS Version 2.00
has a provision that allows you to cause executionof DOS commands from within your application.
Please refer to Appendix F for details.

6-7Format Notation

We will use the following notation to indicate how
the DOS commands should be entered:•

You must enter any words shown in capitalletters. These words are called keywords andmust be entered exactly as shown. You can,however, enter keywords in any combinationof uppercase and lowercase letters. DOS
automatically converts keywords to uppercase.

•

You must supply any items shown inlowercase italic letters. For example, you
should enter the name of your file whenfilename is shown in the format.

•

Items in square brackets ([ ]) are optional. If
you want to include optional information, you
do not need to type the brackets, only the
information inside the brackets.

•

Items separated by a bar ( ) mean that you canenter one of the separated items. For
example:ON

I OFF

Means you can enter ON or OFF, but not
both.

6-8

•

An ellipsis ( ... ) indicates that you can repeat
an item as many times as you want.

•

You must include all punctuation (except
square brackets and vertical bars) such ascommas, equal signs, question marks, colons,slashes, or backslashes where shown.

DOS Command Parameters

Parameters are items that you can include in yourDOS command statements. They are used to
specify additional information to the system. Someparameters are required in your commands, others
are optional. If you do not include someparameters, the system provides a default value.
Default values that the system provides are
discussed in the detailed descriptions of the DOS
commands.
Use the following parameters in your DOS
command statements:
Parameter

Definitiond:Denotes when you should specify a drive.
Enter a drive letter followed by a colon to
specify the drive. For example, A
represents the first drive on yoursystem, B represents the second. If youomit this parameter, DOS assumes thedefault drive.

6-9

Parameter

Definitionpath[\] [dirname] [\ dirname[ ... ]]Denotes a path of directory names. Enterthe directory names, separated bybackslash characters. If a filename is also
to be appended, it should be separated
from the last directory name by abackslash. For example:\DIR1\DIR2\FILEl

The first backslash is optional. If used, it
tells DOS to begin with the root directory.
If omitted, the directory path is assumed
to begin with the current directory. Global
filename characters are not allowed inpath specifications. The longest pathallowed by DOS (from root directory to
the last level) is 63 characters.

6-10

Parameter

Definition

filename

Diskette filenames are 1-8 characters inlength and can be followed by a filename
extension.
The following characters can be used forfilenames:
A-Z 0-9 $ & # @!

%"o-{}-1\.--

Any other characters are invalid. An
invalid character is assumed to be adelimiter, in which case the filename istruncated.
Refer also to "Reserved Device Names"in this chapter for more information
about filenames.

6-11

Parameter

Definition. ext

The optional filename extension consistsof a period and 1- 3 characters. Whenused, filename extensions immediately
follow filenames.
The following characters can be used forfilename extensions:
A-Z 0-9 $&#@!

%"o-{}-/\.Any other characters are invalid.
Remember to include the extension
when you refer to a file that has afilename extension; otherwise, DOS will
be unable to locate the file.

filespec[d: l/ilename[ .ext]
Examples:B:myprog.COB
A:yourprog
DATAFILE.pas
coblile6-12

Reserved Device Names
Certain names have special meaning to DOS. DOS
reserves the following names as system devices:

Reserved Name

DeviceCON

Console keyboard/screen. If used as an
input device, you can press the F6 key;then press the Enter key to generate an
end-of-file indication, which ends
CON as an input device.

AUX
or
COMl

First Asynchronous Communications
Adapter port.

COM2

Second Asynchronous Communications
Adapter port.

LPTl
or
PRN

First Parallel Printer (as an output
device only).

LPT2
or
LPT3

Second Parallel Printer

NUL

Third Parallel PrinterNonexistent (dummy) device fortesting applications. As an input
device, immediate end-of-file isgenerated. As an output device, thewrite operations are simulated, but nodata is actually written.

6-13Notes:1.

When using a device name, you should
assure that the device actually exists;
using the name of a nonexistent device
can cause unpredictable errors in DOS
operation.

2.

The reserved device names can be used inplace of a filename.

3.

Any drive specifier or filename extension
entered with these device names will beignored.

Global Filename Characters
Two special characters? and * can be used within afilename and its extension. These special
characters give you greater flexibility with the
DOS commands.

The ? Character
A ? in a filename or in a filename extension
indicates that any character can occupy that
position. For example,
DIR AB?DE.XYZ

lists all directory entries on the default drive withfilenames that have five characters, begin with AB,
have any next character, are followed by DE, andhave an extension of XYZ.

6-14

Here are some examples of the files that might belisted by the DIR command:
ABCDE IYZABIDE IYZ
ABODE IYZThe * CharacterAn * in a filename or in a filename extension
indicates that any character can occupy that
position and all the remaining positions in thefilename or extension. For example,
DIR AB*.XYZ

lists all directory entries on the default drive withfilenames that begin with AB and have an
extension ofXYZ. In this case, the filenames may
be from 2-8 characters in length.
Here are some example files that might be listedby the DIR command:
ABCDE
ABC357
ABIDE
ABnOU
ABO$$$
AB

XYZ
XYZ
XYZ
IYZ
XYZ
XYZ

6-15

Examples of Ways to Use? and *Example 1
To list the directory entries for all files named
INPUT on drive A (regardless of their filename
extension), enter:
OIR A:INPUT.???

orOIR A:INPUT.*

Example 2
To list the directory entries for all files on drive A(regardless of their filenames) with a filename
extension of XYZ, enter:
OIR A:????????XYZorOIR A:*.XYZExample 3
To list the directory entries for all files on drive A
with filenames beginning with ABC and extensions
beginning with E, enter:
OIR A:ABc?????E??

or
OIR A:ABc*.E*

6-16

Detailed Descriptions of the DOS
Commands

This section presents a detailed description of how
to use the DOS commands. The commands appear
in alphabetical order; each with its purpose,
format, and type. Examples are provided whereappropriate.

Information Common to All DOS
Commands
The following information applies to all DOS
commands:•

The normal prompt from the commandprocessor is the default drive letter plus>,
such as A> unless changed by the PROMPT
command.

•

When a command completes, the systemprompt will reappear on the screen. If noerror messages are displayed before thesystem prompt reappears, the command has
been successfully completed.

•

Commands are usually followed by one ormore parameters.

•

Commands and parameters may be entered inuppercase or lowercase, or a combination of
both.

6-17

•

DOS will search the current directory of thespecified or default drive to find a commandor batch file whose name you have entered. If
not found, DOS will continue its search ineach of the directories listed in the PATH
command.

•

Most commands allowing you to enter
filenames will also accept a path (directory)
name ahead of the filename. If you do notplan to create directories of your own, you
may disregard all references to path names.
This will greatly simplify the command syntax
for you.

•

Commands and parameters must be separated
by delimiters (space, comma, semicolon,
equal sign, or the tab key). The delimiters canbe different within one command. For
example, you could enter:
COpy oldfile.rel;newfile.rel
RENAM E, thi.file thatfile

6-18

•

The three parts of filespec (d: filename. ext)
must not be separated by delimiters. The
colon (:) and period (.) already serve asdelimiters.

•

In this book, we usually use a space as thedelimiter in the commands for readability.

•

Also in this book, when we say" Press any key, "we mean "Press any character key."•

Files are not required to have filename
extensions when you create or rename them;
however, you must include the filename
extension when referring to a file that has afilename extension.

•You can end commands while they arerunning by pressing Ctrl-Break. Ctrl-Break isrecognized only while the system is readingfrom the keyboard or printing characters on
the screen, unless you have used BREAK=ON
in your configuration file or have issued a
BREAK=ON command. Thus, the command
may not end immediately when you press
Ctrl-Break.

•Commands become effective only after youpress the Enter key.

•

Global filename characters and device names
are not allowed in a command name. You may
only use them in command parameters.

•

For commands displaying a large amount of
output, you can press Ctrl-Num Lock tosuspend the display of the output. You canthen press any character key to continue thedisplay.

•

You can use the control keys and the DOS
editing keys described in Chapter 3 while
en tering DOS commands.

•

Drives will be referred to as source drives andtorget drives. A source drive is the drive you
will be transferring information/rom. A target
drive is the drive you will be transferring
information to.

•

When an external command is entered, DOS
first looks for it in the current directory of thedefault or specified drive. If not found, DOS
continues searching for it in the directories
listed in the most recen t PATH command.

6-19

•

If the characters <, >, or : appear anywhere in
the command line you enter, DOS will act
upon them as described in "Redirection ofStandard Input and Output" and "Piping ofStandard Input and Output Device" in
Chapter 10. Thus, the command:
REM this is a : test

would pipe the output of the REM command(none) to a program named "test". If the
program "test" does not exist, this message
appears:
Bad command or filename

6-20

ASSIGN (Drive)
CommandPurpose:Instructs DOS to use a different drive from theone that was specified for disk operations.

Format:ASSIGN [x=y [ ... ]]Type:

Internal

External***
Remarks:

Use this command to tell DOS to route all
requests for a disk drive to a different drive.
The first drive letter x is internally converted by
DOS to the second drive letter y. This command
does not require you to enter a colon after thedrive letter. Entering ASSIGN with noparameters causes all drive reassignments to bereset so that normal drive assignments will
resume.

6-21

ASSIGN (Drive)
Command

Example: This example causes DOS to route all requests
for drive A to drive C. Thus, if you issue Olft A:,
DOS will display the directory that is on physicaldrive C:ASSIGN A=C

In this example, any requests for drive A or
drive B are routed by DOS to drive C:
ASSIGN A=C B=C

The command:
ASSIGN

will undo the reassignment so that requests fordrive A will again go to physical drive A, etc.
Note: This command has been included toassist you with applications that were
designed to perform their disk operations
specifically on drives A and B (those
applications that do not allow you to
specify a drive). By using a commandsuch as:ASSIGN A=C B=C

those applications can be made to use
drives other than A and B, such as a fixed
disk.

6-22

ASSIGN (Drive)
CommandReassignment of drives should only be used
when necessary for these cases. It should
never be used with the PRINT command orwhen running DOS in normal operations,because it can hide the true device type fromcommands and programs that require actual
drive information. Also note thatDISKCOPY and DISKCOMP will ignore
any drive reassignments.
If you will be developing an application
program, we recommend that you avoid
using specific drive assignments within yourprogram, but instead, allow the user tospecify the drive(s) to be used.

6-23

BACKUP (Fixed Disk)
CommandPurpose:Backs up one or more files from a fixed disk to
diskettes.

FormatBACKUP [d.'] [path] [/llename] [.ext]
d: [IS] [1M] [I A] [lD:mm-dd-yy]

Type:Internal

External***
Remarks:

Use DOS formatted diskettes only. The firstparameter you specify is the fixed disk file youwant to back up. The second p~.I:ameter is the
backup diskette drive. Files are backed up fromthe current directory if you do not specify apath. If you do not specify a filename orextension, then all files in the directory will bebacked up.
Global filename characters are allowed in thefilename. They cause all files matching thefilename to be backed up onto diskettes. For
example, entering:BACKUP C:* .DAT A:

Causes each file from the current directory of
fixed disk drive C that has an extension of . DAT
to be backed up onto the diskette in drive A.

6-24

BACKUP (Fixed Disk)
Command

The parameter IS causes the files in all
sub-directories to be backed up in addition to
the files in the specified directory itself. This
includes sub-directories at all levels beyond thespecified directory.
The parameter 1M indicates that only files thathave been modified since the last backup should
be backed up. Use this parameter to avoid
backing up files that never change. The
BACKUP command can tell which files havebeen changed because of an indicator in eachfile's directory entry that is set by DOS
whenever the file is written to.
The parameter I A indicates that backed up files
should be added to the files on the backup
diskette already in the specified drive. If thisparameter is omitted, then you will be prompted, to insert a diskette when the backup program isloaded.
The parameter ID can be used to back up files
written only on or after the specified date. See
the description of the DATE command for valid
date formats.
The following example backs up all of the files
on fixed disk drive C:
BACKUP C:\ A: /S

6-25

BACKUP (Fixed Disk)
Command

The next example backs up three different files
from the default fixed disk drive onto the same
set of backup diskettes:
BACKUP levell \filel.dat A:
BACKUP levell\leveI2\file2.dat A: /A
BACKUP level1\leveI3\file3.dat A: /A

The next example backs up all files in thecurrent directory that have changed since thelast backup:
BACKUP *.* A: 1M

After you enter the BACKUP command, youwill be prompted to insert a diskette (unless you
specified the fA parameter). Use DOS formatted
diskettes only. BACKUP will erase existing files
on the diskette before it starts backing up thefixed disk file, unless you have used the fAparameter. After BACKUP fills up a diskette, itwill prompt you to insert a new diskette. You
should label each diskette and record the dateand diskette number.

6-26

BACKUP (Fixed Disk)
CommandBACKUP displays the name of each file as it
backs it up. If you want a printed copy of thislist, you can use redirection of output to theprinter. Refer to "Redirection of Standard Input
and Output Devices" in Chapter 10 for
additional information.
The BACKUP command sets the exit code as
follows:oNormal completion1

No files were found to backup

3

Terminated by user (Ctrl-Break)4

Terminated due to error

These codes can be used with the batchprocessing IF subcommand.
Note: The files on the backup diskettes
are unusable in normal processing andshould only be used by the RESTORE
command.

6-27

BatchCommands

Purpose:

Executes the commands contained in thespecified file from the current directory of thedesignated or default drive. If the batch file is
not found in the current directory, DOS
searches for it in the directories listed in the
PATH command.

Format:[d:1filename [parameters]

Type:Internal

External***
Remarks: A batch file is a file containing one or morecommands that DOS executes one at a time. Allbatch files must have a filename extension of.BAT.
You can pass parameters to thefilename.BAT filewhen the file executes. Therefore, the file cando similar work with different data during each
execution.

6-28

BatchCommands

You create a batch file by using the Line Editor(EDLIN), or by using the COpy commanddirectly from the keyboard.
Notes:
1.

Do not enter the name BATCH (unlessthe name of the file you want toexecute is BATCH.BAT).

2.

Only the filename must be entered to
run the batch file. Do not enter an
extension.

3.

The commands in the file named
filename.BAT are executed.

4.

There are seven sub commands that canbe used to control batch processing:
ECHO, FOR, GOTO, IF, SHIFT,
PAUSE, and REM. They are explainedin the following pages.

5.

If you press Ctrl-Break while in batch
mode, this prompt appears:
Terminate batch job (Y/N)?

I f you press Y, the remainder of thecommands in the batch file are ignored
and the system prompt appears.

6-29

BatchCommands

If you press N, only the current
command ends and batch processing
continues with the next command in
the file.

6-30

6.

If you remove a diskette containing abatch file being processed, DOS
prompts you to insert it again before
the next command can be read.

7.

The last command in a batch file may
be the name of another batch file. This
allows you to invoke one batch filefrom another when the first is finished.

8.

DOS will remember which directory yourbatch file was started from. Therefore,
the commands within the batch file
may change the current directory atwill, and the batch file will continue
executing.

BatchCommands

The AUTOEXEC.BAT File
The AUTOEXEC.BAT file is a special batch file.
When you start or restart DOS, the commandprocessor searches for the AUTOEXEC.BAT file.
If this file is present in the root directory of thedrive DOS was started from, DOS automatically
executes the file whenever you start DOS.
For example, if you want to automatically load
BASIC and run a program called MENU, create an
AUTOEXEC.BA T file as follows:1.

Enter:
COpy CON: AUTO EXEC. BATThis statement tells DOS to copy the
information from the console (keyboard) into
the AUTOEXEC.BAT file on the default
drive.
2.

Now, enter:
BASIC MENU

and press Enter.
This statement goes into the
AUTOEXEC.BAT file. It tells DOS to load
BASIC and to run the MENU program
whenever DOS is started.

6-31

BatchCommands

3.

Press the F6 key, then press the Enter key toend copying from the keyboard to the file.
The MENU program will now run
automatically whenever you start DOS.

To run your own BASIC program, enter the nameof your program in place of MENU in the secondline of the example. Remember, you can enter any
DOS command, or series of commands, in the
AUTOEXEC.BAT file.
Note: If you use AUTOEXEC.BAT, DOS
does not prompt you for the current date andtime unless you include DATE and TIME
commands in the AUTOEXEC.BAT file.

Creating a .BAT File With Replaceable
Parameters
Within a batch file you may include dummyparameters that can be replaced by values supplied
when the batch file executes.
For example, enter:
A>Copy con: ASMFILE.BAT
Copy °/ol.MAC °/02.MAC
Type °/02.PRN
Type °/oO.BAT

Press Enter after entering each line.

6-32

BatchCommands

Now, press F6; then press Enter.
The system responds with this message:
1 File(s) copiedA>_
The file ASMFILE.BA T, which consists of threecommands, now resides on the diskette in thedefault drive.
The dummy parameters %0, % 1, and %2 are
replaced sequentially by the parameters you supply
when you execute the file. The dummy parameter%0 is always replaced by the drive designator, if
specified, and the filename of the batch file.
Notes:
1.

Up to 10 dummy parameters (%0 - %9)
can be specified within a batch file, morethan 10 parameters can be specified on acommand line (see SHIFT subcommand).

2.

If you want to use % as part of a filename
witbin a batch file, you must specify it
twice. For example, to specify the file
ABC%.EXE you must enter it as
ABC%%.EXE in the batch file.

6-33

BatchCommands

Executing a .BAT File With
Replaceable Parameters
To execute the ASMFILE.BAT file and passparameters, enter the batch filename followed by
the parameters you want sequentially substituted
for %1, %2, etc.
For example, you can enter:
ASMFILE A:PROGl B:PROG2ASMFILE is substituted for %0, A:PROGI for %1,
and B:PROG2 for %2.
The result is the same as if you entered each of thethree commands (in the ASMFILE.BAT file) fromthe console with their parameters, as follows:
Copy A: PROG1. MAC B: PROG2. MAC
Type B: PROG2. PRN
Type ASMFILE.BAT

Remember that the dummy parameter %0 isalways replaced by the drive designator, if
specified, and the filename of the batch file.

6-34

BatchCommands

ECHO Subcommand
Purpose:The ECHO batch processing subcommand
allows or inhibits the screen display of DOS
commands executed from a batch file. It does
not interfere with messages produced while thecommands are executing.

Format:ECHO [ON IOFF Imessage]

Type:

Internal***

External

Remarks: Batch commands are normally displayed on thescreen as they are read from the batch file.
ECHO is ON after power-on or system reset.
ECHO ON displays all the commands on thescreen as they are executed. ECHO OFF stops
the display of commands on the screen(including the REM command).
Echo message displays message on the screen
regardless of the current ON or OFF state. In
this way, you can cause specific messages to be
displayed even when ECHO has been turned off.
If ECHO is issued with no parameters, thecurrent ECHO state (ON or OFF) is displayed.

6-35

BatchCommands

Example: In this example, the batch file contains thefollowing:echo offrem **** command display is off
dir a:/wecho ondir a:/w

Upon execution of the above batch file, thefollowing display will occur:echo off
Volume on drive A has no 10
Directory of A: \filenamel.ext filename2.ext
2 file(s)xxxxx bytes free

dir a:/w
Volume in drive A has no 10
Directory of A: \filenamel.ext
2 file(s)filename2.ext

xxxxx bytes freeIn the above example, the ECHO OFF isdisplayed. The rem command and dir a:/w are
not displayed because ECHO is OFF, but theoutput of the dir is not inhibited.

6-36

BatchCommands

FOR Subcommand
Purpose:The FOR batch processing subcommand allows
iterative execution of DOS commands.

Format:

FOR %%variable IN (set) DO command

Type:Internal

External***
Remarks: The %%variable is sequentially set to eachmember of set and then the command is evaluatedand executed. If a member of set is an expression
involving * and! or?, then the %%variable is set
to each matching filename from disk.
Example: In this example, if you enter the command:
FOR 0/0%1 IN (proal.asm prog2.asm proga.asm) DO dlr 0/00/01

The result is
dir progl.asm
dir prog2.asm
dir prog3.asm

Note: FOR subcommands cannot be
nested; that is, only one FOR subcommand
can be specified on a command line. Also,
path names are not accepted withfilenames.
6-37

BatchCommands

GOTO Subcommand
Purpose:The GOTO batch processing subcommand
transfers control to the line following the one
containing the appropriate label. A label isinserted in a batch file as a colon (:) followed by
the label name.

Format:GOTO label

Type:Internal

External***
Remarks: The GOTO label causes commands to be
executed beginning with the line immediately
after :label. If :label is not defined, the current
batch file terminates with the message Labelnot found. A label in a batch file is defined asa character string where the first 8 characters
are significant (make it different).

6-38

BatchCommands

Example: In this example, the following batch fileproduces an indefinite sequence of remlooping... and GOTO LOOP messages on thescreen::LOOP
rem looping...
GOTO LOOP

Note that labels within a batch file are neverdisplayed while the batch file is executing. In
the example above, the line :LOOP would not
be displayed. Thus, unreferenced labels provide
a handy means for placing comments withinyour batch file that are not displayed when thefile is executed.

6-39

BatchCommands

IF Subcommand
Purpose:The IF batch processing subcommand allows
conditional execution of DOS commands.

Format:IF [NOT] condition command

Type:Internal

External***
Remarks: The condition parameter is one of the following:
ERRORLEVEL number
stringl ==string2
EXIST filespec

6-40

BatchCommands

When the IF parameter's condition is true, thenthe DOS command is executed. Otherwise, theDOS command is skipped, and the following
command in the file is executed.
ERROELEVEL number is true if the previous
program had an exit code of number or higher.
The number is specified as a binary value.
Stringl ==string2 is true when stringl and string2
are identical.
Note: The corresponding characters ofstringl and string2 must both be uppercase
or lowercase to be identical.
EXIST filespec is true if filespec is found on thespecified drive. Path names are not allowed withthe filespec.
NOT condition is true if the condition is false.

Example: This example is for the IF EXIST filespec
command:if exist filel goto abc:abc
command6-41

BatchCommands

Execution of a batch file containing thiscommand with/ilel given as the %1 parameter
would make the condition true providedfilel isfound on the default drive. The goto abc ~ould beexecuted causing the system to skip to thecommand following the label :abc. If/llel is notfound, the goto abc would not be executed.
Processing would then continue with the next
command in the batch file.
The following example is for the IF
string! ==string2 command:
if DID 1 =Doug echo Doug was here!

Execution of a batch file containing thiscommand with Doug given as the %1 parameter
would make the condition true. The ECHO
batch command would then be executed
displaying Doug was here!. If Doug was not
given as the %1 parameter, the condition would
have been false. The ECHO batch command
would not have been executed. Processing
would continue with the next command in thebatch file.

6-42

BatchCommands

The following example is for the IF
ERRORLEVEL number command:
myproglif errorlevel 1 echo myprogl failed - end batch file execution

The above two commands are in a batch file;
MYPROGI is a program that sets the errorlevel
when it completes its processing. In the simple
case, MYPROG 1 sets the errorlevel to 0 if itcompleted processing successfully and sets
errorlevel to 1 if processing completed
unsuccessfully. The batch file conditional if
errorlevel 1 echo ... tests for the situation when
MYPROGI failed. If MYPROGI completed
processing unsuccessfully, the condition istrue and the ECHO batch command is executed.
The ECHO batch command displays the data (ormessage) immediately following echo. If
MYPROG 1 was successful, the condition would
not be true and the ECHO batch
command would not be executed. Processing
would then continue with the next command in
the batch file.

6-43

BatchCommands

The following example is for the IF NOTEXIST filespec command:
if not exist 8:%1 copy b: % 1 a:program

The above IF batch command demonstrates the
NOT condition. The batch file that thiscommand is in, is going to execute a programthat requires a particular file to be on drive A.
The IF command is executed prior to theprogram to make sure that the required file is on
drive A. If the file does not exist on drive A, thecondition is true. The copy will then be executed,
copying the file from drive B to drive A tosatisfy the requirements of the program. If thefile does exist on drive A, the copy will not be
executed. Processing will then continue to
execu te the program.
Note: At the present time, only BACKUP
and RESTORE commands set an
ERRORLEVEL that can be tested. The
facility is included to allow your own
programs to set an error code that can thenbe interrogated by the IF ERRORLEVEL
subcommand.

6-44

BatchCommands

SHIFT Subcommand
Purpose:The SHIFT batch processing subcommand
allows command lines to make use of more than
10 (%0 through %9) replaceable parameters.

Format

SHIFT

Type:

Internal

External***
Remarks: Replaceable parameters are numbered %0
through %9. If you wish to use more than 10parameters on a command line, you can use
SHIFT to get at parameters past the tenth. All
parameters on the command line are shifted one
position to the left, with the %0 parameter
being replaced by the %1 parameter, etc. Eachsubsequent shift command causes all theparameters to be shifted to the left by one
position. For example:
0/00 = A
0/01 = B
0/02 = C
0/03 = 0

0/09

6-45

BatchCommands

The SHIFT results are:0/00 = B
0/01 = C
0/0 2 = 0

0/0

9Example: This example demonstrates how the SHIFT
subcommand can be used in a batch file. If abatch file named MYFILE.BAT contains thefollowing commands, and the default drive is A:
echo 0/00 % 1 0/02 0/03
shiftecho 0/00 % 1 0/02 0/03
shiftecho 0/00 % 1 0/02 0/03
shiftecho 0/00 % 1 0/02 0/03
shiftecho 0/00 % 1 0/02 0/03

Invoke the batch file with the following
parameters:
MYFILE PROGl

6-46

PROG2

PRoa

BatchCommands

Produces the following results:
A>echo MYFILE
MYFILE PROGl

PROGl PROG2 PROG3
PROG2 PROG3

A>shiH
A>echo PROGl PROG2
PROGl PROG2 PROG3

PROG3

A>shiH
A>echo PROG2
PROG2 PROG3

PROG3

A>shift
A> echo PROG3
PROG3
A>shiH
A> echoA>

PAUSE Subcommand
Purpose:Suspends system processing and displays themessage Strike a key when ready....

Format:

PAUSE [remark]

Type:Internal

External***
6-47

BatchCommands

Remarks: You can insert PAUSE comrnands within abatch file to display messages and to give you
the opportunity to change diskettes between
commands. To resume execution of the batch
file, press any key except Ctrl-Break. (Ctrl- Breakends processing.)
If you include the optional remark, the remark isalso displayed. The optional remark can be any
string of characters up to 121 bytes long.
You can control how much of a batch file youwant to execute by placing PAUSE commands at
strategic points in the file. At each PAUSE
command, the system stops and gives you time
to decide whether to end processing. To end
processing, press Ctrl-Break. To continue
processing, press any other key.

Example: If you enter this PAUSE command in a batch
file, the following message is displayed:
A >PAUSE Change diskette in drive A
Strike a key when ready... _This PAUSE "enables you to change diskettes
between commands.

6-48

BatchCommands

REM (Remark) Subcommand
Purpose:

Displays remarks from within a batch file.

FormatREM [remark]

Type:Internal

External***
Remarks: The remarks are displayed when the batch
execution reaches the remark.
Remarks can be any string of characters up to
123 bytes long.

You can use REM commands without remarks
for spacing within your batch file, forreadability.
Example: If the following REM command is issued in abatch file, this remark is displayed:
REM This is the daily checkout program

Note: See "Detailed Descriptions of the
DOS Commands" in this chapter forconsiderations in using the REM command.

6-49

BREAK (Control Break)CommandPurpose:Allows you to instruct DOS to check for acontrol break whenever a program requests
DOS to perform any functions (such as disk
operations).

Format:BREAK [ON I OFF]Type:

Internal***

External

Remarks: Use this command to specify when DOS should
check for a Ctrl-Break being entered at the
keyboard. Normally, DOS only performs thischeck during screen, keyboard, printer, or
auxiliary device operations.
Ctrl-Break allows you to breakout of a programthat performs few or no screen or keyboard
operations (such as a compiler).

6-50

BREAK (Control Break)CommandThe ON parameter causes DOS to begin
checking for Ctrl-Break whenever a program
requests any DOS function. Specifying OFF
causes DOS to check only during screen,
keyboard, printer, or Asynchronous
Communications Adapter operations.
You can also turn on the extended checking byusing BREAK=ON in your configuration file.
Refer to "Configuring Your System" in Chapter 9.
Entering BREAK with no parameter causes
DOS to display the current state (on or off) of
Ctrl-Break checking.

6-51

CHDIR (Change Directory)
CommandPurpose:Change the DOS current directory of thespecified or default drive, or to display thecurrent directory path of a drive.

Format:CHDIR [[d:]patb]orCD [[d:]patb]

Type:Internal

External***
Remarks: The current directory is where DOS looks tofind files whose names were entered without
specifying which directory they were in. If you
do not specify a drive, the default drive isassumed. If you enter CHDIR or CD with noparameters or with only a d: parameter, thecurrent directory path of the specified or default
drive is displayed.

6-52

CHDIR (Change Directory)
Command

Example: In this example, the command will change thecurrent directory of the default drive to its root
directory:
CHOIR \In this example, the command will change drive
B's current directory to the path"root - ; > LEVELl-;=> LEVEL2":
CD B:\LEVEU\LEVEI2

In this example, the command will change drive
B's directory to the current directory path plus
LEVEL3:
CD B:LEVEI.3

Thus, if the second example had been used, theresultant path would be:rool-> LEVEU-> LEVEI2-> LEVEI.3
The search for the LEVEL3 directory begins in
the directory that was current when thecommand was issued.

6-53

CHKDSK (Check Disk)
CommandPurpose:Analyzes the directories and the File Allocation
Table on the designated or default drive andproduces a disk and memory status report.

Format:CHKDSK [d:] lfilename] [IF] [IV]

Type:Internal

External***
Remarks: If you specify a filename, CHKDSK will display
the number of non-contiguous areas occupiedby the file or files. Note thatCHKDSK only
looks in the current directory for these files.
CHKDSK will not automatically correct errors
found in the directory or file allocation table. If
you want it to make the corrections, use the IF(fix) parameter. If you do not specify the IF
parameter, CHKDSK continues to function as
though it were preparing to correct the disk sothat you can analyze the possible results ofcorrection, but does not actually write thecorrections on the disk.
If you use the IV parameter, CHKDSK will
display a series of messages indicating its
progress, and provide more detailed information
about the errors it finds.

6-54

CHKDSK (Check Disk)
CommandAfter checking the disk, CHKDSK displays any
error messages, followed by a status report. A
complete listing of error messages can be foundin Chapter 8.
Following is an example of the status report thatis displayed:
Volume MYDISKCreated AUG 12, 1983 10:00

179712 bytes total disk space
18944 bytes in 3 hidden files
512 bytes in 1 directories
26112 bytes in 4 user files
134144 bytes available on disk
196608 bytes total memory
170736 bytes free

Note that in this status report, three hidden files
were reported. These are the volume label, andthe DOS system files IBMBIO.COM andIBMDOS.COM, that are hidden from thenormal directory searches. Some application
programs also create hidden files.
CHKDSK does not wait for you to insert adiskette. It assumes that the diskette to bechecked is in the specified drive. Therefore, on asingle diskette-drive system, it is especially
important that the specified drive is different
from the default drive, unless you are checking
the DOS diskette itself.

6-55

CHKDSK (Check Disk)
Command

You should run CHKDSK occasionally for each
fixed disk and diskette to ensure the integrity of
the file structures.
Notes:1.

All yes or no (YIN) prompts fromCHKDSK require you to press Enter
after entering Y or N, to prevent
accidental changes to your disk.

2.

If you specified a filenalne, the numberof non-contiguous areas occupied by
the file will be reported. Badly
fragmented files (many non-contiguousareas) can cause system performance toslow down when those files areaccessed, since DOS can not read themsequentially. You can determine theextent of file fragmentation by using *. *in the filename field of the CHKDSK
command.

3.

If CHKDSK finds lost allocation units(clusters) on the disk, it asks if you
wish to recover the lost data into files.
If you say yes, and the IF parameter
was used, CHKDSK recovers eachchain of lost allocation units into a filewhose name is in the form:
FILEnnnn. CHK

6-56

CHKDSK (Check Disk)
Command

Where nnnn is a sequential number
starting with 0000. These files are
created in the root directory of thespecified drive. You can then look atthese files to see if they have any useful
information. If not, you can erase
them.
4.

If you redirect CHKDSK's output to afile, for example:
CHKDSK B:>FILE

It will report errors on that file. In thiscase, be sure not to use the IF
parameter.

6-57

CLS (Clear Screen)
CommandPurpose:Clears the display screen.

Format:

CLS

Type:

Internal

External***
Remarks: This command clears the display screen upon
execu tion. If foreground and background colo rs
have been selected through the "Extended
Screen Control and Keyboard" functions
described in Chapter 1 3, the colors will remainunchanged. Otherwise, the screen is set to whitecharacters on a black background.

6-58

COMP (Compare Files)
CommandPurpose:Compares the contents of the first set of
specified files to the contents of the second setof specified files. Usually, you would run COMP
after a COpy operation to ensure that the two
sets of files are identical.
Note: This command compares two setsof/iles; the DISKCOMP commandcompares two entire diskettes.

Format:COMP [d:] [path] [filename[.ext]][d:] [path] [fllename[.ext]]

Type:Internal

External***
Remarks: The first parameter you specify is the primary
file. The second parameter is the secondary file.
The files that you compare may be on the same
drive or on different drives. They can also be in
the same directory or different directories.
Global filename characters are allowed in bothfilenames, and will cause all of the files matching
the first filename to be compared with thecorresponding files from the second filename.
Thus, entering:
COMP A:*.ASM B:*.BAK

6-59

COMP (Compare Files)
Commandcauses each file that has an extension of .ASM
from drive A to be compared with a file of thesame name (but with an extension of .BAK)
from drive B.
If no parameters are entered with the COMP
command, or if the second parameter is missing,you are prompted for them. If either parameter
only contains a drive or a path with no filename,
COMP assumes a filename of *.*. You can entera complete path with either of the two
filenames. For example, the command:
COMP B:*.ASM C:

causes all .ASM files on drive B to be comparedwith the files of the same names and extensions
on drive C.

It is also possible to compare all files in one
directory with all corresponding files in anotherdirectory. For example:
COMP A:\LEVEL 1 A:\LEVEL2

locates all the files in the LEVELl directory ofdrive A and compares them with the same
filenames from the LEVEL2 directory on thesame drive.
If no file matches the primary filename, COMP
will prompt you for both the primary andsecondary parameters again.

6-60

COMP (Compare Files)
Command

The paths and names of the files being
compared are displayed as the comparing
process proceeds. An error message will follow if
a file matching the second filespec cannot befound, or the files are different sizes, or a
specified directory path is invalid.
During the comparison, an error message
appears for any location that contains
mismatching information in the two files. The
message indicates the offset into the files of themismatching bytes, and the contents of thebytes themselves (all in hexadecimal), as follows:
Compare error at offset XXXXXXXX
File 1 = XX
File 2 = XX

In this example, File 1 is the first filename
entered; File 2 is the second filename entered.
After ten unequal comparisons, COMP
concludes that further comparing would be
useless; processing ends; and the following
message is displayed:
10 Mismatches - ending compare

6-61

COMP (Compare Files)
CommandAfter a successful comparison, COMP displays:
Files compare OK

After the comparison of the two files ends,
comparing will proceed with the next pair offiles that match the two filenames, until nomore files can be found that match the firstparameter. Then COMP displays:
Compare more files (YIN)? _Y ou now have the option to compare two morefiles or to end the comparison. If you want tocompare two more files, enter Y. You will beprompted for new primary and secondary
filenames.
If you want to end COMP processing, enter N.
You will return to the DOS prompt. In allcompares, COMP looks at the last byte of thefiles being compared to assure that it contains avalid end-of-file mark (Ctrl-Z, which is thehexadecimal character lA). If found, no action istaken by COMPo If the end-of-file mark is notfound, COMP produces the message:
EOF mark not found

6-62

COMP (Compare Files)
CommandThis is done because some products produce
files whose sizes are always recorded in the
directory as a multiple of 128 bytes, eventhough the actual usable data in the file isusually a few bytes less than the directory size.
In this case, COMP may produce compare
error messages when comparing the few bytes
beyond the last real data byte in the last blockof 128 bytes (COMP always compares thenumber of bytes reflected in the directory).
Thus, the EOF mark not found message
indicates that the compare errors may not haveoccurred in the usable data portion of the file.
Notes:
1.

The two sets of files you want tocompare can have the same path andfilenames-provided they are on
different drives.

2.

If you only specify a drive for thesecond file, it is assumed that thesecond filename is the same as the first
filename. But, the current directory is
to be used. That is, it is the same asentering:
d'· •

3.

A comparison does not take place if
the file sizes are different.

6-63

COMP (Compare Files)
Command4.

6-64

COMP does not wait for you to insert adiskette containing a file to becompared. Therefore, if a file to becompared is not on the same disketteas the COMP command itself, you
should enter COMP with noparameters. When COMP prompts forthe filenames, you can insert thedesired diskette and reply with thename of the file to be compared.

COpy
CommandPurpose:Copies one or more files to another disk ar:td
optionally, gives the copy a different name ifyou specify it in the COpy command.
COpy also copies files to the same disk. In thiscase, you must give the copies different names
unless different directories are specified;otherwise, the copy is not permitted.
Concatenation (combining of files) can be
performed during the copying process.
You can also use COpy to transfer data between
any of the system devices. (An example of how
to copy information that you enter at the
keyboard to a file is provided at the end of thedescription of COpy.)

Format:COPY [I A] [lB] [d:] [pathlfilename[.ext] [I A] [lB][d:] [path] [filename[.ext]] [IA] [lB] [IV]orCOpy [IA] [lB] [d:] [pathlfilename[.ext] [/A] [lB][+[d:] [pathlfilename[.ext] [IA] [lB] ... ][d:] [path] [filename[.ext]] [/ A] [lB] [IV]

Type:Internal

External

***

6-65

COpy
CommandRemarks: The first file specified is the source file. The
second file specified is the target file. If thesecond parameter is a directory (path with nofilename), files are copied into that directory
without changing their names.
The parameter IV causes DOS to verify that thesectors written on the target diskette arerecorded properly. Although errors in recording
data are very rare, this option has been provided
for those of you who wish to verify that critical
data has been correctly recorded. This option
causes the COpy command to run more slowly,
due to the additional overhead of verification.
The IV parameter provides the same check as
does the VERIFY ON command. IV isredundant if the VERIFY ON command has
been executed previously. The difference is that
IV is effective during the execution of the
COpy command. The VERIFY ON command isin effect continually until VERIFY OFF isentered.

6-66

COpy
Command

The parameters / A and /B indicate the amountof data to be processed by the COpy command.
Each applies to the filespec preceding it and to
all remaining filespecs on the command line
until another / A or /B is encountered. These
parameters have the following meanings:
When used with a source filespec:/A

Causes the file to be treated as an ASCII(text) file. The file's data is copied up to,
but not including, the first end-of-filecharacter (Ctrl-Z, which is hex 1A) foundin the file; the remainder of the file is notcopied.

/B

Causes the entire file (based on the
directory file size) to be copied.

When used with a torget filespec:/A

Causes a Ctrl- Z character to be added as thelast character of the file.

/B

Causes no end-of-file character (Ctrl-Z) tobe added.

6-67

COpy
Command

The default values are / A when concatenation ,isbeing performed (see Option 3 below), and /B
when concatenation is not being performed(Options 1 and 2).
Notes:
1.

When copying to or from a reserved
device name, the copy is performed
in ASCII (/ A) mode. The first Ctrl- Z
character encountered will end the
copy unless /B was specified.

2.

When making a copy of a file that ismarked read-only, the copy will not
be marked read-only.

You can use the global characters? and * in thefilename and in the extension parameters ofboth the original and duplicate files. If you entera? or * in the sourcefilespec, the names of thefiles will be displayed as the files are being
copied. For more information about global
characters, refer to "Global Filename
Characters" in this chapter.

6-68

COpy
Command

The COpy command has three format options:
Option 1 - Copy With Same Name
Use this option to copy a file with the copied filehaving the same filename and extension as thesource file. For example:
COpy[d:] [pathlfi"lename[.ext]

or
COpy

[d..] [pathlfi"lename[.ext] d.·[path]

In the first example, we want to copy a file tothe current directory of the default drive. In thesecond example, we specify the target drive
and! or directory. In both examples, because
we did not specify the second filename, thecopied file will have the same filename as thesource file. Because we did not specify a namefor the second file, the source drive and thetarget drive must be different unless different
directories were specified or implied;otherwise, the copy is not permitted

6-69

COpy
Command

For example, assume the default drive is A. The
command:
COpy B: MYPROG

copies the file MYPROG from drive B, to thedefault drive A, with no change in the filename.
The command:
COpy *.* B:

copies all the files from the default drive A todrive B, with no change in the filenames or in
the extensions. The filenames are displayed as
the files are copied. This method is very useful
if the files on drive A are fragmented. The
command:
COpy B:\MYPROG

6-70

B:\LEVELl

COpy
Commandcopies the file MYPROG from the root
directory of drive B to the directory path:rool-> LEVELl
on the same drive. The copy has the same
filename as the original file. Note that the above
example assumes that directory LEVELl exists
on drive B. If it did not, then the file MYPROG
would have been copied into a file named
LEVELl in the root directory of drive B. In
other words, if the second parameter specifies a
directory th~t exists, the file (or files) will beplaced in that directory, keeping the same
filename. If the second parameter does not
specify a directory that exists, DOS will treat it
as a filename.
Option 2 - Copy With Different Name
Use this option when you want the copied file tohave a different name from the file that is being
copied. For example:

COpy [d:] [pathlfilename[.ext] [d:] [pathlfilename[.ext]
orCOpy [d:] [pathlfilename[.ext] [d:] [pathlfilename[.ext]

6-71

COpy

Command

In the first example, we copied a file (first filespecified), and renamed the copy (second filespecified). We did not specify a drive, so thedefault drive was used. In the second example,
we copied a file and renamed the copy also. In
this example, we did specify the target drive.
Because we changed the name of the file, thesource drive and the target drive do not have to
be different. The current directory can be thesame or different.
For example:
COPY MYPROG.ABC B:*.XXX

copies the file MYPROG.ABC from the diskettein default drive A to drive B, naming the copy
MYPROG.XXX. The current directory of eachdrive was used.
You can also use reserved device names for the
copy operation. For example:
COPY CON: fileA
COPY CON: AUX:
COPY CON: LPT1:
COPY fileA CON:
COPY fileB AUX:
COPY fileC LP12:COPY AUX: LPT1:
COPY AUX: CON:

6-72

COpy
CommandAlso, NUL: can be used in any variation. The
colon is not required when specifying a reserved
device name.
Refer to "Reserved Device N a~es" in thischapter for information about system devices.
This example shows how to use COpy to put
what you enter from the keyboard into a file:
A>COPY CON: fileA
Type a line and press Enter.
Type your next line and press Enter.

•••

Type your last line and press Enter.
Now, press F6 and then press Enter.

When you press F6, and then press Enter, theCOpy operation ends and saves the information
you entered. In this example, the information issaved in a file named fileA.
Note: This example assumes that you
have not altered the meaning of F6 throughthe" Extended Keyboard Support"functions described in Chapter 1 3. If you
have, then substitute the key that you haveassigned Ctrl-Z for F6 in this example.

6-73

COpy
Command

Option 3 - Copy and Combine Files
Use this option when you want to combine files
while copying. That is, you can combine two or
more files into one file by adding the additional
files to the end of the first. The date and time
recorded in the result file directory are thecurrent date and time. The message indicating
the number of files copied refers to the numberof result files created.
To combine files, list any number of source files,
separated by plus (+) signs in the COpy
command. Use the following format:

COpy [/A] [/B] [d:] rJ;atblfilename[.ext] [/A] [/B][+[d:] rJ;atb]filename[.ext] [IA] [/B] ... ][d:] rJ;atblfilename[.ext]] [IA] [/B] [IV]For example:
COPY A.XYZ+B.ABC+B:C.TXT BIGFILE.TXT

This command creates a new file called
BIGFILE.TXT on the default drive. The
combination of A.XYZ, B.ABC, and B:C. TXT is
put into BIGFILE. TXT.

6-74

COpy
CommandIf you do not specify a resultfilename, theadditional files are added to the end of the first
file, leaving the result in the first file. For
example:COPY A.ASM+B.ASM

In this case, COpy appends B.ASM to the end of
A.ASM and leaves the result in A.ASM.
Note: Combining files is normally
performed in text (or ASCII) mode. That is,
the first Ctrl-Z (hex lA) character in the fileis interpreted as an end-of-file mark. To
combine binary files, use the /B parameterto force COpy to use the physicalend-of-file (the file length shown in the DIR
command).
You can also combine ASCII and binary files byusing the following parameters:•

ASCII - fA•

Binary - fB

6-75

COpy
Command

For example:
COPY A.XYZ+B.COM/B+B:C.TXT/A BIGFILE.TXT

A/A or /B takes effect on the file it is placed
after, and it applies to all subsequent files on thecommand line until another / A or /B is found. A/ A or /B on the result file causes a Ctrl-Z to be
added (IA), or not to be added (lB), as the last
character in the result file.
You can use the global characters? and * in thefilenames of both the files to be combined andthe result file. For example:
COPY *.LST COMBIN.PRN

In this example, all files matching *.LST are
combined into one file called COMBIN.PRN.
Also:
COPY *.LST+*.REF COMBIN.PRN

This example combines all files matching *.LST
and then all files matching *.REF into one filecalled COMBIN.PRN.
COPY *.LST+*.REF *.PRN

6-76

COpy
Command

In this example, each file matching *.LST is
combined with the corresponding. REF file,with the result having the same name but withextension .PRN. Thus, a file FILE1.LST would
be combined with FILE1.REF to form
FILE1.PRN; XYZLST would be combined withXYZREF to form XYZPRN; etc. Note that inthis case (when multiple files are to be created),
only one file from each of the source filespecs isused to create a given target file.
For more information about global characters,
refer to "Global Filename Characters" in thischapter.
It is easy to enter a COpy command to combine
files where one of the source files is the same as
the target, yet this often cannot be detected. For
example:COPY *.LST ALL.LST

This would produce an error if ALL.LST alreadyexisted. The error would not be detected,
however, until it was time for ALL.LST to be
appended; by this time, ALL LST could alreadyhave been altered.

6-77

COpy

Command

COpy handles this situation as follows: As each
input file is found, its name is compared withthe target filename. If the names are the same,that one input file is skipped, and the message
Content of destination lost before copy isdisplayed. Further copying proceeds normally.
This allows summing files, with a command like:
COPY ALL.LST + *.LST

This command appends all *.LST files, except
ALL.LST itself, to ALL.LST. In this case, theerror message is suppressed, because this is atrue physical append to ALL.LST.
The following are special cases. Remember to
use the IB parameter whenever you use the plus(+) sign with non-ASCII files.
COPY B:XYZ.ASM+

This command copies the file XYZ.ASM to thedefault drive and gives it a new date and time.
To simply change the date and time, leaving thefile in place, you can use the following
command:
COPY B:XYZ.ASM+, , B:

Note that the two commas are necessary todefine the end of the source filename, because
COpy normally expects to see another filename
after the plus (+) sign.

6-78

COpy
Command

In these special cases, if glo hal filename
characters are used in the filename or extension,then all of the matching files will be appended
together into the first filename that matches.
Thus, the command:
COPY B:*.* +, , B:

will not update the dates and times of all files ondrive B, but will append all of drive B's files
together into a single file that will replace thefirst file found on drive B.
Note: When combining files, COpy
considers the copying process to be
successful if at least one, but not necessarily
all, of the named source files is found. If
none of the source files can be found, you
receive the message

o file( s) copied

6-79

DATE
CommandPurpose:Permits you to enter a date or change the dateknown to the system. The date is recorded in
the directory entry for any files you create oralter.

Format:DATE [mm-dd-yy]

Type:Internal

External***
Remarks: If you enter a valid date with the DATE
command, the new date is accepted, and thesystem prompt appears. Otherwise, the DATE
command issues the following prompt:
Current date is day m..-dd-yy
Enter new date: _The system displays the day of the week in the
day location.
Enter a new date in the form mm-dd-yy or mm/dd/
yy, where:
mm is a one- or two-digit number from 1-12
dd is a one- or two-digit number from 1- 31
yy is a two-digit number from 80-99 (the 19 isassumed) or a four-digit number from1980-2099

6-80

DATE
Command

You can change the date from the keyboard orfrom a batch file. Remember, when you start thesystem, it does not prompt you for the date if
you use an AUTO EXEC. BAT file. You may
want to include a DATE command in that file.
For more information about the
AUTOEXEC.BA T file, refer to "Batch
Commands" in this chapter.
Notes:
1.

To leave the date as is, press Enter.

2.

The valid delimiters within the date are
hyphens (-) and slashes (I).

3.

Any date is acceptable as today's date,as long as the digits are in the correct
ranges.

4.

If you enter an invalid date ordelimiter, you receive an Invalid datemessage.

Example: In this example, once you press Enter, the dateknown to the system is 7/24/82.
A> DATE
Current date is Mon 1-18-1982
Enter new date: 7/24/82_

6-81

DEL
CommandSee" ERASE Command" in this chapter.

6-82

DIR (Directory)
CommandPurpose:Lists either all the directory entries, or only
those for specified files. The information
provided in the display includes the volumeidentification and the amount of free space left
on the disk. The display line for each fileincludes its size in decimal bytes and the date
and time the file was last written to. Entries thatname other directories are clearly identified with
<DIR> in the file size field.
Note: Directory entries for system files
IBMBIO.COM and IBMDOS.COM are notlisted, even if present.

Format:DIR [d:] [path] [filename[.ext]] [/P] [lW]

Type:Internal

External***
Remarks: The IP parameter causes the display to pause
when the screen is full. When you are ready tocontinue with the directory listing, press any
key.
The IW parameter produces a wide display ofthe directory, which lists only the filenames anddirectory names. Each line displayed contains
five names. (This parameter is only
recommended for sO-column displays.)

6-83

DIR (Directory)
Command

You can use the global characters? and * in thefilename and extension parameters. For more
information about the global characters, refer to"Global Filename Characters" in this chapter.
The DIR command has two format options (theIP and IW parameters may be used with either
option):Option 1 - List All Files
Use this option to list all the files in a directory.
F or example:
DIR [path]or
DIR d: [path]
In the first example, we want to,list all directory
entries on the default drive. In the second
example, we want to list all directory entries on
the specified drive. In both cases, if a path isspecified, the listing is of files in the specified
directory. Otherwise, the current directory islisted.

6-84

DIR (Directory)
Command

The directory listing might look like this:
A>dirVolume in drive A is MYDISKDirectory of A: \
FILE1
FILE3
9X
LEVEl2FILEl

A
A

7-20-8310368
5-27-831613
8-17-8231
9-09-82<DIH>
2288
9-02-82
5 File( 5) 141312 bytes free

12:13p12:14p10:59a12:10p12:25pNote that if the directory being listed is not theroot directory, the above example would haveincluded two special entries. The first entry
would contain a period in place of a filename.
The second would contain two periods in placeof a filename. The list of files shown above
would follow these two entries. These special
entries tell you that the directory being listed isa sub-directory, rather than the root directory.

6-85

DIR (Directory)
Command

Option 2 - List Selected Files
Use this option to list selected files from a
directory. For example:
DIR filename. ext
or
DIR d:filename. ext
If eitherjtlename or. ext is omitted, an * isassumed.
In the first example, we want to list all the files
in the directory of the default drive that have thespecified filename and extension. In the second
example, we want to list all the files in the
directory of the specified drive that have thespecified filename and extension.
Using the previous example, if you enter:dlr tlld .•the screen might look like this:A>dlr Illd.•
Volume In drive A Is MYDISK
Dlractory of A:\
FILE3

6-86

A
1613
5.. 27 .. 83
12:14p1 Flla(s) 141312 bytas freeDIR (Directory)
CommandIf you enter:dlr *.8

ordir.8 (omission of/ilename defaults to *)the screen might look like this:A>dlr *.8
Volume in drive A is MYDISKDirectory of A:\
FILEl
FILE3

A
10368
7-20-83
A
1613
5-27-83
2 Filels) 141312 bytes free

12:13p12:14pIf you enter:dir filel

the screen might look like this (omission of. ext
defaults to *):A> dir fllel
Volume in drive A is MYDISKDirectory of A:\
FILEl
FILEl

A

10368
7-20-832288
9-02-82
2 Fllel s) 141312 bytes free

12:13p12:25p

6-87

DIR (Directory)
Command

To display only the entry for a file that has noextension, enter the filename followed by aperiod. In this case, the. ext does not defa ul t to *.
For example,
dir filel

displays the entry for FILEt, but not for
FILEt.A.
If you wish to display all the files in directory
LEVEL2 on the above drive, you can enter:dir level2

The screen will look like this:
A>dir level2
Volume in drive A is MYDISKDirectory of A:\leveI2<Dlft>
9·09·82<Dlft>
9-09·82
MYPROGCOM
2463
7·30·82
3 File(s) 141312 bytes free

6-88

DIR (Directory)
CommandNote that all files in directory LEVEL2 havebeen listed, including the two special entries
found in all sub-directories. The entry marked
with a single period denotes the directory being
listed (LEVEL2), and the double period denotes
this directory's parent directory (in this case, theroot directory). Thus, if your current directory is
LEVEL2 and you wish to see the files in its
parent directory, you can enter:
dir ..

The following screen is displayed:
A>dir ..
Volume in drive A is MYDISKDirectory of A:\
FILEl
FILE3
9X
LEVEL2FILEl

7-20-83
5-27-83
8-17-82<DIR>
9-09-822288 9-02-82
5 File( s) 141312 bytes free

A
A

10368
1613
31

12:13p12:14p10:59a12:10p12:25p

6-89

DISKCOMP (Compare Diskette)
CommandPurpose:Compares the contents of the diskette in thefirst specified drive to the contents of thediskette in the second specified drive. Usually,
you would run DISKCOMP after a DISKCOPY
operation to ensure that the two diskettes are
identical.
Notes:
1.

This command is used only for comparing
diskettes. If a fixed disk drive letter is
specified, an error message is displayed.

2.

This command compares two entire diskettes;
the COMP command compares two files.

Format:DISKCOMP [d:] [d:] [/1] [/8]Type:Internal

External***
Remarks: You can specify the same drive or different
drives in this command. If you specify the same
drive, a single-drive comparison is performed.
You are prompted to insert the diskettes at theappropriate time. DISKCOMP waits for you topress any key before it continues.

6-90

DISKCOMP (Compare Diskette)
Command

The /1 parameter forces DISKCOMP tocompare only the first side of the diskettes, even
if the diskettes and drives are dual-sided.
The /8 parameter causes DISKCOMP tocompare only 8 sectors per track, even if thefirst diskette contains 9 sectors per track.
DISKCOMP compares all 40 tracks on a
track-for-track basis and issues a message if the
tracks are not equal. The message indicates the
track number (0- 39) and the side (0 or 1) where
the mismatch was found.
After completing the comparison, DISKCOMP
prompts:
Compare more diskettes (YIN)? _If you press Y, the next comparison is done on
the same drives that you originally specified,after you receive prompts to insert the proper
diskettes.

6-91

D ISKCOMP (Compare Diskette)
Command

To end the command, press N.
Notes:

6-92

1.

If you omit both parameters, a singledrive comparison is performed on thedefault drive.

2.

If you omit the second parameter, thedefault drive is used as the secondary
drive. If you specify the default drive inthe first parameter, this also results in asingle-drive comparison.

3.

On a single-drive system, all prompts
are for drive A, regardless of any drive
specifiers entered.

4.

DISKCOMP usually does not issue aDiskettes compare OK message if you
try to compare a backup diskettecreated by the COpy command withthe diskette you copied from. The
COpy operation produces a copy that
contains the same information, butplaces the information at different
locations on the target diskette fromthose locations used on the source
diskette. In this case, you should use
the CaMP command to compareindividual files on the diskettes.

DISKCOMP (Compare Diskette)
Command5.

If a diskette error occurs while
DISKCOMP is reading the diskette, amessage is produced that indicateswhere (track and side) the error
occurred. Then DISKCOMP continues
to compare the rest of the diskette.
Because the remainder of the data to
be compared cannot be read correctlyfrom the indicated track and side, you
can expect to receive a Compare error
message.

6.

DISKCOMP automatically determines
the number of sides and sectors per
track to be compared, based on thediskette that is to be read first (the first
drive parameter entered).
If the first diskette or drive can be readon only one side, or if the /1 parameteris used, only the first side is read fromboth diskettes. If the first diskettecontains 9 Sectors per track, thenDISKCOMP will compare 9 sectors per
track unless you used the /8 parameter.
If the first drive and diskette are
dual-sided, and /1 is not specified, atwo-sided comparison is done. An error
message is produced if either thesecond drive or the diskette is asingle-sided diskette.

6-93

DISKCOPY (Copy Diskette)
CommandPurpose:Copies the contents of the diskette in the source
drive to the diskette in the target drive. The
target diskette is formatted if necessary, during
the copy.
Note: This command is used only forcopying diskettes. If a fixed disk drive letteris specified, an error message is displayed.

Format:DISKCOPY [d:] [d:][/I]

Type:Internal

External***
Remarks: The first parameter you specify is the source
drive. The second parameter is the target drive.
The /1 parameter causes DISKCOPY to copy
only the first side of the diskette, regardless ofthe diskette or drive type.
You can specify the same drives or different
drives. If the drives are the same, a single-drive
copy operation is performed. You are prompted
to insert the diskettes at the appropriate times.
DISKCOPY waits for you to press any key
before continuing.
After copying, DISKCOPY prompts:
Copy another (YIN)? _6-94

DISKCOPY (Copy Diskette)
CommandIf you press Y, the next copy is done on thesame drives that you originally specified, after
you are prompted to insert the proper diskettes.
To end the command, press N.
Notes:
1.

If the target diskette has not beenformatted with the same number ofsides and sectors per track as thesource diskette, DISKCOPY will
format the target diskette during the
copy operation.

2.

If you omit both drive parameters, asingle-drive copy operation is
performed on the default drive.

3.

If you omit the second parameter, thedefault drive is used as the target drive.

4.

If you omit the second parameter andyou specify the default drive as thesource drive, a single-drive copy
operation is performed.

5.

On a single-drive system, all prompts
will be for drive A, regardless of any
drive letter you may enter.

6-95

DISKCOPY (Copy Diskette)
Command

6.

Diskettes that have had a lot of filecreation and deletion activity become
fragmented, because diskette space is
not allocated sequentially. The first
free sector found is the next sector
allocated, regardless of its location on
the diskette.
A fragmented diskette can cause
degraded performance due to excessive
head movement and rotational delays
involved in finding, reading, or writing
a file.

If this is the case, it is recommended
that you use the COpy command,
instead of DISKCOPY, to eliminate
the fragmentation.
For example, place a freshly formatted
diskette in drive B, and the diskette
you wish to copy in drive A. The
command:
COpy A:*.* B:

copies all the files from the diskette indrive A to the diskette in drive B.
7.

6-96

You can run DISKCOMP after asuccessful DISKCOPY to ensure thatthe diskettes are identical.

DISKCOPY (Copy Diskette)
Command8.

If disk errors are encountered on either
diskette, DISKCOPY indicates thedrive, track, and side in error andproceeds with the copy. In this case,the target diskette (copy) mayor may
not be usable, depending on whether
the affected diskette location was tocontain valid data.

9.

DISKCOPY automatically determines
the number of sides and sectors per
track to copy, based on the source
drive and diskette. If only the first sideof the source diskette can be read, then
only the first side can be copied. If thesource drive and diskette are
dual-sided, both sides can be copied(unless you override it with the /1
parameter). In this case, if the target
drive is single-sided, an error message
will indicate that the drives areincompatible.
If the source diskette has ever been
physically formatted with 9 sectors per
track, then all 9 sectors on each track
will be copied.

6-97

ERASE
CommandPurpose:Deletes the file with the specified filename fromthe specified directory on the designated drive,or deletes the file from the default drive if nodrive is specified. If no path is entered, the file isdeleted from the current directory.

Format:ERASE [d:] [path] [fi°lename[oext]]or
DEL [d:] [path] [fi°lename[o ext] ]Type:Internal

External***
Remarks: The shortened form, DEL, is a valid
abbreviation for ERASE.
You can use the global characters? and * in thefilename and in the extension. Global charactersshould be used with caution, however, because
multiple files can be erased with a single
command. For more information about global
characters, refer to "Global Filename
Characters" in this chapter.
To erase all files in the current directory, enter:
ERASE [d:]*.*

6-98

ERASE
Command

To erase all files in a specific directory, enter:
ERASE [d:] path

ERASE assumes a filename of *.* if no filename
is given.
Notes:
1.

The system files IBMBIO. COM andIBMDOS.COM cannot be erased.

2.

If you use the filespec *. * to erase all of
the files in a directory or on a disk,
DOS issues the following message toverify that you actually want to erase
all files:
Are you sure (YIN)?

If you do want to erase all of the files
on the diskette, enter Y. Otherwise,
enter N. Then press the Enter key.
3.

The two special entries in eachsub-directory (. and .. in place of
filenames) cannot be erased.

Example: In this example, the file myprog.l will be erased
from the current directory of drive A.
A> ERASE A: myprog.l

6-99

FORMAT
CommandPurpose:

Initializes the disk in the designated or default
drive to a recording format acceptable to DOS;
analyzes the entire disk for any defective tracks;
and prepares the disk to accept DOS files byinitializing the directory, File Allocation Table,
and system loader.

Format:FORMAT [d:] [/S] [/1] [/8] [/V] [/B]

Type:

Internal

External***
Remarks: You must format all new diskettes (by using
either the FORMAT or DISKCOPY command)and fixed disks (through FORMAT) before they
can be used by DOS.
A fixed disk must also be formatted again if youchange the size of its DOS partition through the
FDISK command.
If you specify /S in the FORMAT command, theoperating system files are also copied from thedefault drive to the new disk or diskette in thefollowing order:
IIMIIO.COM
IIMDOS.COM
COMMAND.COM

6-100

FORMAT
CommandIf you specify /1, the target diskette is formatted
for single-sided use, regardless of the drive type.
If you specify /8, the target diskette is formatted
for use at 8 sectors per track. FORMAT will
default to 9 sectors per track usage if you do not
specify /8. Note that format always creates 9
physical sectors on each diskette track, but thatit instructs DOS to use only 8 sectors per track
if you use the /8 parameter. The /1 and /8
parameters are valid only for diskettes.
If you specify IV, FORMAT will prompt you for
a volume label which will be written on the disk.
The volume label cannot be used in place of
filenames as input to any of the DOS
commands. The volume label is for your use in
keeping track of your diskettes. The /Vparameter cannot be used with the /8
parameter.
The IB parameter causes FORMAT to create an
8 sector per track diskette with space allocatedfor the IBMBIO.COM and IBMDOS.COM
system modules. It does not place the systemmodules or the command processor on thediskette. This parameter is used to create adiskette on which any version of DOS (1.00,
1.10, or 2.00) can be placed through thatversion's SYS command. If the IB parameter is
not used, only DOS Version 2.00 can be placedon the diskette through the SYS command.

6-101

FORMAT
CommandThe IV and IS parameters cannot be used with
the IB parameter.
Notes:

6-102

1.

Formatting destroys any previously
existing data on the disk.

2.

During the formatting process, any
defective tracks are marked as reserved
to prevent the tracks from being
allocated to a data file.

3.

Directory entries for IBMBIO. COM
and IBMDOS.COM are marked as
hidden files, and therefore, they do notappear in any directory searchesincluding the DIR command.

4.

FORMAT will prompt you to enter a
volume label (volume identification) if
you have used the IV parameter. The
label can consist of from 1 to 11
characters. All characters acceptable infilenames are acceptable in the volume
label. Unlike filenames, however, thevolume label does not contain a period
between the eighth and ninth
characters.

FORMAT
Command

5.

FORMAT produces a status report,
tha t indicates:•

Total disk space•

Space marked as defective•

Space currently allocated to files(when /S is used)•

Amount of space available foryour files

6.

FORMAT determines the target drive
type and formats the disk or disketteaccordingly. For diskettes, if thediskette can be successfully read andwritten on only one side, the diskette isformatted for single-sided use; it can beused in either type of drive. If thetarget drive is dual-sided and you do
not use the /1 parameter, the disketteis formatted for dual-sided use; it will
not be usable in a single-sided drive.

7.

Fixed disks are already physicallyformatted (proper recording format)
when shipped by IBM. Whenformatting a fixed disk, FORMAT
checks all locations within the DOS
partition, but does not physicallyformat them again.

6-103

FORMAT
Command8.

If the /S parameter is used and thesystem has insufficient available
memory for FORMAT to load all threesystem modules, it will load as many
modules as it can, format the target
disk and write the modules that are inmemory. It must then read theremaining modules from the source
disk so they can be placed on the target
disk. If the source diskette has been
removed from the drive, anappropriate message will prompt you
to reinsert it before FORMAT cancontinue.

Example: By issuing the following command, the diskettein drive B is formatted and the operating systemfiles are also copied:

A>FORMAT I:/S/I
The system displays the following message:
Insert new diskette for drive I:
and strike any key when ready

After you insert the appropriate diskette andpress any key, the system displays this message:
Formatting...

while the diskette formatting is taking place.

6-104

FORMAT
CommandOnce the formatting is complete, the system
displays this message:
formatting ... format complete
System transferred
Volume label (11 character, ENTER for none)? MYDISI(
179712 bytes total disk space
xxxxx bytes used by system
xxxxxx bytes available on disk
format another (Y/N)?n

In the above example, note that MYDISK wasentered as the volume label.
Enter Y to format another diskette.
Enter N to end the FORMAT program.
When you format a fixed disk, you will see thefollowing message instead of the prompt toinsert a diskette:
Press any key to begin formatting x:

The x is replaced by the drive letter you typed.
The messages will otherwise appear in the samemanner.
Fixed disk formatting can take several minutes
because of the large size that can be allocated toDOS, so don't be alarmed if it takes some time
before you are prompted for the volume label.
You can tell that FORMAT is working by notingthat your fixed disk drive light is on.
6-105

GRAPHICS (Screen Print)
CommandPurpose:Prints the contents of a graphics display screen
on an IBM Personal Computer 80 cps Graphics
Printer when using a Color/Graphics Monitor
Adapter. This command increases the resident
size of DOS in memory by 736 bytes.

Format:

GRAPHICSType:Internal

External***
Remarks: Press the Shift-PrtSc keys to print the screen
contents on the printer. If the screen is in text
mode, the text is printed in under 30 seconds. If
the screen is in the graphics mode, each time the
PrtSc key is pressed, the following things occur:

6-106

•

In the 320x200 color graphics mode, thescreen contents are printed in up to fourshades of gray.

•In the 640x200 color graphics mode, thescreen is printed sideways on the paper. The
upper right corner of the screen is printed
on the upper left corner of the paper.

•

Printing may take as long as three minutes.

•

To invoke the screen print from a program,use the following coding example:
PUSH BP
INT 5
POP BPMKDIR (Make Directory)
CommandPurpose:Creates a sub-directory on the specified disk.

Format:

MKDIR [d:]pathorMD [d:]path

Type:Internal

External***
Remarks: If you do not specify a drive, the default drive isassumed.

Example: In this example, the command creates an entry
in the root directory for a new sub-directory
called LEVEL2:
MD\LEVE12

If you have done this and wish to add anotherdirectory level, you can use either of thefollowing two examples.
Use this example if your current directory is theroot directory:
MD \ LEVE12\LEVE13

6-107

MKDIR (Make Directory)
CommandAdds an entry for sub-directory LEVEL3 in the
LEVEL2 directory.
Use this example if your current directory is
LEVEL2:
MD LEVEL3

This command will do the same thing as theprevious example. Note that in the previous
example, the first \ tells DOS to begin its
directory search with the root directory. The
absence of a leading \ in the last example causes
DOS to begin at the current directory. Eachdirectory may contain the names of still otherdirectories.
Note: You can create as many
sub-directories as you wish, limited only byavailable disk space. However, you should
ensure that the maximum length of any
single path from the root directory to thedesired level is 63 characters, including
imbedded backslashes.

6-108

MODE
CommandPurpose:Sets the mode of operation on a printer or on adisplay connected to the Color/Graphics
Monitor Adapter, sets options for an
Asynchronous Communications Adapter, orcauses printer output to be routed to an
Asynchronous Communications Adapter.
Technical Note: When used in Option 1,
3, or 4, the MODE command causes printerand Asynchronous Communications
Adapter intercept code to be made resident
in memory. This increases the size of DOS
in memory by approximately 256 bytes.

Format:

MODE LPT#:[n] [,[m] [,P]]
or
MODEn
or
MODE [n] ,m[, T]or
MODE COMn:baud[,parity[,databits[,stopb#s[,P]]]]or
MODE LPT#:=COMn

6-109

MODE
Command

Type:Internal

External***
Remarks: A missing or invalid nor m parameter means thatthe mode of operation for that parameter is notchanged. The MODE command has four format
options:
Option 1 (For the printer)
MODE LPT#:[n] [,[m] [,P]]
where:#nmP

is 1, 2, or 3 (the printer number)is 80 or 132 (characters per line)is 6 or 8 (lines per inch vertical spacing)
specifies continuous retry on time-out
errorsFor example:
MODE LPT1: 132,8

sets the mode of operation of printer 1 to 132
characters per line and 8 lines per inch verticalspacing. The power-on default options for the
printer are 80 characters per line and 6 lines per
inch.

6-110

MODE
Command

The retry loop can be stopped by pressing
Ctrl-Break. To stop time-out errors from being
continuously retried when you have entered P,
you must use MODE Option 1 without
specifying P.
Option 2 (For switching Display Adapters,
and setting the display mode of theColor/Graphics Monitor Adapter)
MODEn

or
MODE [n],m[,T]where:
nis 40, 80, BW40, BWBO, C040, CaBO,
or MONO40

sets the display width to 40 characters
per line (for Color/Graphics Monitor
Adapter).

80

sets the display width to 80 characters
per line (for Color/Graphics Monitor
Adapter).

BW40

switches the active display adapter tothe Color/Graphics Monitor Adapter,and sets the display mode to Black andWhite (disables color) with 40
characters per line.
6-111

MODE
CommandBWBO

switches the active display adapter tothe Color/Graphics Monitor Adapter,and sets the display mode to Black andWhite (disables color) with 80
characters per line.

C040

switches the active display adapter tothe Color/Graphics Monitor Adapter,enables color, and sets the display
width to 40 characters per line.

coso

switches the active display adapter tothe Color/Graphics Monitor Adapter,enables color, and sets the display
width to 80 characters per line.

MONO switches the active display adapter tothe Monochrome Display Adapter(which always has display width of 80
characters per line).

6-112

m

is R or L (shift display right or left).

T

requests a test pattern used to align thedisplay.

MODE
Command

For readability, you can shift the display one
character (for 40 columns) or two characters (for80 columns) in either direction. If you specify T
in the MODE command, a prompt asks you if
the screen is aligned properly. If you enter Y thecommand ends. If you enter N the shift isrepeated followed by the same prompt. For
example,MODE 80,R,1

sets the mode of operation to 80 characters perline and shifts the display two character
positions to the right. The test pattern isdisplayed to give you the opportunity to further
shift the display without having to enter thecommand again.
Option 3 (For Asynchronous Communications
Adapter)
MOD E COMn: baud[ ,parity[,databits[ ,stopbits[,P]] ]]
where:nEither 1 or 2 (Asynchronous
Communications Adapter number)baud

110,150,300,600,1200,2400,4800,
or 9600

Note: Only the first two
characters are required;subsequent characters are ignored.
6-113

MODE
CommandparityEither N (none), 0 (odd), or E (even) (default = E)

databits

Either 7 or 8 (default = 7)

stop bits

Either 1 or 2 (if baud equals 110,
default = 2; if baud does not equal 110,
default = 1)

These are the protocol parameters. They are used
to initialize the Asynchronous Communications
Adapter. When you specify the protocol, youmust specify at least the baud rate. The otherparameters can be omitted, with the defaults
accepted, by entering only commas. For
example:MODE COM1:12,N,8,1,P

sets the mode of operation to 1200 baud rate,
no parity, eight databits, and one stopbit. To use
the defaults listed in the definitions above, youenter:
MODE COM1: 12"" P
The parity defaults to even, the data bits defaults
to seven, and the stopbits defaults to one.

6-114

MODE
Command

The P option indicates that the asynchronous
adapter is being used for a serial interface
printer. If you enter the P, time-out errors arecontinuously retried. You can stop the retry
loop by pressing Ctrl-Break. To stop thetime-out errors from being continuously retried
when you have entered P, you must reinitialize
the asynchronous adapter without entering theP.
Option 4 (To redirect parallel printer output
to an Asynchronous
Communications Adapter)
MODE LPT#:=COMn
where:#

Either 1, 2, or 3 (printer number)nEither 1 or 2 (Asynchronous
Communications Adapter number)

6-115

MODE
Command

All output directed to printer LPT# is redirectedto the asynchronous adapter n.
Notes:

6-116

1.

Before you can use MODE to redirect
parallel printer output to a serial
device, you must initialize the
Asynchronous Communications
Adapter by using Option 3 (see above).
If that serial device is a printer, yourserial initialization command should
also include the P parameter.

2.

MODE LPT#:[n] [,m] disables theredirection for the printer designatedby the#.

PATH (Set Search Directory)
CommandPurpose:

Causes specified directories to be searched forcommands or batch files that were not found by
a search of the current directory.

Format:

PATH [[d.·]path[[;[d.·]path] ... ]]Type:

Internal

External***
Remarks: You may specify a list of drives and path names,
separated by semicolons (note that path names
must be specified and will not default to current
directory). Then, when you enter a commandthat is not found in the current directory of thedrive that was specified (or implied) with thecommand, DOS searches the named directories
in the sequence you entered them. The current
directory is not changed.
Entering PATH with no parameters causes DOS
to display the names that were specified on aprevious PATH command (that is, the searchpaths currently defined to DOS). Entering
PATH with only a semicolon (PATH;) resets thesearch path to null (no extended search path).
This is the default when DOS is started. In thiscase, DOS searches only the current directoryfor commands and batch files.

6-117

PATH (Set Search Directory)
Command

Example: In this example, assume the program
MYPROG.COM resides only in directory
MYDIR on drive B, and that the default drive isdrive A:
PATH LEVEl2; LEVEL2 LEVEL3;B: MYDIR

This command instructs DOS to look in thecurrent directory of the drive specified, followedby A: LEVEL2, then A: LEVEL2 LEVEL3 then
B: MYDIR until it finds the command you haveentered. If the command entered is not found inany of the directories specified in PATH, themessage Bad command or filename isdisplayed.
In the previous example, if you enter thecommand:
MYPROG

6-118

PATH (Set Search Directory)
Command

DOS searches four directories, finding the
program MYPROG in B:\MYDIR.
Notes:
1.

Erroneous information in the paths,
such as invalid drive specifications or
imbedded delimiters, will not be
detected until DOS actually needs tosearch the specified paths.

2.

If a path is specified that no longer
exists at the time DOS uses it to search
for a command or batch file, DOS
ignores that path and goes on to the
next.

6-119

PRINT
CommandPurpose:Prints a queue (list) of data files on the printerwhile you are doing other tasks on the computer.
Up to 10 filenames can be queued for printing at
one time. The first time this command is issued,
it increases the resident size of DOS in memory
by approximately 3200 bytes.

Format:PRINT [[d:] [/i'lename[.ext]] [IT] [Ie] [lP] ... ]Type:Internal

External***
Remarks: You can enter more than one filename on thecommand line, each with appropriate
parameters. Global filename characters * and?
are allowed in the filename and extension. Only
files in the current directory can be queued forprinting. Once a file has been queued, you canchange the current directory without affecting
the printing of the files already in the print
queue.

IT sets the terminate mode. All queued files arecanceled from the print queue. If a file iscurrently being printed, the printing stops, acancellation message is printed, the paper isadvanced to the next page, and the printer's
alarm sounds.

6-120

PRINT
CommandIe sets the cancel mode. Allows you to selectwhich file or files to cancel. The preceding
filename and all following filenames entered on
the command line are canceled from the print
queue until a IP is found on the command line,or the Enter key is pressed.

IP sets the print mode. The preceding filename
and all following filenames are added to theprint queue until a Ie is found on the command
line, or the Enter key is pressed.
Global filenalne characters * and? are allowed in
the filename and extension. You can enter morethan one filename on the command line, eachwith appropriate parameters.
If no I parameters are specified and the Enter
key is pressed, the files listed on the commandline are queued for printing (lP is assumed).
If PRINT is entered with no parameters, PRINT
displays the names of the files currently in theprint queue.
The first time the PRINT command is executed
after you start your system, the following
message is displayed on the display screen:
Name of list device [PRN):

6-121

PRINT
CommandThis allows you to specify the output list device,
LPTl, LPT2, LPT3, PRN, COMl, COM2, AUX,
etc. The default is PRN, and will be selected if
you press Enter.
Note: Be sure the device you name isphysically attached to your system; naming
a nonexistent device will cause
unpredictable system behavior.
The files are queued for printing in the order
entered. After each file is printed, the printerpaper is advanced to the next page. Any tabcharacters found are expanded with blanks to
the next 8-column boundary.
If PRINT encounters a disk error while
attempting to read the file to be printed, PRINT
will cause:

6-122

•

The file currently printing to be canceled•

The disk error message to be printed on theprinter•

The printer paper to be advanced to thenext page and the alarm to be sounded•

The remaining files in the print queue to beprintedPRINT
Command

If the IT or I C parameters are used to cancel afile or files currently being printed:•

The printer alarm sounds.

•

A file cancellation message prints on theprinter. If IT, All files canceled byoperator. If I C, the name of the file
followed by File canceled by operator,
where File is the name of the file.

•

The printer paper advances to the next
page.

•

If all files in the print queue have not beencanceled, printing resumes with the first fileremaining in the print queue.

6-123

PRINT
CommandNotes:
1.

The disk containing the files being
printed must remain in the specified
drive until all printing is complete. Any
file in the print queue must not bealtered or erased until after it has been
printed.

2.

The printer cannot be used for any
other purpose while PRINT has data toprint. Any attempt to use the printer(Shift-PrtSc, LLIST, LPRINT, etc.)
results in an "out-of-paper" or"time-out" indication until all files
have been printed or printing isterminated (/1). Using Ctrl-PrtSc will
result in a "not ready" error message.
You should press Ctrl-PrtSc again andreply A to the error message.

Example: In this example, the PRINT command is being
used for the first time since system was started.
The command:
PRINT a:templ.tst

has just been entered, DOS responds with:
Name of list device (PRN]:

Press the Enter key to send output to theprinter.
6-124

PRINT
Command

Then it adds the file TEMPI. TST from drive A
to the print queue and sends the output to thedevice "PRN" printer. The command:
PRINT ITempties the print queue. Any other informationon the line is ignored. The command:
PRINT temp.*/C

removes all TEMP.??? files from the print
queue that have the same drive letter as thedefault drive. The command:
PRINT a:templ.tstlC a:temp2.tst a:temp3.tst

removes the three files TEMPI, 2, and 3 on
drive A from the print queue. The command:
PRINT templ.tstlC temp2.tst/P temp3.tst

removes file TEMP1.TST from the print queue,
adds the files TEMP2.TST and TEMP3.TST to
the print queue. The command:
PRINT templ.tst temp2.tst temp3.tstlC

adds files TEMPI.TST and TEMP2.TST to theprint queue, then removes TEMP3. TST fromthe print queue.

6-125

RECOVER
CommandPurpose:Recovers files from a disk that has developed adefective sector . You can recover the file that
contains the bad sector (minus the data in thebad sector), or all the files on the disk can berecovered if the directory has been damaged.

Format:RECOVER [d:] fpathifilename [.ext]
or
RECOVERd:

Type:

Internal

External***
Remarks: The file named by filename is the file to be
recovered. If you do not specify a drive, thedefault drive is used. If you do not specify apath, the current directory is used. The size ofthe recovered file is a multiple of the DOS
allocation unit size. In most cases, this is larger
than the original file size. Text files will
normally require re-editing to remove unwanted
data from the end of the recovered file before
they can be used for normal processing.
In the second format shown, RECOVER
assumes the directory is damaged, and recovers
all files on the specified disk.

6-126

RECOVER
Command

If the global filename characters * and? are usedin the filename or extension, only the first filethat matches the filespec will be recovered.
RECOVER only recovers one file at a time whena filespec is entered.

Example: For this example assume the disk file to be
recovered is MYPROG:RECOVER A:MYPROGThis command causes the disk file MYPROG on
drive A to be read sector-by-sector, skipping thebad sectors. The bad sectors are allocated in asystem table, thus preventing future allocationsof that sector. The filename is not changed.
The following example shows how to recover
the contents of an entire disk from drive A:
RECOVER A:

This command causes the disk file allocationtable on drive A to be scanned for chains ofallocation units. A new root directory is createdfor each chain of allocation units in the form:
FILEnnnn.REC

6-127

RECOVER
Command

Where nnnn is a sequential number starting with0001. Each FILEnnnn.REC points to one of therecovered files on the disk.
Note: This form of the RECOVER
command should only be used if thedirectory of the disk has become unusable.
Because RECOVER has no way to knowwhether the data in the directory is valid or
not, it must assume that the entire directory
is invalid, and therefore recovers all files
into filenames of the form shown above,
including any files for which there may still
have been valid directory entries.

6-128

RENAME (or REN)
CommandPurpose:Changes the name of the file specified in thefirst parameter to the name and extension givenin the second parameter. If a valid drive is
specified in the second parameter, the drive isignored.

Format:REN[AME] [d:] [path]filename[.ext] filename[.ext]

Type:Internal

External***
Remarks: You can use the abbreviated form REN for the
RENAME command. You can also use theglobal characters? and * in the parameters. For
more information about global characters, refer
to "Global Filename Characters" in this chapter.
A path can be specified only with the first
filename; the file will remain in the same
directory after its name has been changed.

6-129

RENAME (or REN)
Command

Example: The command:
RENAME B:ABODE HOME

renames the file ABODE on drive B to HOME.
The command:
REN B:ABODE *.XY

renames the file ABODE on drive B to
ABODE.XY.
The command:
REN B: LEVEL2 MYPROG.COM MYPROG1.COM

renames the file MYPROG .COM in directory
LEVEL2 on drive B to filename
MYPROGl.COM.

6-130

RESTORE (Fixed Disk)
CommandPurpose:Restores one or more files from diskettes to a
fixed disk.

Format:RESTORE d: [d:] [path] [filename] [.ext] [IS] [lP]

Type:Internal

External***
Remarks: The files being restored must have been placedon the diskettes by the BACKUP command. The
first parameter you specify is the backup
diskette drive. The second parameter is the
fixed disk file you want to restore.
Files are restored to the current directory if you
do not specify a path. If you do not specify afilename or extension, then all files backed up
from the directory will be restored.
Global filename characters are allowed in thefilename, and will cause all of the files matching
the filename to be restored. For example,
entering:
RESTORE A: C:*.DAT

restores each file from the backup diskettes
with an extension of .DAT that had been backed
up from the current directory.

6-131

RESTORE (Fixed Disk)
Command

The parameter IS causes backed up files in all
sub-directories to be restored in addition to thefiles in the specified directory itself. This
includes sub-directories at all levels beyond thespecified directory.
The parameter IP will cause RESTORE toprompt you before restoring files that havechanged since they were last backed up, or thatare marked read-only. You can then choose torestore the file or not. Read-only is a fileattribute that an application can set byinterfacing with DOS internally. The two DOS
system files (IBMBIO.COM and IBMDOS.COM)
are marked read-only when they are created by
the FORMAT and SYS commands.
The following example restores all files on the
backup diskettes to fixed disk drive C:
RESTORE A: C:\ /S

The next example restores three different files
from the backup diskettes to the default fixed
disk drive:
RESTORE A: \ level1\ filel. dat
RESTORE A: \level1\level2\flle2.dat
RESTORE A: \level1\level3\file3.dat

6-132

RESTORE (Fixed Disk)
Command

When RESTORE prompts you to insert the
backup diskette, make sure you insert the firstdiskette that might contain the file you want torestore. If you are not sure, insert backup
diskette number one. If the file is not on thediskette you inserted, RESTORE will prompt
you to insert the next diskette.
If you used global filename characters,
RESTORE will prompt you to insert the next
diskette after it has restored all files on the
backup diskette that match the specified
filename.
The RESTORE command sets the
ERRORLEVEL (see Batch Commands) as
follows:oNormal completion1

No files were found to restore

3

Terminated by user (Ctrl-Break or ESC)

4

Terminated due to error

These codes can be used with the batchprocessing IF subcommand to control
subsequent error level processing.

6-133

RMDIR (Remove Directory)
CommandPurpose:Removes a sub-directory from the specified
disk.
RMDIR [d:]pathorRD [d:]path

Type:Internal

External***
Remarks: The directory must be empty before it can beremoved with the exception of the "." and "oo"entries. The last directory name in the path isthe directory to be removed.

Example: In this example, the command:
RD B:\ LEVEI2\ LEVEl3

removes the entry for LEVEL3 from directory
LEVEL2.
Note: The root directory and the current
directory cannot be removed.

6-134

SYS (System)
CommandPurpose:Transfers the operating system files from thedefault drive to the specified drive.

Format:

SYS d:Type:

Internal

External***
Remarks: The directory of the disk in the specified drive
must be completely empty, or the disk musthave been formatted by a FORMAT d:/S or
FORMAT d:/B command to contain directory
entries for the DOS files IBMBIO.COM andIBMDOS. COM. This is necessary because DOS
startup requires these files to occupy the firsttwo directory entries, and because
IBMBIO.COM must reside on consecutive
sectors on the disk.
Note: SYS lets you transfer a copy of DOS
to an application program diskette designed
to use DOS, but sold without it. In thiscase, the space required for the DOS files
has already been allocated, although the
DOS files are not actually present. The SYS
command will transfer the files to theallocated space.

6-135

TIME
CommandPurpose:Permits you to enter or change the time known
to the system. Whenever you create or add to afile, the time is recorded in the directory. You
can change the time from the console or from abatch file.

Format:TIME [bb:mm:ss.xx]

Type:Internal

External***
Remarks: If you enter a valid time with the TIME
command, the time is accepted, and the systemprompt appears. Otherwise, the TIME command
displays the following prompt:
Current time is hh:mm:ss.xx
Enter new time: _where:bb

is a one- or two-digit number from 0-23
(representing hours)
mm is a one- or two-digit number from 0-59
(representing minutes)
ss
is a one- or two-digit number from 0-59
(representing seconds)
xx is a one- or two-digit number from 0-99
(representing hundredths of a second)

6-136

TIME
CommandNotes:
1.

To leave the time as is, press Enter.

2.

If you enter any information (forexample, just the hours, and press
Enter), the remaining fields are set to
zero.

3.

Any time is acceptable as long as thedigits are within the defined ranges.

4.

The valid delimiters within the time are
the colon (:) separating the hours,
minutes, and seconds, and the period(.) separating the seconds and thehundredths of a second.

5.

If you specify an invalid time ordelimiter, you receive an Invalid timemessage.

Example: In this example, once you press Enter, the time
known to the system is changed to 13:55:00.00.
A>TIME
Current time is 00:25:16.65
Enter new time: 13:55_

6-137

TREE (Display Directory)
CommandPurpose:

Displays all of the directory paths found on thespecified drive, and optionally lists the files ineach sub-directory.

Format:TREE [d:][/F]

Type:Internal

External***
Remarks: If no drive is specified, the default drive isassumed.
For each directory found, its full path name will
be displayed, along with the names of any
directories defined within it (these are called
sub-directories in the output). If the IF
parameter is used, the names of all files in eachsub-directory will also be displayed.

6-138

TREE (Display Directory)
Command

Example: In this example, the command:
TREE B:/F > TREE.LST

causes all directories on drive B to be listed.
The output will be placed in file TREE.LST in
the current directory of drive B, and will containthe names of all sub-directories and files at eachdirectory level.
Following is an example of a directory pathlisting. If the disk called MYDISK in drive A had
the following directory structure:

MYPROI1.ASM
MYPROG2.ASM

No 1111.

LEVE13
MYPROI1.EIE

6-139

TREE (Display Directory)
Commandthen TREE would display:
DIRECTORY PATH LISTING FOR VOLUME MYDISKPath: \SOURCE
Sub-directories: None
Files:

MYPROGl .ASM
MYPROG2 .ASM

Path: \LEVEL2
Sub-directories: LEVEL3
Files:

None

Path: \LEVEL2\LEVEL3
Sub-directories: None
Files:

MYPROGl .EXE

The following example lists all the
sub-directories and filenames from drive A on
the printer:
TREE A:/F >PRN

6-140

TYPE
CommandPurpose:

Displays the contents of the specified file on thescreen.

Format:TYPE [d:] fpatblfilename[. ext]

Type:Internal

External***
Remarks: The data is unformatted except that tabcharacters are expanded to an eight-characterboundary; that is, columns 8, 16, 24, etc.

6-141

TYPE
CommandNotes:
1.

Press Ctrl-PrtSc if you want thecontents of a file to be printed as it isbeing displayed. You can also redirect
the output to a file or the printer.

2.

Text files appear in a legible format;
however, other files, such as object
program files, may appear unreadable
due to the presence of nonalphabetic
or nonnumeric characters.

3.

You must specify a filespec.

4.

Global filename characters are notallowed in the filename or extension. If
glo bal filename characters are used in
the filename or extension, the message
File not found will appear.

Example: In this example, the file MYPROG.ONE on thediskette in drive B is displayed on the screen:nPE B: myprog.one

6-142

VER (Version)CommandPurpose:

Displays the DOS version number that you areworking with on the display screen.

Format:

VER

Type:

Internal***

External

Remarks: The DOS version consists of a single-digit major
version number, followed by a period, followed
by a two-digit minor revision level.

Example: A>VER
IBM Personal Computer DOS Version 2.00

6-143

VERIFY
CommandPurpose:Verifies that the data written on a disk has beencorrectly recorded.

Format:VERIFY [ON I OFF]Type:

Internal

External***
Remarks: VERIFY ON remains on until it is turned off
through the SET VERIFY System Call or a
VERIFY OFF command.
When ON, DOS performs a verify operation
following each disk write operation, to verify
that the data just written can be read without
error. Because of the extra time required toperform the verification, the system runs slower
when programs write data to disk.
Entering VERIFY with no parameters causes
DOS to display the current state (on or off) of
the verify feature.
Example: This example causes the verify feature to beturned on:
A>VERIFY ON

This example displays the current status:
A>VERIFY
VERIFY is on

6-144

A>

VOL (Volume)
CommandPurpose:

Displays the disk volume identification of thespecified drive.

Format:VOL [d:]Type:Internal

External***
Remarks: If you do not specify a drive, the default drive isassumed.

Example: A>VOL
Volume in drive A is MYDISK
A>

6-145

Summary of DOS Commands

The following chart is provided for quickreference. The section called "Format Notation"at the beginning of this chapter explains thenotation used in the format of the commands.
Note: In the column labeled Type, the I
stands for Internal and the E stands forExternal.

CommandType Purpose

Format(Batch)I

Executes batch
file[d:Vilename[parameters]

ECHO

I

Inhibits screen
displayECHO[ON I OFFmessage]

FOR

I

Interactive
execu tion ofcommands

FOR %%variable
IN (set) DO
command

GOTO

I

Transfers control GOTO label
to line following
the label

IF

I

Conditional
execu tion ofcommands

PAUSE

I

Provides a system PAUSE [remark]wait

IF [NOT] conditioncommandFigure 1 (Part 1 of 2). DOS Batch Processing Commands

6-146

FormatCommandType Purpose

REM

I

Displays remarks REM [remark]

SHIFT

I

Shift command
lines

SHIFT

Figure 1 (Part 2 of 2). DOS Batch Processing Commands

CommandType Purpose

FormatASSIGNE

Routes requests
to a different
drive

ASSIGN [x=y [... ]]BACKUPE

Backs up fixed
disk files

BACKUP[d:] [path]r/ilename] [. ext]d:[IS] [1M] [I A][D:mm-dd-yy]

BREAK

I

Checks forcontrol break

BREAK[ON I OFF]

CHDIR

I

Change current
directory

CHD IR [[d: ]path]orCD [[d: ]path]

CHKDSKE

Checks disk andreports status

CLS

I

Clears the display CLS
screenCHKDSK[d:] [filename] [.ext][IF] [IV]Figure 2 (Part 1 of 6). DOS Commands

6-147

CommandType Purpose

FormatCOMP

E

Compares files

COMP[d:] [path] r/ilename[.ext] ][d:] [path] r/ilename[.ext] ]COPY

I

Copies files

COpy [IA] [lB][d:] [path lfilename[.ext] [IA] [lB][d:] [path] r/ilename[.ext]] [IA] [lB] [IV]orCOpy [IA] [lB][d:] [path lfilename[.ext] [IA] [lB][+[d:] [pathlfilename[.ext] [IA] [lB] ... ][d:] [path] r/ilename[. ext] ] [IA] [lB] [IV]

DATE

I

Enter date

DATE [mm-dd-yy]

DIR

I

Lists filenames

DIR [d:] [path][filename [.ext]][lP][lW]

Comparesdiskettes

DISKCOMP[d:] [d:]DISKCOMP E[11 ][/8]

DISKCOPY E

Copies diskettes

Figure 2 (Part 2 of6). DOS Commands
6-148

DISKCOPY [d:][d:] [/1]CommandType Purpose

ERASE

I

Deletes files

FormatERASE[d:] [patb] [filename][.ext]orDEL[d:] [patb] [filename][.ext]FORMATE

Formats diskette FORMAT [d:][/S][11] [18] [IV] [lB]

GRAPHICS E

Prints graphics
display screen

GRAPHICSMKDIR

Creates a
sub-directory

MKDIR [d:]patb

IorMD [d:]patb
Figure 2 (Part 3 of 6). DOS Commands

6-149

CommandType Purpose

MODE

E

Sets mode on
printer/display

Format
MODE LPT#:[n][,[m][,P]]

or
MODEn

or
MODE [n],m[,T]orMODECOMn:baud[ ,parity [,data bits[,stopbits[,P]]] ]or
MODE LPT#:=
COMn

PATH

I

Searches
directories forcommands orbatch files

PATH[[d:]path[ [; [d:]path] ... ]]

PRINT

E

Queues andprints data files

PRINT[[d:] [ji'lename[. ext]][/T] [lC] [lP] ... ]Figure 2 (Part 4 of 6). DOS Commands

6-150

CommandType Purpose

FormatRECOVERE

RECOVER[d:] [path Vilename[.ext]

Recovers files
from disk or
diskette

or
RECOVERd:
RENAMEI

Renames files

REN[AME][d:] [pathVilename[. extVilename[. ext]

RESTOREE

Restores diskette RESTOREd:
files to fixed disk [d:] [path] [ti"lename][.ext] [IS] [IP]

RMDIR

I

Removes a
sub-directory

RMDIR [d:]pathorRD [d:]path

SYS

E

Transfers DOS

SYSd:

TIME

I

Enter time

TIME [hh:mm:ss.xx]

TREE

E

Displays all
directory paths

TREE [d:] [IF]

TYPE

I

Displays filecontents

TYPE[d:] [pathVilename[.ext]VER

I

Displays version
numberVER

Figure 2 (Part 5 of 6). DOS Commands

6-151

CommandType Purpose

FormatVERIFYI

Verifies data

VERIFY[ON I OFF]VOL

I

Displays volumeiden tifica tio n

VOL [d:]Figure 2 (Part 6 of 6). DOS Commands

6-152

Contents
Introduction.. . .. . . .. .. .. .. . ...... .. . . .. .

7-3

How to Start the ED,LINProgram ......... 7-4
Editing an "Existing File' ............. ~ . 7-4
EditingaNewFile ~""""""".""" . 7-5

TheEDLINC()mmand Parameters ," ..... .

7-7

Notes:7-2

Introduction

In this chapter, you will learn how to use the Line
Editor (EDLIN) program.
You can use the Line Editor (EDLIN) to create,change, and display source files or text files.
Source files are unassembled programs in source
language format. Text files appear in a legible
format.
EDLIN is a line text editor that you can use to:•Create new source files and save them•Update existing files and save both theupdated and original files•

Delete, edit, insert, and display lines•

Search for, delete, or replace text within one
or more lines

The text of files created or edited by EDLIN is
divided into lines of varying length, up to 253
characters per line.
Line numbers are generated and displayed by
EDLIN during the editing process, but are notactually present in the saved file.

7-3

When you insert lines, all line numbers following
the inserted text advance automatically by the
number of lines inserted. When you delete lines,
all line numbers following the deleted text
decrease automatically by the number of lines
deleted. Consequently, line numbers always goconsecutively from 1 through the last line number.
Note: EDLIN will erase the original backup
copy (.BAK) of the file when you issue an E
(end edit) command, or if the disk space isrequired during the editing session to satisfy a
W (write lines) command.

How to Start the EDLIN Program

To start EDLIN, enter:
EDLIN (d:](path]filename[.extH/Bj

Editing an Existing File
If the specified file exists on the designated ordefault drive, the file is loaded into memory until
memory is 75% full. If the entire file is loaded, thefollowing message and prompt is displayed:
End of input file*

7-4

You can then edit the file.
Note: If you have not used the /Bparameter, EDLIN will stop loading the filewhen the first Ctrl-Z is encountered in the
file's text. If you wish to edit a file that is
known to contain embedded Ctrl-Z characters(end-of-file marks), you should use the /Bparameter. EDLIN will then process the entire
file regardless of any embedded end-of-filemarks.
Notice that the prompt for EDLIN is anasterisk (*).
If the entire file cannot be loaded into memory,
EDLIN loads lines until memory is 75% full, thendisplays the * prompt. You can then edit the
portion of the file that is in memory.
To edit the remainder of the file, you must write
some of the edited lines to diskette in order to freememory so that you can load unedited lines fromdiskette into memory. Refer to the Write Lines
and Append Lines commands in this chapter forthe procedure you will use.

Editing a New File
If the specified file does not exist on the drive, a
new file is created with the specified name. The
following message and prompt are displayed:
New file*
You can now create a new file by entering thedesired lines of text. To begin entering text, youmust enter an I command to insert lines.

7-5

When you have completed the editing session, you
can save the original and updated (new) files byusing the End Edit command. The End Edit
command is discussed in this chapter in the section
called "The EDLIN Commands." The original fileis renamed to an extension of .BAK, and the new
file has the filename and extension you specified in
the EDLIN command.
Note: You cannot edit a file with a filename
extension of .BAK with EDLIN because thesystem assumes it is a backup file. If you findit necessary to edit such a file, rename the file
to another extension; then start EDLIN andspecify the new name.

7-6

The EDLIN Command Parameters

Parameter

Definition

line

Denotes when you must specify a line
number.
There are three possible entries that you
can make using this parameter:
1.

Enter a decimal integer from 1-65529.
If you specify a number greater than
the number of lines that are inmemory, the line will be added after
the last line that exists.
Line numbers must be separated fromeach other by a comma or space.
OR

2:Enter a pound sign (#) to specify theline after the last line in memory.
Entering a # has the same effect as
specifying a number greater than thenumber of lines in memory.

7-7

Parameter

Definition

line

OR

3.

Enter a period (.) to specify the current
line.
The current line indicates the locationof the last change to the file, but it is
not necessarily the last line displayed.
The current line is marked by anasterisk (*) between the line number
and the first character of text in theline. For example:
lO:*FIRST CHARACTER OF TEXTn

Denotes when you must specify lines.
Enter the number of lines that you want towrite to diskette or load from diskette.
You only use this parameter with the Write
Lines and Append Lines commands. These
commands are meaningful only if the file tobe edited is too large to fit in memory.

stringDenotes when you must enter one or morecharacters to represent text to be found,replaced, deleted, or to replace other text.
You only use this parameter with the
Search Text and Replace Text commands.

7-8

The EDLIN Commands

This section describes the EDLIN commands andtells how to use them. The commands are inalphabetical order; each with its purpose, format
and remarks. Examples are provided whereappropriate.

Information Common to All EDLIN
Commands
The following information applies to all EDLIN
commands:•

With the exception of the Edit Linecommand, all commands are a single letter.

•

With the exception of the End Edit and Quit
Edit commands, commands are usually
preceded and! or followed by parameters.

•Enter commands and string parameters inuppercase or lowercase, or a combination of
both.

•

Separate commands and parameters withdelimiters for readability; however, a delimiteris only required between two adjacent line
numbers. Remember, delimiters are spaces orcommas.

•Commands become effective only after youpress the Enter key.

7-9

•

Stop commands by pressing the Ctrl-Break
keys.

•

For commands producing a large amount of
output, press Ctrl-Num Lock to suspend thedisplay so that you can read it before it scrolls
away. Press any other character to restart thedisplay.

•

Use the control keys and DOS editing keys,
described in Chapter 3, while using EDLIN.
They are very useful for editing within a line,
while the EDLIN commands can be used forediting operations on entire lines.

•

The prompt from EDLIN is an asterisk (*).

•

It is possible to refer to line numbers relative

to the current line. Use a Minus (-) sign and anumber to indicate a line before the current
line. Use a Plus (+) sign and a number toindicate a line after the current line. For
example:-10,+10L

This command displays 10 lines before thecurrent line, the current line, and 10 lines
after the current line.

7-10

•

Multiple commands can be entered on one
command line. When you enter the commandto edit a single line using [line], you must use asemicolon to separate the commands on theline. In the case of the Search or Replacecommand the [string] can be terminated by
Ctrl-Z (F6) instead of the Enter key. Otherwise,
one command can follow another without any
special delimiting characters. For example:
15;-5,+5Ledits line 15 and then displays lines 10
through 20 on the screen.
•

Control characters can be inserted into thetext, or can be used in the strings for the
Search text and Replace text commands. To
enter a control character, press Ctrl-V, thenenter the desired control character inuppercase. For example, the sequence Ctrl-V,
followed by Z generates the control character
Ctrl-Z.

7-11

A ppend Lines
CommandPurpose:Adds the specified number of lines from disk to
the file being edited in memory. The lines areadded at the end of the current lines in memory.

Format:[n]ARemarks: This command is only meaningful if the file
being edited is too large to fit in memory. As
many lines as possible are read into memory forediting when you start EDLIN.
To edit the remainder of the file that will not fit
into memory, you must write edited lines inmemory to disk before you can load uneditedlines from disk into memory by using the
Append Lines command. Refer to the Write
Lines command for information on how to write
edited lines to disk.
Notes:

7-12

1.

If you do not specify the number oflines, lines are appended to memory
until available memory is 75% full. No
action is taken if available memory isalready 75% full.

2.

The message End of input file isdisplayed when the Append Lines
command has read the last line of thefile into memory.

Copy Lines
CommandPurpose:Copies the lines in the specified range to the line
number specified by the third parameter. The
new data is placed ahead of the line that was
specified in the third parameter. This thirdparameter is not optional. The operation isrepeated the number of times specified in count.

Format:[line], [line] ,line Lcount]C

Remarks: The parameter count defaults to 1. To repeat text
specify the number of times the operation is tobe performed in count. If the first parameter orthe second parameter is omitted, the default isthe current line. This effectively copies thecurrent line to the specified line. The file isrenumbered accordingly. The first of the copiedlines becomes the current line. For example:
1,5,8C

copies lines 1 through 5 to line 8. Line 8
becomes the current line.
Note: The line numbers must not overlap
or an error is reported. Also, the characters- and + are not allowed in the count field.

7-13

Delete Lines
CommandPurpose:Deletes a specified range of lines.

Format:[line] [,line] D

Remarks: The line following the deleted range becomesthe current line, even if the deleted range
includes the last line in memory. The current
line and any following lines are renumbered.
Default values are supplied if either one or bothof the parameters are omitted.
If you omit the first parameter, as in:,lineD

deletion starts with the current line and ends
with the line specified by the second parameter.
The beginning comma is required to indicate theomitted first parameter.

7-14

Delete Lines
CommandIf you omit the second parameter, as in:
lineD

or
line,D

only the one specified line is deleted. If you
omi t both parameters, as in:Donly the current line is deleted, and the line that
follows becomes the current line.

Example: Assume that you want to edit the following file.
The current line is line 29.
1: This is a sample file
2: used to demonstrate
3: line deletion
4: and dynamic
5: line number generation.

•••
25: See what happens
26: to the lines
27: and line numbers
28: when lines are
29:*deleted.

7-15

Delete Lines
CommandIf you want to delete a range of lines, from 5 -25,
enter:
5,250

The result is:
1: This is a sample file
2: used to demonstrate
3: line deletion
4: and dynamic
5:*to the lines
6: and line numbers
7: when lines are
8: deleted.

Lines 5-25 are deleted from the file. Lines 26-29
are renumbered to 5-8. Line 5 becomes thecurrent line. If you want to delete the current
and the following line, enter:,60

The result is:
1: This is a sample file
2: used to demonstrate
3: line deletion
4: and dynamic
5:*when lines are
6: deleted.

Lines 5-6 are deleted from the file. Lines 7-8 are
renumbered to 5-6. Line 5 is still the current
line, but now it has different text.
7-16

Delete Lines
CommandIf you want to delete a single line, say line 2,
enter:
20

The result is:
1: This is a sample file
2:*line deletion
3: and dynamic
4: when lines are
5: deleted.

Line 2 is deleted. Lines 3-6 are renumbered to
2-5. The new line 2 becomes the current line. If
you want to delete only the current line, enter:o
The result is:
1: This is a sample file2:*and dynamic
3: when lines are
4: deleted.

The current line, line 2, is deleted. Lines 3-5 are
renumber~d to 2-4. The new line 2 becomes thecurrent line.

7-17

Edit Line
CommandPurpose:Allows you to edit a line of text. You must enter
the line number of the line to be edited, or entera period (.) to indicate the current line.

Format:[line]

Remarks: If you just press Enter, you specify that the line
after the current line is to be edited.
The line number and its text are displayed andthe line number is repeated on the line below.
You can use the control keys and the editing
keys, described in Chapter 3, to edit the line, or
you can replace the entire line by typing new
text.
When you press the Enter key, the edited line isplaced in the file and becomes the current line.
If you decide not to save the changed line, press
either Esc or Ctrl-Break instead of Enter. The
original line remains unchanged. Pressing theEnter key with the cursor at the beginning of
the line has the same effect as pressing Esc or
Ctrl-Break.
If the cursor is in any position other than the
beginning or the end of a line, pressing Entererases the rest of the line.

7-18

Edit Line
Command

Example: Assume that you want to edit line 6. The
following display wOl,lld appear on the screen:*6

6: This is a sample unedited line.
6: _The first line is your request to edit line 6,
followed by the two-line display response.
If you want to move the cursor to the letter u,press F2 and enter:u

The result is:*6

6: This is a sample unedited line.
6: This is a sample_

If you want to delete the next two charactersand keep the remainder of the line, press Del
twice; then press F3.
The result is:*6

6: This is a sample unedited line.
6: This is a sample edited line._

7-19

Edit Line
Command

N ow you can take one of the following actions:

7-20

•

Press Enter to save the changed line.

•

Extend the changed line by typing more
text. You are automatically in insert mode
when the cursor is at the end of a line.

•

Press F5 to do additional editing to thechanged line without changing the original
line.

•

Press Esc or Ctrl-Break to cancel thechanges you made to the line. The originalcontents of the line will be preserved.

End Edit
CommandPurpose:Ends EDLIN and saves the edited file.

Format:E

Remarks: The edited file is saved by writing it to the driveand filename specified when you started EDLIN.
The original file, the one specified when EDLIN
was started, is given a . BAK filename extension.
A . BAK file will not be created if there is no
original file; that is, if you created a new fileinstead of updating an old file during the editing
session.

7-21

End Edit
Command

EDLIN returns to the DOS command processor,
which displays the command prompt.
Notes:

7-22

1.

Be sure your disk has enough freespace to save the entire file. If yourdisk does not have enough free space,
only a portion of the file is saved. The
portion in memory that is not written
to disk is lost. In this case, youroriginal file will not be renamed to. BAK, and the portion of data that was
written to disk will have a filename
extension of $$$.

2.

EDLIN appends a carriage return, line
feed sequence to the end of the file ifthey were not already present, todelimi t the last line of text in the file.
Also, a Ctrl- Z character is added as thelast character in the saved file. This
serves as an end-of-file mark.

Insert Lines
CommandPurpose:Inserts lines of text immediately before thespecified line. When you create a new file, youmust enter the Insert Lines command before
text can be inserted.

Format:[line] I

Remarks: If you do not specify line, or if you specify line
as a period (.), the insert is made immediately
before the current line.
If the line number you specify is greater thanthe highest existing line number, or if you
specify # as the line number, the insertion ismade after the last line in memory.
EDLIN displays the appropriate line number sothat you can enter more lines, ending each line
by pressing Enter. During the insert mode ofoperation, successive line numbers appear
automatically each time Enter is pressed.
You must press Ctrl-Break to discontinue theinsert mode of operation.
The line that follows the inserted lines becomesthe current line, even if the inserted lines areadded t<> the end of the lines in memory. The
curren t line and any remaining lines are
renumbered.

7-23

Insert Lines
Command

Example: Assume that you want to edit the following file.
Line 3 is the current line:
1: This is a sample file
2: used to demonstrate
3:*line deletion
4: and dynamic
5: line number generation.

If you want to insert text before line 4, the entry
and immediate response look like this:
*41
4:*_

Now, if you want to insert two new lines of text,
enter:*4 I
4:* first new line of text
5:* Second new line of text

6:*
and press Ctrl-Break.
The original lines 4 and 5 are now renumbered
to lines 6 and 7.

7-24

Insert Lines
CommandIf you display the file with a List Lines
command, the file looks like this:
1: This is a sample file
2: used to demonstrate
3: line deletion
4: First new line of text
5: Second new line of text
6:* and dynamic
7: line number generation.

If the two lines that were inserted had beenplaced at the beginning of the file, the screen
would look like this:
1: First new line of text
2: Second new line of text
3:*This is a sample file
4: used to demonstrate
5: line deletion
6: and dynamic
7: line number generation.

If the two lines that were inserted had beenplaced immediately before the current line (3 I
or. I or I), the screen would look like this:
1: This is a sample file
2: used to demonstrate
3: First new line of text
4: Second new line of text
5:*line deletion
6: and dynamic
7: line number generation.

7-25

Insert Lines
Command

If the two inserted lines had been placed at theend of the file (6 I or # I), the screen would look
like this:
1: This is a sample file
2: used to demonstrate
3: line deletion
4: and dynamic
5: line number generation.
6: first new line of text
7: Second new line of text

7-26

List Lines
CommandPurpose:

Displays a specified range of lines.
The current line remains unchanged.

Format:[line] [,line] L

Remarks: Default values are provided if either one or bothof the parameters are omitted.
If you omit the first parameter, as in:,lineLthe display starts 11 lines before the current line
and ends with the specified line. The beginningcomma is required to indicate the omitted firstparameter.
Note: If the specified line is more than 11lines before the current line, the display is
the same as if you omitted both parameters.
(An example is provided in this section
showing both parameters omitted.)

7-27

List Lines
CommandIf you omit the second parameter, as in:
IineL

or
line, La total of 2 3 lines are displayed, starting with thespecified line.
If you omit both parameters, as in:La total of 2 3 lines are displayed - the 11 lines
before the current line, the current line, and the
11 lines after the current line. If there aren't 11
lines before the current line, then extra lines are
displayed after the current line to make a. total
of23 lines.

7-28

List Lines
Command

Example: Assume that you want to edit the following file.
Line 15 is the current line.
1: This is a sample file
2: used to demonstrate
3: line deletion
4: and dynamic
5: line number generation.

•••
15:*This is the current line (note the asterisk)•••

25: See what happens
26: to the lines
27: and line numbers
28: when lines are
29: deleted.

If you want to display a range of lines, from
5-25, enter:
5,25L

7-29

List Lines
Command

The screen looks like this:
5: line number generation.

•••
15:*This is the current line (note the asterisk)•••
25: See what happens

If you want to display the first three lines, enter:
1,3L

The screen looks like this:
1: This is a sample file
2: used to demonstrate
3: line deletion

If you want to display 23 lines of the file,starting with line 3, enter:
3L

7-30

List Lines
Command

The screen looks like this:
3: line deletion
4: and dynamic
5: line number generation.

•••
15:*This is the current line (note the asterisk)•••
25: See what happens

If you want to display 23 lines centered aroundthe current line, enter:
L

The screen looks like this:
4: and dynamic
5: line number generation.

•••
15:*This is the current line (note the asterisk)•••
25: See what happens
26: to the lines

7-31

Move Lines
CommandPurpose:Moves the range of lines specified by the firsttwo line parameters ahead of the line specified in
the third line parameter. The third parameter is
not optional.

Format:[line] ,[line] ,lineM

Remarks: Use this command to move a block of data fromone location in the file to another. If the first or
second line parameter is omitted, it will default
to the current line. After the move, the first of
the moved lines becomes the current line. Thelines are renumbered according to the directionof the move. For example:,+25,100M

moves the data from the current line plus 25
lines to line 100. If the arguments overlap anentry error is reported.

7-32

Page
CommandPurpose:Lists the specified block of lines.

Format:[line] [,line] P

Remarks: If the first line parameter is omitted, it defaults
to the current line plus one. If the second line
parameter is omitted, 23 lines are listed. The
new current line becomes the last line displayedby the Page command and is marked with anasterisk. This command pages through a filedisplaying 23 lines at a time. It differs from the
List Lines command in that it changes thecurren t line.

7-33

Quit Edit
CommandPurpose:Quits the editing session without saving any
changes you may have entered.

Format:Q

Remarks: EDLIN prompts you to make sure you really
don't want to save the changes. .
Enter Y if you want to quit the editing session.
No editing changes are saved and no .BAK file iscreated. Refer to the End Edit command for
information about the .BAK file.
Enter N, or any other character, if you want tocontinue the editing session.

Example:0
Abort edit (Y/Nlt_

7-34

Replace Text
CommandPurpose:Replaces all occurrences of the first string in thespecified range of lines with the second string.
Notes:
1.

If you omit the second string, Replace
Text deletes all occurrences of the firststring within the specified range oflines. If you omit both strings, EDLIN
will re-use the search string enteredwith the most recent (previous) S or R
command, and the Replace Text string
entered with the last R command.

2.

This command uses the F6 key asnormally setup by DOS. If you havechanged the meaning of the F6 key
through" Extended Keyboard
Control" (see Chapter 13), you shouldpress Ctrl- Z where F6 is referred to
below.

EDLIN displays the changed lines each timethey are changed. The last line changed becomesthe current line.

Format:[line] [,line] [?] R[string] [<F6>string]

7-35

Replace Text
CommandRemarks: You can specify the optional parameter? torequest a prompt (O.K.?) after each display of amodified line. Press Y or the Enter key if you
want to keep the modification.
Enter any other character if you don't want themodification. In either case, the searchcontinues for further occurrences of the firststring within the range of lines, including
multiple occurrences within the same line.
Defaults occur if either one or both of the line
parameters are missing.
If you omit the first line, the search begins withthe line after the current line. If you omit thesecond line, the search ends with the last line inmemory. If you omit both line parameters, thesystem will search from the line following thecurrent line to the last line in memory.
Note: The first string begins with thecharacter in the position immediately
following the R, and continues until youpress F6 orCtrl-Z (or the Enter key if thesecond string is omitted).
The second string begins immediately after
you press F6 or Ctrl- Z and continues until
you press Enter.

7-36

Replace Text
Command

Example: Assume that you want to edit the following file.
Line 7 is the current line.
1: This is a sample file
2: used to demonstrate
3: the Replace and Search Text commands.
4: This includes the
5: optional parameter?
6: and required string
7:*parameter.

To replace all occurrences of and with or in thelines in memory, enter:
1,7 Rand

Then press F6, type Of, and press Enter.
The result is:
3: The Replace or Search Text commands
6: or required stringLine 6 becomes the current line in the file,because line 6 was the last line changed. Noticethat lines 1, 2, 4, 5, and 7 are not displayed
because they were not changed.

7-37

Replace Text
CommandGreater selectivity can be achieved byrequesting a prompt (by using the? parameter)
after each display of a modified line. If you
request a prompt, the screen looks like this:*1,7? Rand (Press F6, type or, and press Enter)
3: the Replace or Search Text commands
O.K.? y3: the Replace or Search Text commands

O.K.?

N

6: or required string
O.K.? y*Lines 3 and 6 are displayed like this:
3: the Replace or Search Text commands.
6: or required string

7-38

Search Text
CommandPurpose:Searches a specified range of lines in order tolocate a specified string.

Format:[line] [,line] [?] S[string]

Remarks: The first line to contain the specified string isdisplayed and the search ends (unless you use
the? parameter). The first line found that
contains the specified string becomes thecurrent line.
Note: The Search command always
searches for the exact same character in
text. That is, it searches for UPPERCASE if
you enter UPPERCASE, and lowercase if
you enter lowercase.
You should specify the optional parameter? if
you would like a prompt (O.K.?) after eachdisplay of a line containing the specified string.

7-39

Search Text
CommandIf you do not enter a string, the S command will
use the last search string that was entered on a
Replace or Search command. If the specified
string is not found, the search ends and themessage Not found is displayed. The current
line remains unchanged. If you enter Y or press
the Enter key, the line that matches the
specified string becomes the current line and thesearch ends. Enter any other character tocontinue the search until another string isfound, or until all lines within the range aresearched. Once all the lines within the range aresearched, the Not found message is displayed.

7-40

Search Text
Command

The system provides default values if you omit
the first, second, or both line parameters. If youomit the first line parameter, the system defaults
to the line followil).g the current line. If youomit the second line parameter, the systemdefaults to the last line in memory. If you omit
both line parameters, the system searches fromthe line following the current line to the last line
in memory.
Notes:
1.

The string begins with the character inthe position immediately following the
S and continues until you end thestring by pressing the Enter key.

2.

If you wish to place more than one
command on a line containing a Search
Text command, the Search Text
command should end in a Ctrl-Z (F6),and the next command should begin in
the following character position.

7-41

Search Text
Command

Example: Assume that you want to edit the following file.
Line 7 is the current line.
1: This is a sample file
2: used to demonstrate
3: the Search Text command.
4: This includes the
5: optional parameter?
6: and required string
7:*parameter.

If you want to search for the first occurrence ofand in the file, enter:
1,7 Sandor
1, SandorlSand

The result is:
3: the Search Text command.

*
The and is part of the word command. Noticethat line 3 becomes the current line in the file.

7-42

Search Text
Command

Perhaps this is not the and you were looking
for. To continue the search, simply enter theletter S and press Enter. The search willcontinue with the line following the current line(the line just found).
The screen looks like this:*1,7 Sand
3: the Search Text command.
*S
6: and required string*Line 6 now becomes the current line in the file.
You can also search for strings by requesting a
prompt (by means of the? parameter) after eachdisplay of a matching line. In this case, thescreen looks like this:*1,7? Sand
3: the Search Text command.
O.K.? N
6: and required string
O.K.? y*7-43

Transfer Lines
CommandPurpose:Transfers (merges) the contents of a specified
file into the file currently being edited.

Format:[line]T[d:lfilename

Remarks: The filename contents will be inserted ahead ofthe line in the file being edited. If line is omitted,
then the current line is used.
Note: The file being merged is read fromthe current directory of the specified ordefault drive. If a path was specified when
you issued the EDLIN command, then thatpath will be the current directory for thatdrive for the duration of the EDLIN
session, and any Transfer Lines commands
for that drive must be satisfied from thesame directory.

7-44

Write Lines
CommandPurpose:Writes a specified number of lines to diskettefrom the lines that are being edited in memory.
Lines are written beginning with the line
number 1.

Format:[n] W

Remarks: This command is only meaningful if the file youare editing is too large to fit in memory. Whenyou start EDLIN, EDLIN reads lines intomemory until memory is 75% fulL
To edit the remainder of your file, you must
write edited lines in memory to diskette before
you can load additional unedited lines fromdiskette into memory by using the Append Lines
command.
Note: If you do not specify the number oflines, lines are written until 25% of available
memory is used. No action is taken if
available memory is already less than 25%
used. All lines are renumbered so that thefirst remaining line becomes number 1.

7-45

Summary of EDLIN Commands

The following chart is provided for quickreference.
Note: The section called "Format
Notation" in Chapter 6 explains thenotation used in the format of the following
commands.

CommandFormatAppend Lines[n]A

Copy Lines[line] ,[line] ,line, [,count] C

Delete Lines[line] [,line] D

Edit Line[line]End Edit

E

Insert Lines[line] I

List Lines[line] [,line] L

Move Lines[line], [line] ,lineM

Page[line] [,line] P

Quit Edit

Q

Replace Text[line] [,line] [?] R[string] [<F6> string]

Figure 3 (Part 1 of2). EDLIN Commands
7-46

CommandFormatSearch Text[line] [,line] [?] S[string]Transfer Lines[line] T filename

Write Lines[n]WFigure 3 (Part 2 of 2). EDLIN Commands

7-47

Notes:7-48

Chapter 8. Messages

Contents
Introduction ............... '. . . . . . . . . . . . . .. 8- 3
Device Error Messages ..................... 8-3
Other Messages ........ ... . .. . . ... . ... .... 8-7

Notes:8-2

In trod uction

This chapter contains two parts; first, device errors(the message that DOS uses to indicate errors
while reading or writing to devices on yoursystem), and second, Other messages (the remainderof the DOS messages) in alphabetical order. Eachmessage is indicated here by bold type, and thedescription follows the message.
The first word of the description of each message
is the name of the program or command thatgenerated the message.

Device Error Messages

When an error is detected while reading or writing
any of the devices (disk drives, printer, etc.) on
your system, DOS will display a message in thefollowing format:<type> error reading <device>
Abort, Retry, Ignore?
or<type> error writing <device>
Abort, Retry, Ignore?

8-3

In these messages, <device> is the name of thedevice in error, such as PRN, or B:, and <type> is
one of the following error types:

Bad call format
A device driver was passed an incorrect length
request header. If this occurs, contact the dealer
you purchased the device driver from.

Bad commandA device driver has issued an invalid command to<device>.
Bad unit
A device driver has been passed an invalid sub-unit
number. If this occurs, contact the dealer you
purchased the device driver from.

Data
The data was unable to be read or writtencorrectly. This usually means a disk has developed
a defective spot.

Disk
An error of a type not described above has
occurred.

No paperThe indicated printer is either out of paper or is
not turned on.

Non-DOS disk
The file allocation table contains invalid
information, and needs to be re-formatted.

Not ready
The named device is not ready, and cannot accept
or transrnit data.

Read fault
DOS was unable to successfully read the data.

Sector not foundThe sector containing the data could not belocated on the disk, usually occurring when adefective spot develops on the disk.

Seek
The fixed disk or diskette drive was unable tolocate the proper track on the disk.

Write fault
DOS was unable to successfully write the data to
the device, from the device.

8-5

Write protect
An attempt was made to write on a write protecteddiskette.
Warning
If any of these messages appear for a diskette
drive, DO NOT change diskettes.
The system now waits until one of the following
responses is made, Enter:•

A for Abort. The system ends the programthat requested the disk read or write.

•

R for Retry. The system tries the disk read or
write operation again.

•

I for Ignore. The system pretends the error
did not occur and continues the program.

To recover from an error condition, the responses
are generally made in the following order:
R to retry the operation because the error may
not occur again.
A to abort the program.
I

to ignore the error condition and continue theprogram. (This response is not recommended
because data is lost when you use it.)
Note: One of these messages will appear if
you attempt to use a dual-sided diskette in asingle-sided drive, or if you attempt to use a 9
sector per track diskette on a pre-version 2.00
level of DOS.

8-6

Other Messages

The following messages are in alphabetical order.

A
About to generate .EXE file
Change disks <hit ENTER>
LINK. This message is displayed when you specify
the IPAUSE parameter. Insert your Runfile
diskette into the appropriate drive and press Enter.

Access denied
DEBUG. An attempt was made to write to a filewhich is marked read-only.

All files canceled by operator
PRINT. This message appears on the printer when
you cancel the printing of all queued files via theIT parameter.

All specified file(s) are contiguous
CHKDSK. The file or files you named are all
written sequentially on the disk.

8-7

Allocation error for file, size adjusted
CHKDSK. A filename precedes this message. An
invalid sector number was found in the fileallocation table. The file was truncated at the endof the last valid sector.

Ambiguous switch: z
LINK. The characters specified by z do not
uniquely identify a linker parameter. Use morecharacters from the parameter name.

Amount read less than size in header
EXE2BIN. The program portion of the file wassmaller than indicated in the file's header. You
should re-compile or re-assemble, and re-LINK theprogram.

An internal failure has occurred
LINK. An error has occurred in the linker
program. Report the conditions under which themessage appeared to your Authorized IBM
Personal Computer Dealer.

Attempt to access data outside of segment
bounds
LINK. An object file is probably invalid.

8-8Attempted write-protect violation
FORMAT. The diskette being formatted cannot be
written on because it is write-protected. You areprompted to insert a new diskette and press a key
to restart formatting.

B
Backup file sequence error
RESTORE. A file to be restored was backed up
onto more than one diskette. You did not insert
the diskette with the first part of the file. Rerun
RESTORE and start with the correct diskette.

Bad command or file nameDOS. The command just entered is not a valid
command to DOS. You should check your spelling
and re- en ter the command. If the command nameis correct, check to see that the default drive
contains the external command or batch file you
are trying to execute.
Bad numeric parameter
LINK. The value you specified with the /STACK
parameter is not a valid numeric constant.

8-9

Bad or missing Command Interpreter
DOS. The disk that DOS is being started fromdoes not contain a copy of COMMAND. COM, oran error occurred while the disk was being loaded.
If System Reset fails to solve the problem, copy
COMMAND. COM from a backup diskette to theroot directory of the disk that failed.
This message also appears if COMMAND. COM has
been removed from the directory it was inoriginally when DOS was started; or if the
COMSPEC= parameter in the environment points
to a directory not containing COMMAND. COM
and DOS is attempting to reload the commandprocessor.

Bad or missing < filename>DOS. This message appears only at startup, andindicates that a device driver named in a DEVICE=<filename> parameter in the CONFIG.SYS file
was not found, or set a break address that was outof bounds for the machine size, or an error
occurred while the driver was being loaded. That
driver is not installed by DOS.

Batch file missing
DOS. DOS was unable to locate the batch file it
had been processing. The file has probably beenerased or renamed by one of the steps within it.
Batch processing stops and the DOS prompt
appears.

8-10

BF
DEBUG. Bad flag. An invalid flag code setting was
specified. Try the Register (R F) command again
with the correct code.

BP
DEBUG. Breakpoints. More than ten breakpoints
were specified for the Go command. Try the Go(G) command again with ten or fewer breakpoints.

BR
DEBUG. Bad register. An invalid register namewas specified. Try the Register (R) command again
with a correct register name.

BREAK is On/Off
DOS. This message indicates that BREAK is on oroff.

c
Cannot do binary reads from a device
COPY. You have used the /B parameter with adevice name while attempting to copy from thedevice. The copy cannot be performed in binarymode because COpy must be able to detect
end-of-file from the device. You should omit the/B parameter or use the / A parameter after thedevice name.

8-11

Cannot edit .BAK file - rename file
EDLIN.. BAK files are considered to be backup
files, with more up-to-date versions of the files
assumed to exist. Therefore, .BAK files shouldn't
be edited.
If it is necessary to edit the .BAK file, either
rename the file, or copy it and give the copy adifferent name.
Cannot find file object file
Change diskette <hit ENTER>
LINK. The linker could not locate the specified
object module on the drive. Insert the diskettewith the specified module on it and press Enter.
Cannot find library library file
En ter new drive letter:
LINK. The specified library could not be found on
the drive. Enter the letter for the drive the libraryis on.

Cannot load COMMAND, system halted
DOS. While attempting to reload the commandprocessor, DOS determined that the area in which
it keeps track of available memory has been
destroyed, or the command processor could not befound in the path specified by the COM SPEC .
environment parameter. You should restart DOS.

8-12

Cannot nest response file
LINK. You used @filespec within an automatic
response file. Automatic response files cannot be
nested.

Cannot open list file
LINK. The directory or disk is full.

Cannot open overlay
LINK. The directory or disk is full.

Cannot open response file
LINK. The automatic response file could not befound.

Cannot open temporary file
LINK. The directory or disk is full.

Cannot start COMMAND, exiting
DOS. While attempting to load a second copy ofthe command processor, either the FILES=
parameter in the configuration file was found tocontain too small a value, or there is insufficientavailable memory to contain the new copy of
COMMAND. COM.

8-13

COMn: bbbb,p,d,s,t initialized
MODE. The Asynchronous Communications
Adapter has been initialized. The values represent:nadapter (COM1 or COM2)

bbbb

baud ratepparity
e

even

o

odd

n

none

s

stop bits (1 or 2)ttype of serial devicepserial printer (serial timeouts will be
retried)other serial device (serial timeouts
will not be retried)

Compare error at offset xxxxxxxx
CaMP. The files being compared contain different
values at the displayed offset (in hexadecimal) into
the file. The differing values are also displayed inhexadecimal.

8-14

Compare error(s) on
Track xx, side xx
DISKCOMP. One or more locations on theindicated track and side contain differing
information between the diskettes being
compared.

Compare more diskettes (Y/N)?
DISKCOMP. If you wish to compare another pairof diskettes, enter Y, and DISKCOMP will prompt
you to insert the required diskettes. If you do notwant to compare any more diskettes, enter N.

Compare more files (Y/N)?
COMPo If you wish to compare the contents of two
more files, enter Y, and COMP will prompt you forthe names of the files to compare. If you do notwish to compare more files, enter N.

Comparing x sectors per track, n side( s)DISKCOMP. The n will be either 1 or 2, indicating
the number of sides that DISKCOMP will compare
on the two diskettes. This number is determinedby the number of sides DISKCOMP was able tosuccessfully read from the first track of the firstdiskette. The x indicates the number of sectors per
track found on the first diskette (8 or 9). If you use/8, then the number 8 will appear.

8-15

Contains invalid cluster,
file truncated
CHKDSK. The file whose name precedes thismessage contains an invalid pointer to the data
area. The file is truncated at the last valid data
block if the IF parameter was used.
Contains xxx non-contiguous blocks
CHKDSK. The file whose name precedes thismessage is not written sequentially on disk-it is
written in xxx pieces on different areas of the disk.
This is an information only message, and does notindicate a problem on the disk. Since fragmented
files take longer to read, you should consider
copying badly fragmented files to another disk.
This w~ll record the file sequentially, resulting in
better system performance when the file is read.

Convert directory to file (YIN)?
CHKDSK. The directory whose name appears
ahead of this message contains enough invalid
information that it is no longer usable as adirectory. If you reply Y, CHKDSK will convert
the directory to a file so that you may examine itwith DEBUG. If you reply N, the entry is notchanged.

Convert lost chains to files (YIN)?
CHKDSK. If you wish to recover the data in the"lost" blocks found by CHKDSK, reply Y. If you
reply N, CHKDSK will free the blocks up so they
can be allocated to new files.

8-16

Copy another (Y/N)?
DISKCOPY. If you wish to copy another entire
diskette, enter Y; DISKCOPY will prompt you to
insert the required diskette. If you do not wish to
make another copy, enter N.

Copy complete
DISKCOPY. The source diskette contents havebeen successfully copied to the target diskette.

Copying x sectors per track, n side( s)DISKCOPY. The n will be either 1 or 2, indicating
the number of sides that DISKCOPY has
successfully read from the first track of the source
diskette. The x will be 8 or 9, indicating thenumber of sectors per track found on the source
diskette.

D
DF
DEBUG. Double flag. Conflicting codes were
specified for a single flag. A flag can be changed
only once per Register (R F) command.

Disk boot failureDOS. An error occurred while trying to load DOS
into memory. If subsequent attempts to start thesystem also fail, place a backup DOS diskette indrive A and restart your system.

8-17

Disk error wri ting FAT x
CHKDSK. A disk error was encountered which
CHKDSK was attempting to update the fileallocation table (FAT) on the specified drive. X willbe 1 or 2, depending on which of the 2 copies ofthe file allocation table could not be written. If
this message appears twice, for FAT's 1 and 2, thedisk should be considered unusable.

Disk full- write not completed
EDLIN. An End Edit command ended abnormallybecause the disk does not have enough free space
to save the entire file.
Some of the file may be saved on disk, but the
portion in memory not saved is lost.

Disk not compatible
FORMAT. The drive you specified cannot be
formatted by the DOS FORMAT command. It is
not supported by the IBM device interfaces that
FORMAT requires.

Disk unsuitable for system disk
FORMAT. A defective track was detected where
the DOS files were to reside. The diskette can beused only for data.

Diskettes compare OKDISKCOMP. The two diskettes just compared
contain identical information.

8-18

Diskette is not a backup diskette
BACKUP and RESTORE. The diskette was notcreated by BACKUP. The first file on a backup
diskette is always BACKUPID.@@@. Rerun withthe correct diskette.

Divide overflow
DOS. A program attempted to divide a number byzero, or the program had a logic error that caused
an internal malfunction. The system simulates
Ctrl-Break processing.

Do you see the leftmost 9? (YIN)
MODE. ,R,Twas specified. Respond Y or N. This
prompt is repeated until you respond Y.

Do you see the rightmost 9? (YIN)
MODE. ,L, T was specified. Respond Y or N. This
prompt is repeated until you respond Y.

Do you wish to use the en tire fixed
disk for DOS (YIN) ................ ?[ ]FDISK. When the "Create DOS Partition" option
is used on the current fixed disk and the fixed disk
has never been set up, this question is asked. If you
enter Y, the entire current fixed disk will be usedfor DOS and it will be made active. If you enter N,
you will be asked to enter the limits of the DOS
partition you want to create.

8-19Dup record too complex
LINK. Problem resides in object module createdfrom an assembler source program. A single DUP
requires 1024 bytes before expansion. Debug thesource program; then rerun LINK.

Duplicate filename orfile not found
RENAME. You tried to rename a file to a filenamethat already exists on the diskette, or the file to berenamed could not be found on the specified (ordefault) drive.

E
Enter the number of the partition you
want to make active............... : [ ]FDISK. The "Change Active Partition" option isrequesting that you enter the number of thepartition you want to make active. Type thenumber of the partitions that you want to makeactive on the current fixed disk. They are displayed
above the prompt. Then press the Enter key.

Enter partition size............ : [dddd]
FDISK. The "Create DOS Partition" option
requests that you enter the size of the partition
you wish to create. The number shown in thebrackets is the default size. If you only press Enter,that size will be used as the partition size.

8-20

En ter primary file name
CaMP. Enter the filespec of the first of two files tobe compared.

Enter starting cylinder number.. : [dddd]
FDISK. The "Create DOS Partition" option isrequesting that you enter the starting cylinder
number for the DOS partition you are creating.
The value in the brackets is the default value. It is
the starting cylinder of the largest piece of freespace on the current fixed disk. Type a number
and press Enter, or just press Enter to use thedefault value.

Enter 2nd file name or drive id
CaMP. Enter the filespec of the second of two
files to be compared, or just enter the drive
designator if the filename is the same as theprimary filename.

Entry error
EDLIN. Correct the syntax error on the lastcommand.

Entry has a bad attribute(or size or link)
CHKDSK. This message may begin with one or
two periods, indicating which entry in thesubdirectory was in error. CHKDSK will attempt
to correct the error if the IF parameter was
specified.

8-21

EOF mark not found
COMPo An unsuccessful attempt was made tolocate the end of valid data in the last block of thefiles being compared. This message usually occurs
when comparing nontext files; it should not occur
when comparing text files. For more details, see
the COMP command in Chapter 5.

Error found, F parameter not specified
Corrections will not be written to disk
CHKDSK. You have not used the IF parameter.
CHKDSK will perform its analysis as though it
were going to correct any errors detected, so thatyou can see the results of its analysis, but it will
not actually write the corrections on the disk.
Error in EXE file
DOS. An error was detected in the relocation
information placed in the file by the LINK
program. This may be due to a modification to thefile.

Error in EXE/HEX file
DEBUG. The file contained invalid records orcharacters.

Error loading operating system
Startup. A disk error occurred while attempting toload your operating system from fixed disk. If thesituation persists after several attempts to
re-start the system, you should start DOS fromyour DOS diskette and use the SYS command totransfer a new copy of DOS to your fixed disk.
8-22

Error reading fixed disk.
FDISK. The FDISK program was unable to readthe startup record of the current fixed disk after
five tries. Try the FDISK program again. If after
several tries you are unable to proceed, consult the
Guide to Operations book "Problem Determination"section and see your IBM Personal Computer
Dealer.
Error writing fixed disk.
FDISK. The FDISK program was unable to write
the startup record of the current fixed disk after
five tries. Try the FDISK program again. If after
several tries you are unable to proceed, consult the
Gutde to Operations book "Problem Determination"section and see your IBM Personal Computer
Dealer.
Error writing to device
Commands. DOS was unable to write therequested number of bytes to the device. This
indicates that you tried to send more data to thedevice than the device was expecting.
Errors on list device indicate thatit may be off-line. Please check.
PRINT. The device being used for backgroundprinting is offline. This message only appears when
the device is offline and you enter a new PRINT
command.

8-23

EXE and HEX files cannot be written
DEBUG. The data would require a backwards
conversion that DEBUG doesn't support.

EXEC failure
Commands. An error was encountered while
reading a command from disk, or the FILES=
command in the configuration file (CONFIG.SYS)
does not specify a large enough value. You should
increase that value and restart DOS.

F
File allocation table bad, drive x
Abort, Retry, Ignore?
DOS. See the message Disk error reading drive x
under "Device Error Messages" at the beginning of
this chapter. If this error persists, the disk isunusable and should be formatted again.

File AND File
COMPo This message indicates the full path andfilenames of the two files currently being
compared.

File canceled by operator
PRINT. This message appears on the printer after
you cancel the printing of a file to serve as areminder that the printout is incomplete.

8-24File cannot be copied onto itself
DOS. A request is made to COpy a file and place
the copy (with the same name) in the same
directory on the same disk as the originaL You
should change the name given to the copy, put it
in a different directory or put it on another disk.

F He creation error
DOS and commands. An unsuccessful attempt wasmade to add a new filename to the directory or to
replace a file that was already there. If the file wasalready there, it was marked read-only andtherefore could not be replaced. Otherwise run
CHKDSK to determine if the directory is full, or ifsome other condition caused the error.

F He is cross-linked:
on cluster xx
CHKDSK. This message will appear twice for eachcross-linked cluster number, naming the two files
in error. The same data block is allocated to both
files. No corrective action is taken automatically,
so you must correct the problem. For example,
you can:•Make copies of both files (use COpy
command).

•Delete the original files (use ERASE
command).

•

Review the files for validity and edit asnecessary.

8-25

File is currently being printed
File is in queue
PRINT. These messages appear together when you
issue a PRINT command with no parameters, orindividually when you queue the first or asubsequent file for printing. This message isprovided for your information.

File not foundDOS and commands. A file named in a commandor command paranleter does not exist in the
directory in the specified (or default) drive.

Files are different sizes
COMPo The sizes of the files to be compared do
not match. The comparison cannot be done
because one of the files contains data which theother does not.

Files compare OK
COMPo The two files just compared containidentical information.
First cluster number is invalid,
entry truncated
CHKDSK. The file whose name precedes thismessage contains an invalid pointer to the data
area. The file is truncated to a zero-length file if
the IF parameter was specified.

8-26

Fixed disk already has a DOS partition.
FDISK. You chose the "Create DOS Partition"
option and the current fixed disk which alreadyhas a DOS partition.
Fixup offset exceeds field width
LINK. An assembler instruction refers to an
address with a NEAR attribute instead of a FAR
attribute. Edit assembler source program andprocess again.
Fixups needed- base segment (hex):
EXE2BIN. The source (.EXE) file contained
information indicating that a load segment isrequired for the file. Specify the absolute segment
address at which the finished module is to beloaded.
WARNING
We do not recommend using such a program as a.COM file because the program is dependent
upon being loaded at a specific memory
location.

8·27

FOR cannot be nested
Batch. More than one FOR subcommand wasfound on one command line in the batch file. Only
one FOR subcommand is allowed per commandline.

Format failure
FORMAT. A disk error was encountered while
creating the target diskette. The diskette isunusable.

Formatting while copying
DISKCOPY. The target diskette was found tocontain unformatted tracks. DISKCOPY will
format the remainder of the target diskette as it
copies data. If this message is followed by themessage Incompatible drive types, you have tried
to copy a dual sided diskette to a drive that does
not have dual sided capability; processing will end,
and the target diskette will not contain any usefuldata

I
Illegal Device N arne
MODE. The specified printer must be LPTl:,
LPT2:, or LPT3:; the specified Asynchronous
Communications Adapter must exist and be
COMl: or COM2:. There must be no more than
one blank between MODE and its parameters.

8-28

Incompatible diskette or drive types
DISKCOMP. The first diskette was successfully
read on both sides, but the second diskette could
only be read on the first side. Either the second
drive or diskette is single sided or the first diskettecontains 9-sectors per track and the second
diskette contains only 8-sectors per track.

Incompatible drive types
DISKCOMP. The source diskette and drive aredual sided, but the target drive has only single
sided capability. The target diskette contains nouseful data.

Incompatible system size
SYS. The target diskette contained a copy of DOS
tha t is smaller than the one being copied. The
system transfer does not take place. A possible
solution might be to format a blank diskette (usethe FORMAT IS command) and then copy any
files to the new diskette.

Incorrect DOS version
Commands. The command you just enteredrequires a different version of DOS than the one
you are running.

8-29

Insert backup diskette xx in drive x:
Strike any key when ready
RESTORE. Insert the new backup diskette insequence. RESTORE will continue when you press
a key.

Insert backup diskette xx in drive x:
Warning! Diskette files will be erased
Strike any key when readyBACKUP. Insert the next diskette to be used forthe backup. Use DOS formatted diskettes only.
BACKUP will continue when you press a key.

Insert COMMAND.COM disk in drive x:
and strike any key when readyDOS. DOS is attempting to reload the commandprocessor, but COMMAND. COM is not on thedrive that DOS was started from. Insert the DOS
diskette in the indicated drive and press any key.

Insert disk to be recovered in todrive x: and press any key when ready
RECOVER. Insert the diskette to be recovered in
the indicated drive and press any character key.

Insert disk with batch fileand strike any key when readyDOS. The diskette that contained the batch file
being processed was removed. The batch processor
is trying to find the next command in the file.
Processing will continue when you insert thediskette in the appropriate drive and press a key.
8-30

Insert DOS disk in x:
and strike any key when ready
SYS and FORMAT. FORMAT or SYS is trying toload the DOS files, but the indicated drive x: does
not contain the DOS diskette.

Insert DOS diskette in drive A:
Press any key when ready ...
FDISK. You have successfully created the DOS
partition on the current fixed disk. Insert the DOS
diskette into drive A: and press any key. This will
restart your IBM Personal Computer. The current
fixed disk will now be assigned a fixed disk letterand you can now FORMAT the fixed disk.
Insert first diskette in drive x
Insert second diskette in drive x
DISKCOMP. Insert the first (or second) disketteof the two diskettes to be compared in to theindicated drive. One or both of these messages will
be followed by the message Strike any key when
ready. When you press a key, the comparison willcontinue.
Insert source diskette in drive x
Insert target diskette in drive x
DISKCOPY. Insert the appropriate diskette into
the indicated drive, and press any key when
prompted. The copying process will continue.

8-31

Insufficien t disk space
DOS and commands. The disk does not containenough free space to contain the file being written.
If you suspect this condition is invalid, run
CHKDSK to determine the status of the disk.

Insufficien t memory
Commands. The amount of available memory is
too small to allow these commands to function.
You should change the BUFFERS= parameter in
the CONFIG.SYS file to a smaller value (if you
have specified BUFFERS=), restart the system andtry the command again. If the message still
appears, then your system does not have enoughmemory to execute the command.

Insufficient room in root directory
Erase files from root and repeat CHKDSK.
CHKDSK. You have instructed CHKDSK tocreate files from the "lost" data blocks it has
found, but the root directory is full, so all of thelost chains could not be recovered into files. You
should copy some of the recovered files to anotherdisk for further examination, delete them from thedisk you are checking, then run CHKDSK again to
recover the remainder of the lost data.

Insufficien t space on disk
DEBUG. A Write command was issued to a diskthat doesn't have enough free space to hold thedata being written. If you are writing to diskette,you may insert a diskette that does have enoughfree space and re-issue the Write command.
Otherwise, you should erase files from the disk andrun DEBUG again.
8-32

Intermediate file error during pipeDOS. DOS was unable to create one or both of its
intermediate files because the default drive's root
directory was full, or DOS is unable to locate thepiping files, or the disk contains insufficientavailable space to hold the data being piped. You
should erase some files from the default drive's
root directory and re-issue the command thatfailed. If it still fails, one of the programs in thecommand line has erased one or both of the piping
files. You should correct the program and re-issue
the command line.

Invalid baud rate specified
MODE. The baud rate you specify must be 110,
150, 300,600, 1200, 2400,4800, or 9600 (or the
first two characters of the number).

Invalid characters in volume label
FORMAT. One or more of the characters you
entered in the volume label is not a valid filename
character, or the name contained a period (volume
labels contain 1 to 11 valid characters without aperiod).

Invalid COMMAND. COM in drive nDOS. While trying to reload the commandprocessor, the copy of COMMAND. COM on thedisk was found to be an incorrect version. You areprompted to insert the correct DOS diskette andpress any key to continue.

8-33

Invalid date
DATE. An invalid date or delimiter was entered.
The only valid delimiters in a date entry are
hyphens (-) and slashes (I).

Invalid device
CTTY. The device name you specified is an invalidname to DOS.

Invalid directory
DOS and commands. One of the directories in thespecified path does not exist.

Invalid drive in search path
DOS. An invalid drive specifier was found in oneof the paths specified in the PATH command. Thismessage appears when DOS attempts to locate acommand or batch file, not at the time you issued
the erroneous PATH command.

Invalid drive specification
DOS and commands. An invalid drive specification
was just entered in a command or one of its
parameters.

Invalid format file
LINK. A library is in error.

8-34Invalid number of parameters
Commands. You have specified too few or too
many parameters for the command you issued.

Invalid numeric parameter
LINK. Numeric value not in digits.

Invalid object module
LINK. Object module(s) incorrectly formed or
incomplete (as when the language processor was
stopped in mid-process).

Invalid parameter
DOS and commands. One or more of theparameters entered for these commands was not
valid. If the program expects a drive specifier, besure to enter a colon following the drive letter. In
other cases, be sure the character following theslash (I) is valid for the program being run.

Invalid parameters
MODE. No parameters were entered, or the firstparameter character was other than L, or C, or the
first parameter was other than 40, 80, BW40,
BW80, C040, C080, MONO, L, R, or the display
adapter the parameter refers to is not present in
the machine.

8-35

Invalid partition table
Startup. While attempting to start DOS from yourfixed disk, the start-up procedures detected invalid
information in the disk's partition information.
You should start DOS from diskette and use the
FDISK command to examine and correct the fixed
disk partition information.
Invalid path
TREE. Tree was unable to use a directory whosename was found in another directory. You should
run CHKDSK to determine what is wrong with thedirectory structure.

Invalid path, not directoryor directory not empty
RMDIR. The specified directory was not removed
because one of the names you specified in the path
was not a valid directory name, or the directory
you specified still contains entries for files or othersub-directories. You cannot remove a directory
unless it is empty (with the exception of the. and.. entries). Also you cannot remove a current
directory.

Invalid path or file name
COPY. You specified a directory or file name that
does not exist.

8-36

Invalid sub-directory
CHKDSK. Invalid information was detected in the
sub-directory whose name precedes this message.
CHKDSK will attempt to correct the error. For
more specific information about the nature of theerror, run CHKDSK with the IV parameter.
Invalid switch: z
LINK. The characters indicated by z do not form avalid linker parameter.
Invalid time
TIME. An invalid time or delimiter was entered.
The only valid delimiters are the colon between
the hours and minutes, and the minutes andseconds; and a period between the seconds andhundredths of a second.

L
Label not foundBatch. A GOTO command named a label which
does not exist in the batch file.
Line too long
EDLIN. Upon replacing a string, the replacement
causes the line to expand beyond the
25 3-character limit. The Replace Text command is
ended abnormally.
Split the long line into shorter lines; then issue theReplace Text command again.
8-37

List output is not assigned to a device
PRINT. The device you named to be the PRINT
list device is not recognized as a valid device. You
should re-issue the PRINT command and reply
with a valid list device name when prompted.
LPT#: not redirected.
MODE. The parallel printer will now receive its
own output, even if this printer's output had
previously been redirected to a serial device. This
indicates cancellation of any previous redirection
which may have been in effect, because you have
set the printer width or vertical spacing.
LPT#: redirected to COMn:
MODE. Any request that would normally havegone to the parallel printer LPT# (#=1, 2, or 3) issent instead to the serial device COMn (n=1 or 2).

LPT#: set for 80
MODE. An attempt was made to set the printerline length to 80 characters by requesting standard
type format. If the attempt was unsuccessful, anerror message will follow this message on thescreen.
LPT#: set for 132
MODE. An attempt was made to set the printerline length to 132 characters by requesting
compressed type format. If the attempt was
unsuccessful, an error message will follow thismessage on the screen.
8-38

M
Maximum available space is xxxx
cylinders at cylinder xxxx.
FDISK. The "Create DOS Partition" option
displays the largest available piece of space on thecurrent fixed disk. These numbers are also used as
the defaults for the two prompts that will follow.

Memory allocation error
Cannot load COMMAND, system halted
DOS. A program has destroyed the area in which
DOS keeps track of available memory. You should
restart DOS.

Missing operating system
Startup. While attempting to start DOS from fixed
disk, the startup procedures determined that the
DOS partition was marked as being "bootable"(startable), but that it doesn't contain a copy ofDOS. You should start DOS from diskette and use
FORMAT with the /S parameter to place a copy of
DOS on the fixed disk. You might want to backup
your files before doing the FORMAT.

Must specify destination line number
EDLIN. A Move or Copy command was enteredwithout a destination line number. Reenter thecommand with a valid destination line number.

8-39

N
No DOS partition to delete.
FDISK. You chose the "Delete DOS Partition"
option when there was no DOS partition on thecurrent fixed disk to be deleted.

N arne of list device [PRN]:
PRINT. This message appears the first time you
start print after DOS has been restarted Reply
with the reserved device name which is to receive
the printed output, or simply press Enter if thefirst parallel printer [PRN] is to be used.

No free file handles
Cannot start COMMAND, exiting
DOS. An attempt to load a second copy of thecommand processor has failed because there are
currently too many files open. You should increase
the number in the FILES= command in theconfiguration file (CONFIG.SYS), and restartDOS.
No fixed disks present.
FDISK. The FDISK program was run on an IBM
Personal Computer that:

8-40

•

Does not have a fixed disk.

•

Has a fixed disk in the expansion unit and the
expansion unit is not powered on.

•

Has a fixed disk that is not properly installed.

No object modules specified
LINK. You did not name any object modules in
the command line or in response to the prompt.
The linker needs some files to link.

No partitions to make active.
FDISK. You chose the "Change Active Partition"
option when there were no partitions on thecurrent fixed disk to be made active. You can use
the "Create DOS Partition" option to create apartition and then the "Change Active Partition"
option to make it the active partition.

No path
PATH. There is currently no alternate path for
DOS to search to find commands and batch files if
it does not find them in the specified (or default
directory).

No room for system on destination disk
SYS. The destination diskette did not alreadycontain the required reserved space for DOS;
therefore, the system cannot be transferred. A
possible solution would be to format a blankdiskette (use the FORMAT /S command), and thencopy any other files to the new diskette.

8-41

No room in directory for file
EDLIN. The directory on the specified disk is full.
Your editing changes are lost. You should assurethat your disk has auditable directory entries andrun EDLIN again.
No space for a xxxx cylinder partition.
FDISK. You entered a "Partition Cylinder Size"that is larger than the largest piece of free space on
the disk. Enter a smaller number.

No space for a xxxx cylinder partitionat cylinder xxxx.
FDISK. You requested a partition to be created at
a place on the current fixed disk and it does nothave space at that place to create a DOS partition.

No space to create a DOS partition
FDISK. You chose the "Create DOS Partition"
option on the current fixed disk which has nospace to create a DOS partition.

8-42

No sub-directories exist
TREE. The specified drive contains only a root
directory. Therefore, there is no directory path todisplay.

Non-System disk or disk error
Replace and strike any key when readyStartup. There is no entry for IBMBIO. COM orIBMDOS. COM in the directory; or a disk readerror occurred while starting up the system. Insert
a DOS diskette in drive A: and restart your system.

Not enough room to merge the entire file
EDLIN. A Transfer command was unable to merge
the entire contents of the specified file because of
insufficient memory. Part of the file was merged.

Not found
EDLIN. Either the specified range of lines does
not contain the string being searched for by the
Replace Text or Search Text commands; or if asearch is resumed by replying N to the OK?
prompt, no further occurrences of the string were
found.

8-43

o
Out of environment spaceDOS. DOS was unable to accept the SET
command you just issued because it was unable toexpand the area in which the environment
information is kept. This normally occurs where
you try to add to the environment after loading a
program which makes itself resident (PRINT,
MODE, or GRAPHICS for example).
Out of space on list file
LINK. This error usually occurs when there is notenough disk space for the List file.
Out of space on run file
LINK. This error usually occurs when there is notenough disk space for the Run file (.EXE).
Out of space on VM. TMP
LINK. No more disk space remained to expand
the VM. TMP file.

pParameters not compatible
FORMAT. You attempted to use two parametersthat are not compatible with each other (lB and IV
for example).

8-44

Parameter not compatible with fixed disk
FORMAT. You specified the /1 or /8 parameter
while formatting a fixed disk. Neither of theseparameters is valid for a fixed disk.
Press any key to begin formatting x:
FORMAT. The fixed disk (drive x) is about to beformatted. Formatting will lose track of all
previously existing data on the disk. If you do notwant the disk formatted, press Ctrl-Break. If you
do want the disk formatted, press a character key.
Print queue is empty
PRINT. There are currently no files being
processed by PRINT.
Prin t queue is full
PRINT. You attempted to add more than the limitof 10 files to the print queue. You will have to wait
until a file is printed before you can add anotherfile to the print queue.
Prin ter error
MODE. The MODE command (option 1) was
unable to set the printer mode because of an I/Oerror, out of paper (or POWER OFF), or time out(not ready) condition.

8-45

Prin ter lines per inch set
MODE. An attempt has been made to set theprinter vertical spacing to the specified 6 or 8 lines
per inch. If the attempt was unsuccessful, an error
message will follow this message on the screen.

Probable non-DOS disk.
Continue (Y/N)?
CHKDSK. The file allocation table identification
byte contains invalid information. Either the disk
was not formatted by DOS or has become badly
damaged. If you did not use the /F parameter, andyou reply Y, CHKDSK will indicate its possible
corrective actions without actually changing the
disk. We recommend doing this first, before you
consider using the /F switch and replying Y.

Processing cannot continue,
CHKDSK. This message will be followed byanother message which explains why CHKDSK
cannot continue. Normally, this condition iscaused by insufficient memory.

Program size exceeds capacity of LINK
LINK. Load module is too large for processing.

8-46

Program too big to fit in memory
DOS. The file containing the external commandcannot be loaded because it is larger than theavailable free memory. You should reduce thenumber in the BUFFERS= parameter in yourCONFIG.SYS file (if you have specified
BUFFERS=), restart your system and re-issue thecommand. If the message reappears, your systemdoes not have enough memory to execute thecommand.

R
Requested stack size exceeds 64K
LINK. Specify a size ~ 64K bytes when the STACKSIZE: prompt appears.
Resident part of PRINT installed
PRINT. The message appears the first time you
use the PRINT command. A program has been
loaded into memory to handle subsequent PRINT
commands. Available memory for yourapplications has been reduced by approximately
3200 bytes.
Resident portion of MODE loaded
MODE. When MODE is invoked for anon-screen-setting function it is sometimes
necessary to load a portion of code to be madepermanently resident.

8-47

s
Sector size too large in file < filename>Startup. The device driver named in <filename>specifies a device sector size larger than the devices
previously defined to DOS.
Segment size exceeds 64K
LINK. Attempted to combine identically named
segments which resulted in a segment requirementof greater than 64K bytes. The addreSSing limit is64K bytes.
Stack size exceeds 65535 bytes
LINK. The size specified for the stack must be lessthan or equal to 65535.
Symbol defined more than once
LINK. The Linker found two or more modules
that define a single symbol name.
Symbol table capacity exceeded
LINK. Very many, very long names were entered.
The names exceeded approximately 50K bytes.
Use shorter and! or fewer names.
Syntax error
DOS. The command you entered is improperly
formatted. Check to make sure you have used thecorrect format for this command.
8-48

T
Target diskette may be unusable
DISKCOPY. This message follows an
unrecoverable read, write, or verify error message.
The copy on the target diskette may be incomplete
because of the unrecoverable VO error.

Target diskette write protected
Correct, then strike any key
DISKCOPY. You are trying to produce a copy on
a diskette that is write-protected.

Terminate batch job (Y/N)?
DOS. This message appears when you press
Ctrl-Break while DOS is processing a batch file.
Press Y to stop processing the batch file. Pressing
N only ends the command that was executing
when Ctrl-Break was pressed; processing resumes
with the next command in the batch file.
The current active partition is x.
FDISK. The "Change Active Partition" option
displays the active partition on the current fixeddisk.
The last file was not restored
RESTORE. You stopped RESTORE before it
completely restored the last file listed or there was
not enough room on the fixed disk. RESTORE
then deleted the partially restored file.

8-49

There was/were

number errors detected
LINK. This message is displayed for yourinformation at the end of the link session.

Too many external symbols in one module
LINK. The limit is 256 external symbols per
module.

Too many groups
LINK. The limit is 10, including DGROUP.

Too many libraries specified
LINK. The limit is eight libraries.

Too many overlays
LINK. The limit is 64.

Too many public symbols
LINK. The limit is 1024 public symbols.

Too many segments or classes
LINK. The limit is 247 (segments and classes taken
together).

8-50

Total disk space is xxxx cylinders.
FDISK. The total space on the current fixed disk isdisplayed.

Track 0 bad-disk unusable
FORMAT. Track 0 is where the boot record, fileallocation table, and directory must reside. The
disk is unusable.

Tree past this point notprocessed
CHKDSK. CHKDSK is unable to continue
processing the directory path currently being
examined because track 0 is bad.

uUnable to create directory
MKDIR. The directory you wish to create alreadyexists, or one of the directory path names you
specified could not be found, or you attempted to
add a directory to the root directory and it is full,or a file already exists by that name in that
directory.

Unable to write BOOT
FORMAT. The first track of the diskette or DOS
partition is bad. The BOOT record could not be
written on it. The diskette or DOS partition is not
usable.

8-51

Unexpected end-of-file on library
LINK. This is probably caused by an error in thelibrary file.
Unexpected end of file on VM. TMP
LINK. The diskette containing VM.TMP has been
removed.
Unrecognized command in CONFIG.SYS
Startup. An invalid command was detected in theconfiguration file CONFIG.SYS. You should edit
the file, correct the invalid command and restartDOS.
Unrecoverable format error on target
Target diskette unusable
DISKCOPY. An unrecoverable error was
encountered while formatting the target diskette.
The diskette contains no usable data.
Unrecoverable read error on drive x
Track xx, side x
DISKCOMP. Four attempts were made to read thedata from the diskette in the specified drive. THedata could not be read from the indicated track
and side.

8-52

Unrecoverable read error on source
Track xx, side x
DISKCOPY. Four attempts were made to read thedata from the source diskette. DISKCOPY
continues copying, but the copy may contain
incomplete data.
Unrecoverable verify error on target
Track xx, side x
DISKCOPY. Four attempts were made to verify
the write operation to the target diskette.
DISKCOPY continues copying, but the copy may
contain incomplete data.
Unrecoverable write error on target
Track xx, side x
DISKCOPY. Four attempts were made to write
the data to the target diskette. DISKCOPY
continues copying, but the copy may contain
incomplete data.
Unresolved externals: list
LINK. The external symbols listed were notdefined in the modules or library files that you
specified. If this error occurs, do not attempt to
run the executable file created by the linker.

8-53

v
VM. TMP is an illegal filename and has been
ignored
LINK. VM. TMP cannot be used for an object:filename. This message is only a warning.
Volume label (1.1 characters, ENTER for none) ?
FORMAT. You are requested to enter ~ 1 to 11
character volume label which will be written on
the disk being formatted. If you do not want a
volume label on the disk, press only the ENTER
key.

w
Warning! All data in the DOS partition
will be DESTROYED. Do you wish to
con tinue.................... ? [d]FDISK. The "Delete DOS Partition" option is
warning you that if you continue, all data in the
DOS partition on the current fixed disk will be
destroyed. If you press Enter, the DOS partition
will NOT be destroyed. If you do wish to delete
the DOS partition, type Y and press Enter.

Warning- directory full
RECOVER. There is insufficient directory space torecover more files. You should copy some of thefiles to another disk, erase them from this disk an,..'run RECOVER again.

8-54

Warning! Diskette is out of sequence
Replace the diskette or continue
Strike any key when ready
RESTORE. The backup diskette is not the next
one in sequence. Replace the diskette unless you
are sure no files on the diskette(s) you skipped
would be restored. RESTORE will continue when
you press a key. This message will be repeated if
you try to skip a diskette which contains part of afile being restored.
Warning! File xx
is a read-only file
Replace the file (Y/N)?
RESTORE. The indicated file is read-only. Enter Y
if you want to replace it or N if you do not.
RESTORE will continue after you press ENTER.
You will see this message only if you specified theIP option.
Warning! File xx
was changed after it was backed up
Replace the file (Y/N)?
RESTORE. The indicated file on the fixed disk hasa later date and time than the corresponding fileon the backup diskette. Enter Y if you want toreplace it with the backed up version or N if you
do not. RESTORE will continue after you press
ENTER. You will see this message only if you
specified the IP option.

8-55

Warning! No files were found to back up
BACKUP. No fixed disk files were found thatmatched the backup file specification.
Warning! No files were found to restore
RESTORE. No backup diskette files were foundthat matched the restore file specification.,
Warning: no stack segment
LINK. None of the object modules specified
contain a statement allocating stack space.

WARNING-Read error on EXE fileEXE2 BIN. An error occurred while reading the
input file. EXE2BIN will attempt to continue, but
the result file may be unusable.

x
x is not a choice. Enter a choice.
FDISK. You entered x which is not a choice forthis question.

x is not choice. Enter Y or N.
FDISK. You entered x which is not a choice forthis question. Enter Y or N.

8-56

xxxxxxxxxx bytes disk space freed
CHKDSK. Diskette space marked as allocated was
not allocated. Therefore, the space was freed andmade available.

xxxx error on file yyyy
PRINT. This message appears on the printer.
While attempting to read data from file yyyy for
printing, a disk error of type xxxx was encountered.
Printing of that file is stopped.

xxx lost clusters found in yyy chains
CHKDSK. CHKDSK located xxx blocks of thedata area which were marked as allocated, but were
not associated with a file. These clusters are
assumed to contain "lost" data, and CHKDSK will
ask whether you wish to free them, or to recovereach chain into a separate file.

*** Backing up files to diskette xx ***BACKUP. This message will be followed by a listof files that were backed up on the indicateddiskette.

*** Files were backed up xx/xx/xxxx ***RESTORE. The files on the backup diskette werebacked up on the indicated date.

8-57••• Restoring files from diskette xx •••RESTORE. This message will be followed by a listof files that were restored from the indicateddiskette.
-MoreMORE. The screen is full and there is more data
waiting to be displayed. Press any character to see
the next screen full.

10 Mismatches-ending compare

CaMP. Ten mismatched locations were detectedin the files being compared. CaMP assumes thatthe files are so different that further comparisons
would serve no purpose.

8-58

Notes:

9-ii

Notes:9-2

Introduction

Each time DOS is started, it searches the root
directory of the drive (from which it was started)
for a special configuration file named
CONFIG.SYS. If found, it reads the file andinterprets the text commands within it.

Configuration Commands

The following commands can be included in theconfiguration file. If you add or change any of theconfiguration file commands, they will become
effective the next time DOS is started

9-3

BREAK Command

BREAK=ON/OFF
This command should only be used once in theconfiguration file. The default value is OFF, andcauses DOS to check for Ctrl-Break being enteredat the keyboard only when DOS is performing
screen, keyboard, printer or Asynchronous
Communication Adapter operations. With thissetting, it may not be possible to cancel an
executing program by using Ctrl-Break unless the
program causes DOS to perform one of those four
operations. Specifying ON causes DOS to checkfor Ctrl-Break whenever it performs any function
for a program. This allows you to "break" out of
programs that perform few (or no) screen,
keyboard, printer, or auxiliary device operations(such as compilers). The ON/OFF state set in theconfiguration file can later be changed by issuing a
BREAK command (see Chapter 6).

BUFFERS Command
BUFFERS=xx
Where xx is a numberbetween 1 and 99. This is
the number of disk buffers that DOS shouldallocate in memory when it starts up. The default
value is 2, and this value will remain in effect until
DOS is restarted with a different value specified in
the configuration file.

9-4

What Is a Buffer
A disk buffer is a block of memory that DOS uses
to hold data being read from, or written to a disk
(fixed disk or diskette), when the amount of data
being transferred is not an exact multiple of thesector size. For example, if an application reads a
128- byte record from a file, DOS will read theentire sector into one of its buffers, locate thecorrect 128- byte record in the buffer, and movethe record from the buffer into the application'sarea of memory. It then marks that buffer as
having been used recently. On the next request totransfer data, DOS will attempt to use a different
buffer. In this way, all of the buffers will eventuallycontain the most recently-used data. The more
buffers DOS has, the more data will be in memory.

Read/Write Requests
Each time DOS is requested to read or write arecord that is not an exact multiple of the sector
size, it first looks to see if the sector containingthat record is already in a buffer. If not, it must
read the sector as described above. But if the datais already in a buffer, then DOS can simply transfer
the record to the application's area without theneed to read the sector from the disk-this saves
time. This savings is realized on both reading andwriting records, since DOS must first read a sector
before it can insert a record your application is
attempting to write.

9-5

Random/Sequential Applications
For applications that read and write records in arandom fashion (such as many Basic and data baseapplications), the likelihood of finding the correct
record already in a buffer increases if DOS has
more buffers to work with. This can greatly speed
up the performance of those applications.
For applications doing sequential reads and writes,
however (read an entire file, write an entire file),
there is little advantage to having a large numberof buffers allocated.
Because all applications are different, there is no
specific number of buffers that will serve allapplications equally well. If your applications dolittle random reading and writing of records, thesystem default of 2 buffers (if you do not specify
BUFFERS= in your configuration file) should be
sufficient.
However, if you use data-base type applications, orrun programs that perform a lot of random reads
and writes of records, you will want to increase thenumber of DOS buffers. The "best" number ofbuffers for your particular application can only be
determined by using different values until the best
performance is achieved. For most data baseapplications, a value between 10 and 20 buffers
will usually provide the best results.
Beyond that point, the system may appear to startrunning slower - this is because, with a very large
number of buffers it can take DOS longer tosearch all the buffers for the record than it would
take to read the record from disk.

9-6

Size of Your Computer
The final consideration in determining the numberof buffers to allocate is the memory size of yourcomputer. Since each additional buffer increases
the resident size of DOS by 528 bytes, the amountof memory available to the application is reducedby that amount. Therefore, additional buffers may
actually cause some applications to slow down,
since there is less memory in which the application
itself can keep data-this could result in more
frequent reads and writes than would otherwise benecessary.
In summary, the optimum number of buffers must
be determined by you, based on:
1.

The types of applications most often used

2.

The memory size of your computer

3.

Your analysis of system performance whenusing your applications with different
numbers of buffers allocated4.

For computers with fixed disks, werecommend a minimum of BUFFERS=3.

DEVICE Command
DEVICE=[d: ][path Vi/enamel. ext]
This command allows you to specify the name of afile containing a device driver. During startup,
DOS loads the file into memory as an extension of
itself, and gives it control as described in"Installable Device Drivers" in Chapter 14. Pleaserefer to that section for technical information
about installable device drivers.

9-7

Loading Standard Device Drivers
The standard device drivers loaded by DOS
support the standard screen, keyboard, printer,auxiliary device, diskette, and fixed disk devices. A
clock driver is also loaded (see Chapter 14). You
don't need to specify any DEVICE= commands for
DOS to support these devices.

Replacing Standard Device Drivers
If you wish to use the "Extended Screen andKeyboard Control" features described in Chapter
13, you should create the file CONFIG.SYS on thedisk you will be starting DOS from. The file should
contain the command DEVICE=ANSI.SYS. This
command causes DOS to replace the standard
screen and keyboard support with the extended
functions.

Installing Your Own Device Driver
For systems programmers and application
developers-if you have written device drivers thatyou want DOS to load when it starts, include a
DEVICE= command in the CONFIG.SYS file foreach driver to be loaded.

9-8

FILES Command
FILES=xx
The maximum value for xx is 99.
Beginning with DOS Version 2.00, there is noneed for an application to construct a special
control block (FCB) in order to access a file.
Instead, the program can simply specify an ASCII
string consisting of drive specifier, complete
directory path name and filename when opening or
creating a file. DOS will locate the correct drive,
directory and file, and will create and return ahandle-merely a 16-bit binary value.

Accessing a FileAll file accesses (reads, writes, close) can then be
performed by telling DOS which handle to use.
When an application opens a file in this manner,
DOS constructs a control block in its own memory
on behalf of the application, in an area that was set
aside when DOS started. The size of this area (andconsequently, the maximum number of files thatcan be concurrently open), depends on the value
specified in the FILES= command.
The default value is FILES=8; that is, no morethan 8 files can be open at the same time. There isno effect on the number of files that can be
concurrently open using the traditional (OPEN
FCB) functions. This default value is sufficient forthe majority of operating environments. However,
if applications are installed that result in error
messages indicating an insufficient number ofhandles, the FILES= command should be used toprovide DOS with additional handles.

9-9Number of Files Opened
The value specified in FILES= becomes the new
maximum number of files that DOS allows to be
concurrently open.
Note that this value is the maximum number offiles allowed for the entire system. The maximum
number of files that a process can haveconcurrently open is 20 (this number includes the
5 predefined handles for standard input, output,
error, auxiliary, and standard printer).
If you specify FILES= in your configuration file,the size of the resident portion of DOS increases
by 39 bytes for each additional file above thedefault value of 8. Consequently, the memory
available to the application is reduced by the sameamount. See function calls hex 3C through hex 46
in Appendix D for descriptions of the new
file- handling functions.

9-10

SHELL Command
SHELL=[d.· ]fpath ]fi/ename[. ext]
This command allows you to specify the name andlocation of a top-level command processor that
DOS initialization will load in place of
COMMAND. COM.
System programmers who develop their own
top-level command processor should remember toinclude provisions for handling interrupts hex 22,
hex 23 and hex 24, and for reading and executing
commands.
Note: Because the internal commands,
batch processor, and EXEC function call(program loader) reside in COMMAND. COM.
These functions will not be available to theuser unless they are duplicated in yourcommand processor.

9-11.

Notes:9-12Notes:10-2

Introduction

This chapter explains how to use the advanced
DOS commands. You can use advanced DOS
commands to:•

Set options for the Asynchronous
Communications Adapter.

•

Define a remote device as your primaryconsole.

•Sort text data.

•

Search files for occurrences of specified
strings of text.

•

Display a screen full of data at a time.

•

Set new system prompt.

•

Set the system environment.

•

Convert .EXE files to .COM files.

10-3Redirection of Standard Input andOu tpu t Devices

The DOS standard input and output device
redirection feature allows a program to receive its
input from a source other than the keyboard(standard input), or direct its output to a device
other than the display screen (standard output).
The standard input and output devices can be
redirected to or from files or other devices by thefollowing DOS command line parameters:>[d:] fpathlfilename
Causesfilename to be created (or truncated tozero length) and then assigns standard output
to that file. All output that would normally
have gone to the screen from the command isplaced in the file.

>> [d:] fpathlfilename
Causes filename to be opened (created if
necessary) and positions the write pointer atthe end of the file so that all output isappended to the file.

10-4

<[d:] fpathlfilename
Causes standard input to be assigned tofilename. All input to the program comes fromthis file instead of from the keyboard.
CAUTION
When using this method of providing input to a
program, be sure all of the program's input is in
the file. If the program attempts to obtain more
input after end-of-file is reached, DOS is unable
to supply the input, and processing will stop.
You can return to the DOS prompt by entering
Ctrl- Break.
Note: If an application does not use DOS
function calls to perform standard input
and/or output (for example you put text
directly into the video buffer), thenredirection will not work for that application.
Example: In this example, the output of the DIR
command is sent to the printer:
OIR >PRN

In this example, the output of the DIR
command is sent to file DIRLIST:
OIR >OIRLlST

In the following example, program MYPROG
will receive its input from file INPUT. TXT,
instead of from the keyboard:
MYPROG <INPUT.TXT

10-5

Piping of Standard Input and
Output

The DOS piping feature)llows the screen output
of one program to be used as the keyboard input
to another program. DOS uses temporary files tohold the input and output data being piped. These
temporary files are created in the root directory ofthe default drive and have the form:
0/0

PI PEx.$$$The programs being piped must use care not tocause the piping files to be erased or modified.
Piping is the chaining of programs with automatic
redirection of standard input and output (refer to"Redirection of Standard Input and Output
Devices" in this chapter for additional
information). The names of the programs to bechained are separated by the vertical bar (:)
character on the command line.
The following are typical examples of using thepiping feature for a program that does all of its
input and output to the standard devices (screen
and keyboard). For example, if the program named
SORT read all of it's standard input, sorted it, andthen wrote it to the standard output device, thecommand:
OIR:SORl

would generate a sorted directory listing. This
causes all standard output generated by the DIR
command to be sent to the standard input of the
SORT program.
10-6

To send the sorted directory to a file, you wouldtype:
OIR lSORT>FILE

If you wish the file to contain only the directory
entries for sub-directories, you could enter:
OIR :FINO "OIR": SORT>FILE

DOS Filters

A filter is a program or command that reads datafrom a standard input device, modifies the data,then writes the result to a standard output device.
Thus, the data has been "filtered" by the program.
For example, one of the filters on your DOS
diskette is called SORT. SORT reads input fromthe standard input device (normally the keyboard),
sorts the lines of data, then writes the sorted
results to the standard output device (normally thescreen). With the redirection capabilities describedearlier in this chapter, you can cause SORT to
receive its input from some other source, and tosend its output to a different destination. For
example,SORT <MYFILE >RESULT

will cause SORT to read the file MYFILE, sort thelines within it, and write the sorted output to file
RESULT.

10-7

By using the piping feature, you can cause a filter
to receive its input from the output of anothercommand, or to send its output to the input of
another command. For example,
DIR : SORT

causes the output listing from the DIR command
to be used by SORT as its input. The listing will besorted and the result displayed on the screen.
There are three filters on your DOS diskette, andthey are described as individual commands in thischapter. They are:
SORT

Sorts text data.

FIND

Searches files for occurrences of specified
strings of text.

MORE

Displays a screen full of data at a time,then pauses with the message -More--.

You can easily add your own filter to the filtersthat have been supplied; just write a program that
reads its input from the standard input device, andwrites its output to the standard output device.
Note: If an application does not use DOS
function calls to perform standard input
and/or output (for example you put text
directly into the video buffer), then filters will
not work for that application.

10-8

Detailed Descriptions of Advanced
DOS Commands

This section presents a detailed description of how
to use the advanced DOS commands. The
commands appear in alphabetical order; each with
its purpose, format, and type. Examples areprovided where appropriate. For "Information
Common to All DOS Commands" refer to Chapter 6.

Invoking a Secondary Command
Processor
If you wish to invoke a secondary commandprocessor, the following syntax should be used:
COMMAND [d:](path) [IP) [IC string)
Where d.-path will be the directory searched forthe command processor to be loaded, IP causes
the new copy to become permanent in memory,and Ie string allows you to pass a command line
(string) as a parameter. The command line will beinterpreted and acted upon as if you had entered it
as a normal command. For example, COMMANDIC DIR B: causes a secondary command processor
to be loaded, and it executes the command
DIRB:.

10-9

Issuing COMMAND without any parameterscauses a new copy of the command processor to beloaded, and this new copy will inherit theenvironment (will never be able to change theenvironment via a SET command).
When a secondary command processor has been
loaded, you can cause it to return to the previous
level of command processor by issuing the special
command EXIT. If you used the /p parameter, it
will not return to the previous level (refer toAppendix F for additional information).

10-10

CTTY (Change Console)
CommandPurpose:Changes the standard input and output console
to an auxiliary console, or restores the keyboard
and screen as the standard input and output
devices.

FormatCTTY device-name

Type:Internal

External***
Remarks: Defines the device to be used as the primaryconsole. Specifying AUX, COMl, or COM2
causes DOS to use that device as the primaryconsole. Specifying CON resets the standard
input and output device to the primary console.
Example: In this example, the command causes DOS to
use the AUX device for its screen and keyboard
operations:
cmAUX

10-11

CTTY (Change Console)
Command

In this example, the command reverses theprevious assignment, causing DOS to switch
back to the standard screen and keyboard for its
operations:em CON
Notes:

10-12

1.

The CTTY command accepts thename of any character-oriented device
to allow you to install your own device
drivers, and to specify their device
names. You must be certain that thenamed device is capable of both input
and output operations. For example,
you should not specify the name of a
printer, because DOS will attempt toread from that device.

2.

The CTTY command only accepts
programs that use DOS function calls.
Other programs, such as BASIC (thatdo not use DOS function calls), will
not be able to use the CTTY command
to change the standard input andoutput device.

EXE2BIN
CommandPurpose:Converts .EXE files that have no segment fix up
to a form that is compatible with. COM
programs. This results in a saving of diskettespace and faster program loading.

Format:

EXE2BIN [d:] [pathlfitename[.ext]][d:] [path] [fi'lename[.ext]]
Type:Internal

External***
Remarks: The file named by filespec is the input file. If no
exten~ion is specified, it defaults to . EXE. The
input file is converted to . COM file format(memory image of the program) and placed in
the output file, [d:lfitename[.ext]. If you do not
specify a drive, the drive of the input file is used.
If you do not specify an output filename, theinput filename is used. If you do not specify afilename extension in the output filename, the
new file is given an extension of. BIN. If you do
not specify a path, the current directory is used.
The input must be in valid .EXE format as
produced by the linker. The resident, or actual
code and data, part of the file must be less then
64K. There must be no STACK segment.

10-13

EXE2BIN
Command

Two kinds of conversions are possible,
depending on the specified initial CS:IP:•

If CS:IP is not specified in the program (the.EXE file contains 0:0), a pure binary
conversion is assumed. If segment fixups
are n~essary (the program contains
instructions requiring segment relocation),
you are prompted for the fixup value. Thisvalue is the absolute segment at which theprogram is to be loaded.
In this case, the resultant program is usable
only when loaded at the absolute memory
address specified by a user application. The
DOS command processor will not becapable of properly loading the program.

•

10-14

If CS:IP is specified as OOOO:100H, it isassumed that the file is to be run as a COM
file, with the location pointer set at 100Hby the assembler statement ORG; the first
100H bytes of the file are deleted. No
segment fixups are allowed, as COM files
must be segment relocatable; that is, tliey
must assume the entry conditions explainedin Appendixes B-K. In this case, once theconversion is complete, you may rename
the resultant file to a .COM extension.
Then, the command processor is capable ofloading and executing the program in thesame manner as the .COM programs
supplied on your DOS diskette.

EXE2BIN
Command

If CS:IP does not meet one of these criteria, or if
it meets the COM file criterion but has segment
fixups, the following message is displayed:
File cannot be convertedThis message is also displayed if the file is not avalid. EXE file.
To produce standard COM files with theassembler, you must both use the assembler
statement ORG to set the location pointer ofthe file at 100R and specify the first location as
the start address. (This is done in the END
statement.) Also, the program must not use
references that are defined only in otherprograms. For example, with the IBM Personal
Computer MACRO Assembler:
ORG 100H
START:•••
END STARTEXE2 BIN resides on your DOS Supplemental
Program diskette.

10-15

FIND Filter
CommandPurpose:This filter sends to the standard output device
all lines from the filenames specified in thecommand line that contain the specified string.

Format:

FIND [IV] [Ie] [lNlrtring[[d.·] [pathlfilename[. ext] ... ]Type:Internal

External***
Remarks: The IV parameter causes all lines not containing
the string to be displayed.
The Ie parameter causes FIND to display only acount of the number of matching occurrences ofstrillg in each file, without displaying thematching lines from the file.
The IN parameter causes the relative line
number of each matching line to be displayed
ahead of the line from the file.
The string should be enclosed in double quotes.
Two quotes in succession are taken as a single
quote.
Global filename characters are not allowed in
the filenames or extensions.

10-16

FIND Filter
Command

Examples:

A>FIND "Fool's Paradise" bookl.txt book2.txt book3

will output all lines from the book1. txt,
book2. txt, and book3 (in that order) that
contain the string "Fool's Paradise". Or,
A>OIR B: : FIND IV "OAT'

will ou tpu t the names of all the files in drive Bthat do not contain the string DAT.

10-17

MORE Filter
CommandPurpose:This filter reads data from the standard input
device, and sends one screen-full of data to thestandard output device, and then pauses withthe message -More--.

Format:

MORE

Type:

Internal

External***
Remarks: Pressing any character key causes anotherscreen-full of data to be written to the standard
output device. This process continues until all
input data is read.
Example: In this example, the command line will display
the contents of file TEST.ASM one screen-full ata time. When the screen is full, the message-More- appears on the bottom line. You canpress any key to see the next screen-full:
MORE <TEST.ASM

10-18

PROMPT (Set System Prompt)
CommandPurpose:Sets a new system prompt.

Format:

PROMPT [prompt-text]

Type:Internal

External***
Remarks: All text on the PROMPT command line is taken
by DOS to be the new system prompt. If noparameter is specified, the normal DOS prompt
is assumed. Special meta-strings can be
imbedded in the text in the form $c.
Where c is one of the following:$
The "$" character.
t
The time.
d
The date.
p
The current directory of the default drive.
v
The version number.
n
The default drive.
g
The ">" character.
1
The "<" character.
b
The"" character.
q
The "=" character.
hA backspace and erasure of the previous
character.
e
The ESCape character.
The CR LF sequence (go to beginning of
new line on the display screen).

10-19

PROMPT (Set System Prompt)
CommandAny other character is treated as a nullcharacter-no action is taken on it by the
PROMPT command.
Example: In this example, the command would set thenormal DOS prompt:
PROMPT $n$1

In this example, the command would set ABC as
the system prompt:
PROMPT ABC

In this example, the command would set a twoline prompt that displays:
Time = (current time)
Date = (current date)
PROMPT Time = $t$_ Date = $d

If you wish to create a prompt that begins withany of the DOS command delimiters (such as
semicolon, blank, etc.), you can precede thatcharacter with a null meta-string. In this case,the character will be treated as the firstcharacter of the prompt, rather than as adelimiter between the word PROMPT and its
parameter. For example:
PROMPT $A;ABC

10-20

PROMPT (Set System Prompt)
Commandcauses the PROMPT command to interpret the$A as a null character, because A is not one ofthe defined characters in the above list. All
characters following the null character will
become the new system prompt.

10-21

SET (Set Environment)
CommandPurpose:This command inserts strings into the commandprocessor's environment. The entire series ofstrings in the environment is made available toall commands and applications.

Format:SET [name=[parameter]]

Type:

Internal

External***
Remarks: The entire string (beginning with name) isinserted into a block of memory reserved forenvironment strings. Any lowercase letters in
the name are converted to uppercase letterswhen added to the environment; the remainderof the line is inserted as you entered it. If thename already existed in the environment, it isreplaced with the new parameter.
If the SET command is entered with no namespecified, then the current set of environment
strings will be displayed.
If a name is specified, but the parameter is not
specified, then the current occurrence of
name=parameter is removed from theenvironment.

10-22

SET (Set Environment)
Command

The environment (series of names andparameters) is made available to all DOS
commands and applications (see the "Program
Segment Prefix description" in Appendix E).
You can display the current environment
contents by entering a SET command with noparameters. You can select the strings in theenvironment. For example, entering:
SET abe==xyz

will add the string ABC=xyz to the other strings
already in the environment (note the conversionof abc to uppercase ABC). In this way, it ispossible for you to enter keywords andparameters that are not meaningful to DOS, but
can be found and interpreted by applications
that are designed to examine the environment.

Example: This example will add the string
PGMS= LEVEL2 to the environment. When an
application program receives control, it could
search the environment for the name PGMS,
and use the supplied parameter as the directory
name to use for its files:
SET PGMS-\LEVE12

10-23

SET (Set Environment)
Command

The following example would remove
PGMS= LEVEL2 from the environment:
SET PGMS=

Notes:

10-24

1.

DOS automatically adds any PROMPTor PATH commands to theenvironment when you enter them.
You do not need to use the SET
command to add either of these twocommands to the environment.

2.

One of the strings in the environment(placed there by DOS when it startsup) will always be a COMSPEC =parameter. That parameter describes
the path that DOS uses to reload thecommand processor when necessary.

SET (Set Environment)
Command3.

If you have not loaded a program that~emains resident (such as MODE,
PRINT, GRAPHICS, etc.), DOS
expands the environment string area tohold additional strings. If you haveloaded a program that remains
resident, DOS is unable to expand theenvironment area beyond 127 bytes orif the environment area has alreadyexpanded beyond 127 bytes when you
load a program that is to remain
resident, DOS is unable to expand theenvironment area beyond that point.
The message Out of environment
space appears if you issue a SET
command that would cause the
combined environment strings toexceed 127 bytes.

10-25

SORT Filter
CommandPurpose:This filter command reads data from thestandard input device, sorts the data, then writes
the data to the standard output device.

Format:SORT (/R] (/+n]Type:Internal

External***
Remarks: Sorts are done using the ASCII collating
sequence. Tab characters are not expanded withblanks.
The /R parameter will reverse the sort, forexample make" Z" come before" A. "The / + n parameter is an integer that starts thesort with column n. If no parameters are
specified, the sort starts with column 1. The
maximum file size that can be sorted is 63K.

10-26

SORT Filter
Command

Example: In this example, the command line will read thefile UNSORT.TXT, do a reverse sort, then write
the output to file SORT. TXT:
A>SORT IR <UNSORT.TXT >SORT.TXT

In the next example, the command line causes
the output of the directory command to be
piped to the SORT filter. The SORT filter will
sort starting with column 14 (this is the column
the file size starts in), then send the output tothe console. Thus, a directory sorted by file size
will be the result:
A>DIR: SORT 1+14

10-27

Summary of Advanced DOS
Commands

The following chart is provided for quickreference. The section called "Format Notation"at the beginning of Chapter 6 explains thenotation used in the format of the commands.
Note: In the column labeled Type, the I
stands for Internal and the E stands forExternal.

10-28

Command Type Purpose

FormatCTTY

Change to an
auxiliary console

CTTY device-nameConverts. EXE
files to .COM
format

EXE2BIN[d:] [pathVilename[.ext]]

I

EXE2BIN E[d:] [path] [filename[.ext]]
FIND

E

Searches files forstrings of text

FIND[I"] [/C] [IN]string[[d:] [path]l/i'lename [.ext] ... ]

MORE

E

Displays a screen MORE
full of data

PROMPTE

Set new prompt

SET

I

SET
Inserts strings[name=[parameter]]into the command,processor senvironment

SORT

E

Sorts text data

PROMPT[prompt-text]

SORT [lR] [I+n]Figure 4. DOS Advanced Commands

10-29

Notes:10-30

·,il:i,',... '~~f~;~ •....•~~.;.~0;~a;i.'Am.:~.~.:T~f:~~r~..
''':~''';:~:'~;';'>'"

L".L:.'-I.

.
.,

How to Start the Linker Program ........
Before You Begin ...................
Option 1 - Console Reponses ........
Option 2 - Command Line ...........
Option 3 - Automatic Responses .....

11-19
11-19
11-19
11-20
11-22

Example Linker Session ................. 11-25
How to Determine the Absolute
Address of a Segment ............... 11-28
Messages ............................... 11-30

11-2

Introduction

The linker (LINK) program is a program that:•

Combines separately produced object
modules•

Searches library files for definitions ofunresolved external references•

Resolves external cross-references•

Produces a printable listing that shows theresolution of external references and error
messages•

Produces a relocatable load module

The LINK program resides on your DOS
Supplemental Program Diskette. In this chapter,
we show you how to use LINK. You should read
all of this chapter before you start LINK.

11-3

FilesThe linker processes the following input, output,
and temporary files:

Input FilesType

Default Override
.ext
.ext

ProducedbyObject.OB]

YesCompiler!
or MACRO!Assembler

Library.LIB

Yes

Compiler

Automatic
Response(None)

N/A*

User

Figure 5. Input files used by the linker*N/A - Not applicable.

lOne of the optional compiler packages available
for use with the IBM Personal Computer DOS.

11-4

Output FilesType

Default Override
.ext
.ext

Used
by

Listing

. MAP

Yes

User

Run

.EXE

No

Relocatable
loader(COMMAND.
COM)

Figure 6. Output files used by the Linker

VM. TMP (Temporary File)
LINK uses as much memory as is available to holdthe data that defines the load module being
created. If the module is too large to be processedwith the available amount of memory, the linker
may need additional memory space. If thishappens, a temporary file called VM. TMP iscreated on the DOS default drive.
When the overflow to the VM. TMP file has begun,
the linker displays the following message:
VM.TMP has been created
Do not change diskeHe in drive x

If the VM. TMP file has been created on diskette,you should not remove the diskette until LINK
ends. When LINK ends, it erases the VM.TMP file.

11-5

If the DOS default drive already has a file by thename of VM. TMP,. it will be deleted by LINK and a
new file will be allocated; the contents of theprevious file are destroyed. Therefore, you should
avoid using VM. TMP as one of your own
filenames.

Definitions

Segment, group, and class are terms that appear in thischapter and in some of the messages in Chapter 8.
These terms describe the underlying function of
LINK. An understanding of the concepts thatdefine these terms provides a basic understandingof the way LINK works.

Segment
A segment is a contiguous area of memory up to
64K bytes in length. A segment may be locatedanywhere in memory on aparagraph (16-byte)boundary. Each of the four segment registers
defines a segment. The segments can overlap. Each
16-bit address is an offset from the beginning of asegment. The contents of a segment are addressedby a segment register/offset pair.
The contents of various portions of the segment
are determined when machine language is
generated.

11-6

Neither size nor location is necessarily fixed by thecompiler or assembler because this portion of thesegment may be combined at link time with otherportions forming a single segment.
A program's ultimate location in memory isdetermined at load time by the relocation loader
facility provided in COMMAND. COM, based onwhether you specify the /HIGH parameter. The/HIGH parameter is discussed later in this chapter.

Group
A group is a collection of segments that fit together
within a 64K-byte segment of memory. The
segments are named to the group by the assembler
or compiler. A program may consist of one ormore groups.
The group is used for addressing segments inmemory. The various portions of segments within
the group are addressed by a segment base pointerplus an offset. The linker checks that the object
modules of a group meet the 64K-byte constraint.

Class
A class is a collection of segments. The naming ofsegments to a class affects the order and relative
placement of segments in memory. The class nameis specified by the assembler or compiler. All
portions assigned to the same class name are
loaded into memory contiguously.

11-7

The segments are ordered within a class in theorder that the linker encounters the segmentsin the object files. One class precedes another inmemory only if a segment for the first classprecedes all segments for the second class in the
input to LINK. Classes are not restricted in size.
The classes are divided into groups for addressing.

Command Prompts

After you start the linker session, you receive aseries of four prompts. You can respond to these
prompts from the keyboard, respond to these
prompts on the command line, or you can use a
special diskette file called an automatic response file torespond to the prompts. An example of an
automatic response file is provided in this chapter.
LINK prompts you for the names of the object,run, list, and library files. When the session isfinished, LINK returns to DOS and the DOS
prompt is displayed. If linking is unsuccessful,
LINK displays a message.
The prompts are described in order of theirappearance on the screen. Defaults are shown insquare brackets ([ ]) after the prompt. In the
response column of the table, square brackets
indicate optional entries. Object Modules is the
only prompt that requires a response from you.

11-8

PROMPTRESPONSES

Object Modules [.OBJ]:[d:] rPathVilename[. ext][+[ d:] rPathlfilename[. ext]] ...

Run File [filename.EXE]:[d:] rPath] [filename [. ext]]

List File [NUL. MAP] :[d:] rPath] [fi'lename[.ext]]

Libraries [.LIB]:[d:] [[pathlfilename[.ext]][+[d:] [rPathlfi'lename[.ext]]] ...

Notes:
1.

If you enter a filename without specifying
the drive, the default drive is assumed. If
you enter a filename without specifying
the path, the default path is assumed.
The libraries prompt is an exceptionthe linker will look for the libraries on
the default drive and if not found, lookon the drive specified by the compiler.

2.

You can end the linker session prior to
its normal end by pressing Ctrl-Break.

11-9

Detailed Description of the
Command Prompts

The following detailed descriptions contain
information about the responses that you canenter to the prompts.

Object Modules [.OBJ]:Enter one or more file locations for the object
modules to be linked. Multiple file locations must
be separated by single plus (+) signs or blanks. If
the extension is omitted from any filename, LINK
assumes the filename extension. DB]. If an object
module has a different filename extension, theextension must be specified. Object filenames can
not begin with the @ symbol (@ is reserved forusing an automatic response file).
LINK loads segments into classes in the orderencountered.
If you specify an object module on a diskette drive,
but LINK cannot locate the file, it displays thefollowing prompt:
Cannot lind ru, object modulechang, dlsk,n, <hit ENTER>

11-10

If you specify an object module on a
non-removable media (like a fixed disk), the linker
session will end with the following message:
Cannot find file object module

You should insert the diskette containing therequested module. This permits .OB] files fromseveral diskettes to be included. On a single-drive
system, diskette exchanging can be done safely
only ifVM.TMP has not been opened. As explainedin the discussion of the VM. TMP file earlier in thischapter, a message will indicate if VM. TMP has
been opened.
IMPORTANT: If a VM.TMP file has been
opened on a diskette, you should not remove thediskette containing the VM.TMP file. Remember,once a VM. TMP file is opened on a diskette, thediskette it resides on cannot be removed.
After a VM. TMP file has been opened, if you
specified an object module on the same disk that
VM.TMP is on and LINK cannot find it, the linker
session ends with the message:
Cannot find file object module

11-11

Run File [filename.EXE]:
The file specification you enter is created to store
the run (executable) file that results from the
LINK session. All run files receive the filename
extension .EXE, even if you specify anotherextension. If you specify another extension, yourspecified extension is ignored.
The default filename for the run file prompt is thefirst filename specified on the object module
prompt.
You can specify just a drive letter, or a path on therun file prompt. This changes the place where therun file filename. EXE is placed.

List File [NUL.MAP]:
T he linker list file is sometimes called the linker
map.
The list file is not created unless you specificallyrequest it. You can request it by overriding thedefault with a drive letter, path, orfilename[.ext]. If
you do not include a filename extension, thedefault extension .MAP is used. If you do not enteranything, the DOS reserved filename NULL
specifies that no list file will be created.
The list file contains an entry for each segment in
the input (object) modules. Each entry also shows
the offset (addressing) in the run file.

11-12

You can specify just a drive letter or a path on thelist file prompt. This changes the place where thelist file is placed.
Note: If the list file is allocated to a file on
diskette, that diskette must not be removed
until the LINK has ended.
If you specify an object module on the samediskette drive as the diskette drive to which the list
file is allocated, and LINK cannot find the object
module, the linker session ends with the message:
Cannot find file object module

To avoid generating the list file on a diskette, you
can specify the display or printer as the list filedevice. For example:
List File [NUL.MAP]: CON

If you direct the output to your display, you canalso print a copy of the output by pressing
Ctrl-PrtSc.

Libraries [.LIB]:
You may either list the file locations for yourlibraries, or just press the Enter key. If you press
the Enter key, LINK defaults to the libraryprovided as part of the Compiler package.

11-13

The LINK program will look for the Compiler
package library on the default drive. If it cannot
find the library there, then it will look for the
library on the drive specified by the Compiler
package. For linking objects from just the MACRO
Assembler, there is no automatic default library
search.
If you answer the library prompt, you specify a listof drive letters and fpathlfilename.ext separated byplus signs (+) or spaces. You can enter from one toeight library file locations. Specifying a drive letter
tells linker to look on that drive instead of
the Compiler package supplied drive for all
subsequent libraries on the library prompt. The
automatically searched library file specifications
are conceptually placed at the end of the responseto the library prompt.
LINK searches the library files in the order inwhich they are listed to resolve externalreferences. When LINK finds the module thatdefines the external symbol, the module isprocessed as another object module.
If two or more libraries have the same filename,regardless of the location, only the first library in
the list is searched.
When LINK cannot find a library file, it displays amessage like this:Cannal find library A:I/ibrary file
Enler nlw drivi Ilnlr:
The drive that the indicated library is located onmust be entered.

11-14

The following library prompt responses may be
used:
Ubrarles [.LlB]: B:

Look for compiler. LIB on drive B.
Libraries [.LlB]: B:USERLIB

Look for USERLIB. LIB on drive Band
compiler. LIB on drive A.
Ubrarles [.LlB): A:LlBl+LlB2+B:Ll83+A:

Look for LIBl.LIB and LIB2.LIB on drive
A, LIB3.LIB on drive B, andcompiler. LIB on drive A.

Linker Parameters
At the end of any of the four linker prompts, you
may specify one or more parameters that instruct
the linker to do something differently. Only the /and first letter of any parameter are required.

11-15

/DSALLOCATION
The /DSALLOCATION (/D) parameter directs
LINK to load all data defined to be in DG ROUP at
the high end of the group. If the IHIGH parameteris specified, (module loaded high), this allows any
available storage below the specifically allocatedarea within DGROUP to be allocated dynamicallyby your application and still be addressable by thesame data space pointer.
Note: The maximum amount of storage
which can be dynamically allocated by theapplication is 64K (or the amount actuallyavailable) minus the allocated portion of
DGROUP.
If the IDSALLOCATION parameter is not
specified, LINK loads all data defined to be in thegroup whose group name is DGROUP at the low
end of the group, beginning at an offset of O. The
only storage thus referenced by the data spacepointer should be that specifically defined as
residing in the group.
All other segments of any type in any GROUP
other than DGROUP are loaded at the low end of
their respective groups, as if the
IDSALLOCA TION parameter were not specified.
For certain compiler packages, /DSALLOCA TION
is automatically used.

11-16

/HIGH
The /HIG H (lH) parameter causes the loader toplace the run image as high as possible in storage.
If you specify the /HIGH parameter, you tell thelinker to cause the loader to place the run file as
high as possible without overlaying the transient
portion of COMMAND. COM, which occupies thehighest area of storage when loaded. If you do not
specify the /HIGH parameter, the linker directs
the loader to place the run file as low in memory as
possible.
The /HIGH parameter is used with the/DSA~LOCA TION parameter.

/LINE
For certain IBM Personal Computer language
processors, the /LINE (lL) parameter directs LINK
to include the line numbers and addresses of thesource statements in the input modules in the list
file.

/MAP
The /MAP (/M) parameter directs LINK to list all
public (global) symbols defined in the input
modules. For each symbol, LINK lists its value andsegment-offset location in the run file. The
symbols are listed at the end of the list file.

11-17

/PAUSEThe IPAUSE (/P) parameter tells LINK to display
a message to you as follows:
About to generate. EXE file
Change disks <hit ENTER>

This message allows you to insert the diskette thatis to contain the run file.

/STACK:size
The size entry is any positive decimal value up to65536 bytes. This value is used to override the sizeof the stack that the MACRO Assembler orcompiler has provided for the load module being
created. If you specify a value greater than 0 but
less than 512, the value 5 12 is used
If you do not specify ISTACK (IS), the original
stack size provided by the MACRO Assembler orcompiler is used.
If the size of the stack is too small, the results ofexecu ting the resulting load module areunpredictable.
At least one input (object) module must contain astack allocation statement, unless you plan to use
the EXE2BIN program. This is automaticallyprovided by compilers. For the MACRO
Assembler, the source must contain a SEGMENT
command that has the combine type of STACK. If
a stack allocation statement was not provided,
LINK returns a Warning: No Stack statement
message.

11-18

How to Start the Linker Program

Before You Begin•

Make sure the files you will be using forlinking are on the appropriate disks.

•

Make sure you have enough free space on
your disks to contain your files and any
generated data.

You can start the linker program by using one ofthree options:

Option 1 - Console Responses
From your keyboard, enter:
LINK

The linker is loaded into memory and displays aseries of four prompts, one at a time, to which you
must enter the requested responses. (Detailed
descriptions of the responses that you can make tothe prompts are discussed in this chapter.)If you enter a wrong response, such as anincorrectly spelled filename, you must press
Ctrl-Break to exit LINK, then restart LINK. If the
response in error has been typed but you haven't
pressed Enter yet, you may delete the wrong
characters (on that line only).

11-19

An example of a linker session using the console
response option is provided in this chapter in thesection called "Example Linker Session."
As soon as you have entered the last filename, thelinker begins to run. If the linker finds any errors,
it displays the errors on the screen as well as in thelisting file.
Note: After any of these responses, before
pressing Enter, you may continue theresponse with a comma and the answer towhat would be the next prompt, without
having to wait for that prompt. If you end any
with the semicolon (;), the remaining
responses are all assumed to be the default.
Processing begins immediately with nofurther prompting.

Option 2 - Command Line
From your keyboard, enter:
LINK objlist,runfile, map file, lib list [parm] ... ;11-20

objlistis a list of object modules separated by
spaces or plus signs (+).

runfileis the name you want to give the run file.

mapfileis the name you want to give the linker
map.

liblistis a list of the libraries to be used,
separated by plus signs (+) or spaces.

parm

is an optional linker parameter. Eachparameter must begin with a slash (I).

The linker is loaded and immediately performs thetasks indicated by the command line.
When you use this command line, the prompts
described in Option 1 are not displayed if you
specified an entry for all four files or if thecommand line ends with a semicolon.
If an incomplete list is given and no semicolon isused, the linker prompts for the remaining
unspecified files.
Each prompt displays its default, which may be
accepted by pressing the Enter key, or overriddenwith an explicit filename or device name.
However, if an incomplete list is given and thecommand line is terminated with a final semicolon,
the unspecified files default without further
prompting. The parms are never prompted for, but
may be added to the end of the command line or
to any file specification given in response to aprompt.
Certain variations of this command line are
permitted.
Examples:
LINK module
The object module is MODULE.OB]. A
prompt is given, showing the default of
MODULE.EXE. After the response isentered, a prompt is given showing thedefault of NUL. MAP . After the response
is given, a prompt is displayed showing
the default extension of .LIB.

11-21

LINK module;
If the semicolon is added, no further
prompts are displayed The object
module of MODULE. OB] is linked, therun file is put into MODULE. EXE, andno list file is produced.
LINK module,,;This is similar to the preceding example,
except the list file is produced in
MODULE. MAP.
LINK module"
Using the same example, but without thesemicolon, MODULE.OB] is linked, andthe run file is produced in
MODULE.EXE, but a prompt is given
with the default of MODULE. MAP.
LINK module"NUL;No list file is produced. The run file is in
MODULE.EXE. No further prompts are
displayed.

Option 3 - Automatic Responses
It is often convenient to save responses to thelinker for use at a later time. This is especially
useful when long lists of object modules need to
be specified.

11-22

Before using this option, you must create theautomatic response file. It contains several lines oftext, each of which is the response to a linker
prompt. These responses must be in the sameorder as the linker prompts that were discussed
earlier in this chapter. If desired, a long responseto the object module or libraries prompt may becontained on several lines by using a plus sign (+)
to continue the same response onto the next line.
To specify an automatic response file, you enter afile specification preceded by an @ symbol in placeof a prompt response or part of a prompt
response. The prompt is answered by the contentsof the diskette file. The file specification may not
be a reserved DOS filename.
From your keyboard, enter:
LINK @(d:](pathlfilenamel(ext)

Use of the filename extension is optional and may
be any name. There is no default extension.
Use of this option permits the command that starts
LINK to be entered from the keyboard or within abatch file without requiring any response fromyou.
ExampleAutomatic Response File - RESPIMODA+MODB+MODC+
MODB+MODE+MODF

11-23

Automatic Response File - RESP2
runflle/p
printout

Command line
LINK @IESP1 +mymod,@RESP2;

Notes:

11-24

1.

The plus sign at the end of the first line
in RESP1 causes the modules listed in thefirst two lines to be considered as the
input object modules. After reading
RESP1, the linker returns to thecommand line and sees +mymod, so it
includes MYMOD.OB) in the first list of
object modules as well.

2.

Each of the above lines ends when you press
the Enter key.

Example Linker Session

This example shows you the type of informationthat is displayed during a linker session.
Once we enter:b:linkin response to the DOS prompt, the system
responds with the following messages andprompts, which we answer as shown:
IBM Personal Computer Unker
Version 2.00 (C) Copyright IBM Corp. 1981, 1982, 1983
Object Modules (.OBJ]: example
Run File (EXAMPLE.EIE): /map
List File (NUL.MAP]: prn/line
Ubraries (.LlB]:

Notes:
1.

By specifying / map, we get both analphabetic listing and a chronologicallisting of public symbols.

2.

By responding prn to the list file prompt,
we send our output to the printer.

3.

By specifying the /LINE parameter,
LINK gives us a listing of all line
numbers for all modules. (The /LINEparameter can generate a large amount of
output.)4.

By just pressing Enter in response to thelibraries prompt, an automatic library
search is performed.
11-25

Once LINK locates all libraries, the linker map
displays a list of segments in the relative order of
their appearance within the load module. The list
looks like this:
Start

Stop

Length

Name

Class

OOOOOH
0OO30H
00100H
00100H
038D4H

0OO28HOOOF6H
00100H
038D3H
04921H

0029H
OOC7H
OOOOH
37D4H
104EH

MAINOOENTXOOINIXOOFILVOO_CODEFILUOO _CODE

CODE
CODE
CODE
CODE
CODE

074AOH
074AOH
0759FH
07925H
082A9H

OOOOH
OOOOH
0100H
0386H
097AH

HEAP
MEMORY
STACK
DATA
CONST

MEMORYMEMORY
STACK
DATA
CONST

•
•
•

074AOH
074AOH
074AOH
075AOH
07930HThe information in the Start and Stop columns
shows a 2o-bit hex address of each segment
relative to location zero. Location zero is the
beginning of the load module. The addresses
displayed are not the absolute addresses of wherethese segments are loaded. To find the absoluteaddress of where a segment is actually loaded, youmust determine where the segment listed as beingat relative zero is actually loaded; then add theabsolute address to the relative address shown in
the linker map. The procedure you use todetermine where relative zero is actually located is
discussed in this chapter, in the section called"How to Determine the Absolute Address of a
Segment."

11-26

Now, because we specified the lMAP parameter,
the public symbols are displayed by name and byvalue. For example:
Address

Publics by Name

0492:0003H
06CO:029FH
0492:0013H
06CO:0087H
0602:000FH

ABSNOO
ABSROOAOONOOAOOROOALLHOO•••

0010:1 BCEH
0010:107EH
0010:1887H
0010:19E2H
0010:1182H

WT4VOOWTFVOOWTIVOOWTNVOOWTRVOO

Address

Publics by Value

0000:0001 H
0000:0010H
0000:0010H
0003:0000H
0003:0095H

MAIN
ENTGOO
MAINOOBEGXOOENOXOO•••F82B:f31 CH
F82B:f31 EH
F82B:f322H
F82B:F5B8H
F82B:F5mH

CRCXOOCROXOOCESXOOFNSUOOOUTUOO

11-27

The addresses of the public symbols are in thesegment:offset format, showing the location relative
to zero as the beginning of the load module. In
some cases, an entry may look like this:
FBCC:EBE2HThis entry appears to be the address of a load
module that is almost one megabyte in size.
Actually, the area being referenced is relative to asegment base that is pointing to a segment below
the relative zero beginning of the load module.
This condition produces a pointer that has
effectively gone negative. The memory map which
follows illustrates this point.
When LINK has completed, the following message
is displayed:
Program entry point at 0003:0000

How to Determine the Absolute
Address of a Segment
The linker map displays a list of segments in therelative order of their appearance within the load
module. The information displayed shows a 20-bit
hex address of each segment relative to location
zero. The addresses that are displayed are not theabsolute addresses of where these segments are
actually located. To determine where relative zerois actually located, we must use DEBUG. DEBUG
is described in detail in Chapter 12.

11-28

Using DEBUG,
1.

Load the application. Note the segment value
in CS and the offset within that segment to
the entry point as shown in IP. The last line of
the linker map also describes this entry point,
but uses relative values, not the absolutevalues shown by CS and IP.

2.

Subtract the relative entry as shown at the endof the map listing from the CS:IP value. For
example, let's say CS is at 05DC and IP is atzero.
The linker map shows the entry point at
0100:0000. (0100 is a segment ID orparagraph number; 0000 is the offset into thatsegment.)
In this example, relative zero is located at
04DC:0000, which is 04DCO absolute.

If a program is loaded low, the relative zero
location is located at the end of the Program
Segment Prefix, in the location DS plus 100H.

11-29

Messages

All messages, except for the warning messages,
cause the LINK session to end. Therefore, after
you locate and correct a problem, you must rerun
LINK.
Messages appear both in the list file and on thedisplay unless you direct the list file to CON, inwhich case the display messages are suppressed.
All of the linker messages are included in
Chapter 8.

11-30

Name Command ........................ 12-42
Output Command ...................... 12-44
Quit Command ......................... 12-45
Register Command ..................... 12-46
Search Command ....................... 12-53
Trace Command ........................ 12-55
Un assemble Command ................. 12-57
Write Command ........................ 12-62
Summary of DEBUG Commands ........ 12-67

12-2

Introduction

This chapter explains how to use the DEBUG
program.
The DEBUG program can be used to:•Provide a controlled testing environment so
you can monitor and control the execution ofa program to be debugged. You can fix
problems in your program directly, and thenexecu te the program immediately todetermine if the problems have been resolved.
You do not need to reassemble a program tofind out if your changes worked.

•

Load, alter, or display any file.

•

Execute object files. Object files are executable
programs in machine language format.

12-3

How to Start the DEBUG Program

To start DEBUG, enter:
DEBUG (d](path)[filename(.ext)](parm 1](parm2]

If you enterfilename, the DEBUG program loads
the specified file into memory. You may now entercommands to alter, display, or execute thecontents of the specified file.
If you do not enter a filename, you must either
work with the present memory contents, or load
the required file into memory by using the Nameand Load commands. Then you can entercommands to alter, display, or execute thememory contents.
The optional parameters, parml and parm2 ,represent the optional parameters for the named
filespec. For example,
DEBUG DlSKCOMP.COM A: B:

In this command, the A: and B: are the parametersthat DEBUG prepares for the DISKCOMP
program.

12-4

When the DEBUG program starts, the registers
and flags are set to the following values for the
program being debugged:•

The segment registers (eS, DS, ES, and SS)
are set to the bottom of free memory; that is,
the first segment after the end of the DEBUG
program.

•

The Instruction Pointer (IP) is set tohex 0100.

•

The Stack Pointer (SP) is set to the end of thesegment, or the bottom of the transient
portion of the program loader, whichever islower. The segment size at offset 6 is reducedby hex 100 to allow for a stack of that size.

•

The remaining registers (AX, BX, ex, DX,
BP, SI, and DI) are set to zero. However, if
you start the DEBUG program with a filespec,
the ex register contains the length of the filein bytes. If the file is greater than 64K, thelength is contained in registers BX and ex(the high portion in BX).

•

The flags are set to their cleared values. (Referto the Register command.)•The default disk transfer address is set tohex 80 in the code segment.

12-5

All of available memory is allocated; therefore, any
attempt by the loaded program to allocate
memory will faiL
Notes:
1.

If a file loaded by DEBUG has anextension of. EXE, DEBUG does thenecessary relocation and sets the segment
registers, stack pointer, and Instruction
Pointer to the values defined in the file.
The DS and ES registers, however, point
to the Program Segment Prefix at thelowest available segment. The BX andCX registers contain the size of the
program (smaller than the file size).
The program is loaded at the high end ofmemory if the appropriate parameter was
specified when the linker created the file.
Refer to ". EXE File Structure andLoading" in Appendix H for more
information about loading .EXE files.

2.

12-6

If a file loaded by DEBUG has anextension of . HEX, the file is assumed tocontain ASCII representation ofhexadecimal characters, and is converted
to binary while being loaded.

The DEBUG Command
Parameters

Parameter

Definition

address

Enter a one- or two-part designation in oneof the following formats:alphabetic segment register• An
designation, plus an offset value, suchas:
CS:Ol00

segment address, plus an offset• Avalue,such as:481:0100• An offset value only, such as:
100(In this case, each command uses adefault segment.)

12-7

Parameter

Definition

address(cont)

Notes:
1.

In the first two formats, the colon isrequired to separate the values.

2.

All numeric values are hexadecimal andmay be entered as 1-4 characters.

3.

The memory locations specified inaddress must be valid; that is, theymust actually exist. Unpredictable
results will occur if an attempt is madeto access a nonexistent memory
location.

byteEnter a one or two character hexadecimalvalue.

driveEnter a single digit (for example, 0 for drive
A or 1 for drive B) to indicate which drive
data is to be loaded from or written to.
(Refer to the Load and Write commands.)

filespec

Enter a one- to three-part file specificationconsisting of a drive designation, filename,and filename extension. All three fields are
optional. However, for the Name command
to be meaningful, you should at leastspecify a drive designator or a filename.
(Refer to the Name command.)

12-8

Parameter

Defini tion

list

Enter one or more byte and! or stringvalues. For example,
E CS:100 F3 'IYZ' 804 "abed"

has five items in the list (that is, three byte
entries and two string entries having a totalof 10 bytes).

portaddressEnter a 1-4 character hexadecimal value tospecify an8- or 16- bit port address.
(Refer to the Input and Output commands.)

range

Enter either of the following formats tospecify the lower and upper addresses of arange:•

address address
For example:
CS:100 110

Note: Only an offset value isallowed in the second address. The
addresses must be separated by aspace or comma.

12-9Parameter

Definition

range(cont.)• address L value
where value is the number of bytes inhexadecimal to be processed by thecommand. For example:
CS:l00 L 11

Notes:

registername

12-10

1.

The limit for range is hex
10000. To specify that value
within four hexadecimal
characters, enter 0000 (or 0).

2.

The memory locations
specified in range must be
valid; that is, they must
actually exist. Unpredictable
resul ts will occur if an
attempt is made to access a
non-existent memory
location.

Refer to the Register command.

Parameter

Defini tion

sector sector

Enter 1- 3 character hexadecimal values tospecify:
1.

The starting relative sector number

2.

The number of sector numbers to beloaded or written

In DEBUG, relative sectors are obtained bycounting the sectors on the disk surface.
The sector at track 0, sector 1, head 0 (thefirst sector on the disk) is relative sector o.
The numbering continues for each sector
on that track and head, then continues withthe first sector on the next head of thesame track. When all sectors on all heads ofthe track have been counted, numberingcontinues with the first sector on head 0 of
the next track.
Note: This is a change from thesector mapping used by DOS
Version 1.10.
The maximum number of sectors that canbe loaded or written with a single commandis hex 80. A sector contains 512 bytes.
(Refer to the Load and Write commands.)

12-11

Parameter

Definition

stringEnter characters enclosed in quotation
marks. The quotation marks can be either
single (') or double (").
The ASCII values of the characters in thestring are used as a list of byte values.
Within a string, the opposite set of quotation
marks can be used freely as characters.
However, if the same set of quotation marks(as the delimiters) must be used within thestring, then the quotation marks must be
doubled. The doubling does not appear inmemory. For example:

12-12

1.

'This "literal" is correct'

2.

'This' 'literal' ' is correct'

3.

'This 'literal' is not correct'

4.

'This ''''literal'''' is not correct'

5.

"This 'literal' is correct"

6.

"This ""literal'''' is correct"

7.

"This "literal" is not correct"

8.

"This' 'literal' ' is not correct"

Parameter

Definition

string(cont.)In the second and sixth cases above, theword literal is enclosed in one set of
quotation marks in memory. In the fourthand eighth cases above, the word literal is
not correct unless you really want it
enclosed in two sets of quotation marks inmemory.

value

Enter a 1-4 character hexadecimal value tospecify:
numbers to be added and• The
subtracted (refer to the Hexarithmetic
command), or
number of instructions to be• The
executed by the Trace command, or
number of bytes a command• The
should operate on. (Refer to theDump, Fill, Move, Search, andU nassemble commands.)

12-13

The DEBUG Commands

This section presents a detailed description of how
to use the commands to the DEBUG program.
The commands appear in alphabetical order; eachwith its format and purpose. Examples areprovided where appropriate.

Information Common to
All DEBUG Commands
The following information applies to the DEBUG
commands:•

A command is a single letter, usually followed
by one or more parameters.

•

Commands and parameters can be entered inuppercase or lowercase, or a combination of
both.

•

Commands and parameters may be separated
by delimiters. Delimiters are only required,however, between two consecutive
hexadecimal values. Thus, these commands
are equivalent:
dcs:100 110
d cs:100 110
d,cs:100,110

•

12-14

Press Ctrl-Break to end commands.

•

Commands become effective only after youpress the Enter key.

•

For commands producing a large amount of
output, you can press Ctrl-NumLock tosuspend the display to read it before it scrolls
away. Press any other character to restart thedisplay.

•

You can use the control keys and the DOS
editing keys, described in Chapter 3, while
using the DEBUG program.

•If a syntax error is encountered, the line isdisplayed with the error pointed out asfollows:
d c5:100 CS:110

error

In this case, the Dump command is expecting
the second address to contain only ahexadecimal offset value. It finds the S, which
is not a valid hexadecimal character.
•

The prompt from the DEBUG program is ahyphen (-).

•

The DEBUG program resides on your DOS
Supplemental Program diskette.

12-15

Assemble
CommandPurpose:To assemble IBM Personal Computer Macro
Assembler language statements directly intomemory.

Format:A [address]

Remarks: All numeric input to the Assemble command isin hexadecimal. The assembly statements you
enter are assembled into memory at successive
locations, starting with the address specified inaddress. If no address is specified, the statements
are assembled into the area at CS:0100, if noprevious Assemble command was used, or into
the location following the last instruction
assembled by a previous Assemble command.
When all desired statements have been entered,press Enter when you are prompted for the next
statement, to return to the DEBUG prompt.
DEBUG responds to invalid statements bydisplaying:
1\ Errorand redisplaying the current assemble address.

12-16

Assemble
Command

DEBUG supports standard 8086/8088 assembly
language syntax (and the 8087 instruction set),with the following rules:•

All numeric values entered are hexadecimaland can be entered as 1-4 characters.

•

Prefix mnemonics must be entered in frontof the opcode to which they refer. They canalso be entered on a separate line.

•

The segment override mnemonics are CS:,
DS:, ES:, and SS:.

•

String manipulation mnemonics must
explicitly state the string size. For example,
MOVSW must be used to move word
strings and MOVSB must be used to movebyte strings.

•

The mnemonic for the far return is RETF.

12-17

Assemble
Command•

The assembler will automatically assemble
short, near, or far jumps and calls
depending on byte displacement to thedestination address. These can beoverridden with the NEAR OR FAR prefix.
For example:
0100:0500 JMP 502; a 2 byte short jump
0100:0502 JMP NEAR 505 ; a 3 byte near jump
0100:0505 JMP FAR 50A ; a 5 byte far jump

The NEAR prefix can be abbreviated toNE, but the FAR prefix cannot be
abbreviated.
•

DEBUG cannot tell whether some operands
refer to a word memory location or a byte
memory location. In this case, the data typemust be explicitly stated with the prefix"WORD PTR" or "BYTE PTR". DEBUG
will also accept the abbreviations "wo"and "BY". For example:
NEG BYTE PTR [128]
DEC WO (SI]12-18

Assemble
Command•

DEBUG also cannot tell whether anoperand refers to a memory location or toan immediate operand. DEBUG uses thecommon convention that operands
enclosed in square brackets refer tomemory. For example:
MOV AX,21
MOV AX,[21]••;Load AX with 21H;Load AX with thecontents of memory
location 21 H

Two popular pseudo-instructions have also
been included. The DB opcode willassemble byte values directly into memory.
The DW opcode will assemble word values
directly into memory. For example:
DB
DB
DB

1,2,3,4,"THIS IS AN EXAMPLE"'THIS IS A QUOTE: " ,"THIS IS A QUOTE: ' "OW1000,2000,3000", BACH"

All forms of the register indirect commands
are supported. For example:
ADD
POP
PUSH

B1,34[ BP+2].[ SI-1][BP+DI)
[SI]

12-19

Assemble
Command•

All opcode synonyms are supported. For
example:
LOOPZ
LOOPE

100
100

JA

200
200

JNBE

•

For 8087 opcodes the WAIT or FWAIT
prefix must be explicitly specified. For
example:FWAIT FAOO ST,ST(3) ;This line will assemble

a FWAIT prefix
FLO TBYTE PTR (BX]

Example: C>debug-1200
0884:0200 xor ax,ax
0884:0202 mov (bx),ax
0884:0204 ret
0884:0205

12-20;This line will notCompareCommandPurpose:Compares the contents of two blocks ofmemory.

Format:C range address

Remarks: The contents of the two blocks of memory arecompared; the length of the comparison isdetermined from the range. If unequal bytes arefound, their addresses and contents are
displayed, in the form:
addrl

by tel

byte2

addr2

where, the first half (addrl by tel) refers to thelocation and contents of the mismatching
locations in range, and the second half(byte2 addr2) refers to the byte found in address.
If you enter only an offset for the beginning
address of range, the C command assumes thesegment contained in the DS register. To specify
an ending address for range, enter it with only an
offset value.

Example: C 100L20 200
The 32 bytes of memory beginning at DS:lOO
are compared with the 32 bytes beginning at
DS:200.

12-21

Dump
CommandPurpose:

Displays the contents of a portion of memory.

Format:D [address]orD [range]

Remarks: The dump is displayed in two parts:
1.

A hexadecimal portion. Each byte isdisplayed in hexadecimal.

2.

An ASCII portion. The bytes are displayed
as ASCII characters. Unprintable characters
are indicated by a period (.).

With a 40-column system display format, eachline begins on an 8- byte boundary and shows 8
bytes.
With an 80-column system display format, eachline begins on a 16-byte boundary and shows 16
bytes. There is a hyphen between the 8 th and9th bytes.
Note: The first line may have fewer than 8
or 16 bytes if the starting address of the
dump is not on a boundary. In this case, thesecond line of the dump begins on aboundary.
12-22

Dump
Command

The Dump command has two format options:
Option 1
Use this option to display the contents of hex 40
bytes (40-column mode) or hex so bytes(SO-column mode). For example:
D addressorD

The contents are dumped starting with thespecified address.
If you do not specify an address, the Dcommand assumes the starting address is thelocation following the last location displayed bya previous D command. Thus, it is possible todump consecutive 40-byte or SO-byte areas byentering consecutive D commands withoutparameters.
If no previous D command was entered, thelocation is offset hex 0100 into the segment
originally initialized in the segment registers by
DEBUG.
Note: If you enter only an offset for thestarting address, the D command assumes
the segment contained in the DS register.

12-23

Dump
Command

Option 2
Use this option to display the contents of thespecified address range. For example:
D range. Note: If you enter only an offset for thestarting address, the D command assumes
the segment contained in the DS register. If
you specify an ending address, enter it with
only an offset value.
F or example:

o cs:l00 10C
A 40-column display format might look like this:
04BA:Ol00

42 45 52 54 41 20 54 00

BERTA T.
04BA:Ol08

12-24

20 42 4F 52 47
BORG

EnterCommandPurpose:The Enter command has two modes ofoperation:
Replaces the contents of one or more bytes,
starting at the specified address, with thevalues contained in the list. (See Option 1.)
Displays and allows modification of bytes ina sequential manner. (See Option 2.)

Format:E address [ltst]

Remarks: If you enter only an offset for the address, the Ecommand assumes the segment contained in the
DS register.
The Enter command has two format options:
Option 1
Use this option to place the list in memory
beginning at the specified address.
E address Itst

For example:
E ds: 100 F3 "xyz" 8 0

Memory locations ds:l00 through ds:l04 arefilled with the five bytes specified in the list.
12-25

EnterCommand

Option 2
Use this option to display the address and thebyte of a location, then the system waits foryour input.
F or example:
E address

Now you can take one of the following actions:1.

Enter a one or two character hexadecimalvalue to replace the contents of the byte;
then take any of the next three actions:

2.

Press the space bar to advance to the next
address. Its contents are displayed. If you
want to change the contents take action 1,
above.
To advance to the next byte withoutchanging the current byte, press the space
bar again.

3.

Enter a hyphen (-) to back up to thepreceding address. A new line is displayedwith the preceding address and its contents.
If you want to change the contents takeaction 1, above.
To back up one more byte withoutchanging the current byte, enter anotherhyphen.

12-26

EnterCommand4.

Press the Enter key to end the Entercommand.
Note: Display lines can have 4 or 8 bytes
of data, depending on whether the system
display format is 40- or 80-column. Spacing
beyond an 8-byte boundary causes a newdisplay line, with the beginning address, tobe started.
For example:
E cs:l00

might cause this display:
04BI:Ol00 EB._To change the contents of 04BA:0100 fromhex EB to hex 41, enter 41.
048A:Ol00 EB.41 _To see the contents of the next threelocations, press the space bar three times.
The screen might look like this:
04BA:Ol00

EB.41

10.

00.

BC._

To change the contents of the current
location (04BA:0103) from hex Be tohex 42, enter 42.
04BA:Ol00

EB.41

10.

00.

BC.42_

12-27

EnterCommandNow, suppose you want to back up andchange the hex 10 to hex 6F. This is what
the screen would look like after entering
two hyphens and the replacement byte:
04BA:Ol00
04BA:Ol02
04BA:Ol0l

EB.41 10.
00.10.6F_

00.

BC.42·

Press the Enter key to end the Entercommand. You will see the hyphen (-)
prompt.

12-28

Fill
CommandPurpose:Fills the memory locations in the range with thevalues in the list.

Format:F range list

Remarks: If the list contains fewer bytes than the address
range, the list is used repeatedly until all thedesignated memory locations are filled.
If the list contains more bytes than the address
range, the extra list items are ignored.
Note: If you enter only an offset for thestarting address of the range, the Fillcommand assumes the segment containedin the DS register.
Example: F 4BA:l00 L 5 F3 "XYI" 80
Memory locations 04BA:100 through 04BA:104
are filled with the 5 bytes specified. Rememberthat the ASCII values of the list characters are
stored. Thus, locations 100-104 will contain F3
5859 5A 8D.

12-29

Go
CommandPurpose:

Executes the program you are debugging.
Stops the execution when the instruction at a
specified address is reached (breakpoint), anddisplays the registers, flags, and the next
instruction to be executed.

Format:G [=address] [address [address ... ]]Remarks: Program execution begins with the current
instruction, whose address is determined by thecontents of the CS and IP registers, unlessoverridden by the =address parameter (the =must be entered). If =address is specified,program execution begins with CS:=address.
The Go command has two format options:
Option 1
Use this option to execute the program you aredebugging without breakpoints. For example:

G [=address]
This option is useful when testing program
execution with different parameters each time.
(Refer to the Name command.) Be certain the
CS:IP values are set properly before issuing the
G command, if not using =address.

12-30

Go
Command

Option 2

This option performs the same function as
Option 1 but, in addition, allows breakpoints tobe set at the specified addresses. For example:
G [=address] address[address ... ]This method causes execution to stop at a
specified location so the system/program
environment can be examined.
You can specify up to ten breakpoints in any
order. You may wish to take advantage of this if
your program has many paths, and you want tostop the execution no matter which path theprogram takes.
The DEBUG program replaces the instruction
codes at the breakpoint addresses with aninterrupt code (hex CC). If anyone breakpoint isreached during execution, the execution is
stopped, the registers and flags are displayed,
and all the breakpoint addresses are restored totheir original instruction codes. If no breakpointis reached, the instructions are not restored.

12-31

Go
CommandNotes:

12-32

1.

Once a program has reachedcompletion (DEBUG has displayed the"Program terminated normally"message), it will be necessary to reload
the program before it can be executed
again.

2.

Make sure that the address parametersrefer to locations that contain valid
8088 instruction codes. If you specify
an address that does not contain thefirst byte valid instruction,
unpredictable results will occur.

3.

The stack pointer must be valid andhave 6 bytes available for the Gocommand; otherwise, unpredictable
resul ts will occur.

4.

If only an offset is entered for abreakpoint, the G command assumes
the segment contained in the CS
register.

Go
Command

For example:
G 102 1EF 208

Execution begins with the current
instruction, whose address is the current
values of CS:IP. The =addres! parameter was
not used.
Three breakpoints are specified; assume
that the second is reached. Execution stops
before the instruction at location CS: 1 EF is
executed, the original instruction codes arerestored, all three breakpoints are removed,
the display occurs, and the Go command
ends.
Refer to the Register command for a
description of the display.

12-33

Hexari thmetic
CommandPurpose:Adds the two hexadecimal values, then subtracts
the second from the first.
Displays the sum and difference on one line.

Format:H value value

Example: H OF 81707

The hexadecimal sum of 000 F and 0008 is 001 7,
and their difference is 0007.

12-34InputCommandPurpose:

Inputs and displays (in hexadecimal) one byte
from the specified port.

Format:Iportaddress

Example: 12F868

The single hexadecimal byte read from port
02F8 is displayed (6B).

12-35

Load
CommandPurpose:Loads a file or absolute diskette sectors intomemory.

FormatL [address [ drive sector sector]]

Remarks: The maximum number of sectors that can beloaded with a single Load command is hex 80.
Note: DEBUG displays a message if a
diskette read error occurs. You can retry
the read operation by pressing F3 tore-display the Load command. Then, press
the Enter key.
The Load command has two format options:
Option 1
Use this option to load data from the diskettespecified by drive, and place the data in memory
beginning at the specified address. For example:
L address drive sector sector

12-36

Load
Command

The data is read from the specified starting
relative sector (first sector) and continues until
the requested number of sectors is read (second
sector).
Note: If you only enter an offset for the
beginning address, the L command assumes
the segment contained in the CS register.
For example, to load data, you might enter:
L 4BA:l00 1 OF 60

The data is loaded from the diskette in drive B
and placed in memory beginning at 4BA:I00.
Hex 6D (109) consecutive sectors of data aretransferred, starting with relative sector hex of(15) (the 16th sector on the diskette).

12-37

Load
Command

Option 2
When issued without parameters, or with only
the address parameter, use this option to load
the file whose filespec is properly formatted in
the file control block at CS:5C. For example:
Lor
L address

This condition is met by specifying the filespec
when starting the DEBUG program, or by using
the Name command.
Note: If DEBUG was started with afilespec and subsequent Name commands
were used, you may need to enter a new
Name command for the proper filespec
before issning the Load command.
The file is loaded into memory beginning at
CS: 1 00 (or the location specified by address), andis read from the drive specified in the filespec(or from the default drive, if none was specified).
Note that files with extensions of .COM or .EXE
are always loaded at CS: 1 00 -- if you specified anaddress, it will be ignored.

12-38

Load
Command

The BX and ex registers are set to the numberof bytes read; however, if the file being loaded
has an extension of . EXE, BX and ex are set tothe actual program size, and the file may beloaded at the high end of memory. Refer to thenotes in "How to Start the DEBUG Program" atthe beginning of this chapter for the conditions
that are in effect when .EXE or .HEX files areloaded.
For example:

DEBUG-N myprog-L
The file named myprog is loaded from thedefault diskette and placed in memory
beginning at location CS:0100.

12-39

Move
CommandPurpose:Moves the contents of the memory locations
specified by range to the locations beginning at
the address specified.

Format:M range address

Remarks: Overlapping moves are always performed
without loss of data during the transfer. (Thesource and destination areas share some of thesame memory locations.)
The data in the source area remains unchanged
unless overwritten by the move.
Notes:

12-40

1.

If you enter only an offset for the
beginning address of the range, the Mcommand assumes the segment
contained in the DS register. If you
specify an ending address for the range,
enter it with only an offset value.

2.

If you enter only an offset for theaddress of the destination area, the Mcommand assumes the segment
contained in the DS register.

MoveCommand

Example: M CS:l00 110 500
The 1 7 bytes of data from CS: 1 00 throughCS: 11 0 are moved to the area of memory
beginning at DS:500.

12-41

Name
CommandPurpose:The Name command has two functions:
Formats file control blocks for the first two
filespecs, at CS:5C and CS:6C. (Starting
DEBUG with a filespec also formats a filecontrol block at CS:5C.)
The file control blocks are set up for theuse of the Load and Write commands, andto supply required filenames for the
program being debugged.
All specified filespecs and other parameters
are placed exactly as entered, including
delimiters, in a parameter save area at
CS:81, with CS:80 containing the numberof characters entered. Register AX is set toindicate the validity of the drive specifiers
entered with the first two filespecs.

Format:Nfilespec [filespec. .. J

Remarks: If you start the DEBUG program without afilespec, you must use the Name command
before a file can be loaded with the L command.

12-42

Name
Command

Example: DEBUG·N myprog·L

To define filespecs or other parameters requiredby the program being debugged, enter:
DEBUG myprog. N filel file2

In this example, DEBUG loads the file myprog
at CS:I00, and leaves the file control block at
CS:5C formatted with the same filespec. Then,the Name command formats file control blocks
for/llel and/ile2 at CS:5C and CS:6C,
respectively. The file control block for myprog
is overwritten. The parameter area at CS:81
contains all characters entered after the N,
including all delimiters, and CS:80 contains thecount of those characters (hex OC).

12-43

Output
CommandPurpose:Sends the byte to the specified output port.

Format:0 portaddress byte

Example: To send the byte value 4F to output port 2F8,
enter:

o2F8 4F

12-44

Quit
CommandPurpose:Ends the DEBUG program.

Format:Q

Remarks: The file that you are working on in memory is
not saved by the Quit command. You must use
the Write command to save the file.
DEBUG returns to the command processor
which then issues the normal command prompt.
Example: -0
A>

12-45

RegisterCommandPurpose:The Register command has three functions:

It displays the hexadecimal contents of asingle register, with the option of changing
those contents.
It displays the hexadecimal contents of all
the registers, plus the alphabetic flagsettings, and the next instruction to be
executed.
It displays the eight 2-letter alphabetic flagsettings, with the option of changing any or
all of them.
Format:12-46

R [registername]RegisterCommandRemarks: When the DEBUG program starts, the registers
and flags are set to certain values for the
program being debugged. (Refer to "How toStart the DEBUG Program" at the beginning of
this chapter.)
Display a Single Register
The valid registernames are:
AX
BX
CX
DX
SP

BP
SI
DI
DS
ES

SSCS
IP
PC
F

Both IP and PC refer to the instruction pointer.
For example, to display the contents of a single
register, you might enter:
R AX

The system might respond with:AX Fl E4

12-47

RegisterCommandNow you may take one of two actions:
Press Enter to leave the contents
unchanged.
orChange the contents of the AX register byentering a 1-4 character hexadecimal value,such as hex FFF.
AX F1E4:FFF_

Now pressing Enter changes the contents of the
AX register to hex OFFF.
Display All Registers and Flags
To display the contents of all registers and flags(and the next instruction to be executed), enter:R

The system might respond with:
AX=GBm iii=GGFF Ci=OOiii DX=iii FF
SP=0390 BP=OOOO SI=005C 01=0000
0S=04 BA ES=04 BA SS=04 BA CS=04 BA
1P=011 A NV UP DI NG NZ AC PE NC
04BA:011 A CD21
INT
21

12-48

RegisterCommand

The first four lines display the hexadecimal
contents of the registers and the eightalphabetic flag settings. The last line indicatesthe location of the next instruction to be
executed, and its hexadecimal and unassembled
formats. This is the instruction pointed to by
CS:IP.
Note: A system with an 80-column display
shows:
1 st line - 8 registers
2nd line - 5 registers and 8 flag settings
3rd line - next instruction information

A system with a 40-column display shows:
1 st line - 4 registers

2nd line - 4 registers
3rd line - 4 registers
4th line - 1 register and 8 flag settings
5 th line - next instruction information

12-49

RegisterCommand

Display All Flags
There are eight flags, each with 2-letter codes toindicate either a set condition or a clear
condition.
The flags appear in displays in the same order as
presented in the following table:
Set.

Clear

Overflow (yes/no)

OV

NV

Direction (decrement! incremen t)

DN

UPInterrupt ( enable/disable)

EI

DI

Sign (negative/positive)NG

PL

Zero (yes/no)

ZR

NZ

Auxiliary carry (yes/no)

AC

NA

Pari ty ( even! odd)

PE

PO

Carry (yes! no)CY

NCFlag Name

Figure 7. Alphabetic Flag Settings

12-50

RegisterCommand

To display all flags, enter:RF

If all the flags are in a set condition, the responseis:
OV ON EI NG ZR AC PE CY-_

Now you can take one of two actions:
1.

Press Enter to leave the settings unchanged.

2.

Change any or all of the settings.

To change a flag, just enter its opposite code.
The opposite codes can be entered in any
order - with or without intervening spaces. For
example, to change the first, third, fifth, andseventh flags, enter:
OV ON EI NG ZR AC PE CY - PONZDlNV

They are entered in reverse order in thisexample.
Press Enter and the flags are modified as
specified, the prompt appears, and you can enter
the next command.

12-51

RegisterCommandIf you want to see if the new codes are in effect,
enter:RFThe response will be:

NVDNDINGNZACPOCY-_
The first, third, fifth, and seventh flags arechanged as requested. The second, fourth, sixth,
and eighth flags are unchanged.
Note: A single flag can be changed only
once per R F command.

12-52

SearchCommandPurpose:Searches the range for the character( s) in the list.

Format:S range list

Remarks: All matches are indicated by displaying theaddresses where matches are found.
A display of the prompt (-) without an addressmeans that no match was found.
Note: If you enter only an offset for thestarting address of the range, the Scommand assumes the segment containedin the DS register.

12-53

SearchCommand

Example: If you want to search the range of addresses
from CS: 100 through CS: 110 for hex 41, enter:
S CS:100 11041

If two matches are found the response might be:
041A:0104
041A:0100

If you want to search the same range ofaddresses as in the previous example for a matchwith the 4-byte-Iong list, enter:
S CS: 100 L 11 41 "AI" E

The starting addresses of all matches are listed.
If no match is found, no address is displayed.

12-54

TraceCommandPurpose:

Executes one or more instructions starting with
the instruction at CS:IP, or at =address if it isspecified. The = must be entered. One
instruction is assumed, but you can specify morethan one with value. Displays the contents of all
registers and flags after each instruction executes.
For a description of the display format, refer tothe Register command.

Format:T [=address][value]

Remarks: The display caused by the Trace commandcontinues until value instructions are executed.
Therefore, when tracing multiple instructions,remember you can suspend the scrolling at any
time by pressing Ctrl-NumLock. Resume
scrolling by entering any other character.

12-55

TraceCommand

Example: T
If the IP register contains OllA, and thatlocation contains B40E (MOV AH,OEH), thismight be displayed:
Ax=omo BX=OOFF CX=0007 OX=Ol FF
SP==0390 BP==OOOO SI=005C 01=0000
0S=04BA ES=04BA SS=04BA C~04BA
1P=011 C NV UP DI NG NZ AC PE NC
04BA:011 C CD21
INT 21This displays the results after the instruction at
OllA is executed, and indicates the next
instruction to be executed is the INT 21 atlocation 04BA:Oll C.
T10

Sixteen instructions are executed (starting at
CS:IP). The contents of all registers and flags are
displayed after each instruction. The display
stops after the 16 th instruction has been
executed. Displays may scroll off the screen
unless you suspend the display by pressing theCtrl-NumLock keys.

12-56

Unassemble
CommandPurpose:Unassembles instructions (translates thecontents of memory into assembler-likestatenlents) and displays their addresses andhexadecimal values, together withassembler-like statements. For example, adisplay might look like this:
04BA:Ol00 206472 AND [SI+72],AH
04 BA:O 103 FC
CLD
04BA:Ol04 7665
JBE 016B

Format:U [address]orU [range]

12-57

Unassemble
CommandRemarks: The number of bytes unassembled depends on
your system display format (whether 40 or 80
columns), and which option you use with the
Unassemble command.
Notes:

12-58

1.

In all cases, the number of bytes
unassembled and displayed may beslightly more than either the amountrequested or the default amount. This
happens because the instructions are ofvariable lengths; therefore, tounassemble the last instruction may
include more bytes than expected.

2.

Make sure that the address parametersrefer to locations containing valid 8088
instruction codes. If you specify anaddress that does not contain the first
byte of a valid instruction, the display
will be erroneous.

3.

If you enter only an offset for thestarting address, the U commandassumes the segment contained in the
CS register.

Unassemble
Command

The Unassemble command has two format
options:
Option 1
Use this option to either unassemble
instructions without specifying an address, or tounassemble instructions beginning with a
specified address. For example:
Uor
U address

Sixteen bytes are unassembled with a 40-column
display. "Thirty-two" or" display; 32" bytes areunassembled with an 80-column display.
Instructions are unassembled beginning with thespecified address.
If you do not specify an address, the Ucommand assumes the starting address is thelocation following the last instructionunassembled by a previous U command. Thus, it
is possible to unassemble consecutive locations,producing continuous unassembled displays, byentering consecutive U commands withoutparameters.

12-59

Unassemble
CommandIf no previous U command is entered, thelocation is offset hex 0100 into the segment
originally initialized in the segment registers by

DEBUG.
Option 2
Use this option to unassemble instructions in a
specified address range. For example:
U range

All instructions in the specified address range
are unassembled, regardless of the system
display format.
Note: If you specify an ending address,
enter it with only an offset value.
For example:
U 04ba:Ol00 108

12-60

Unassemble
Command

The display response might be:
048A:Ol00
048A:Ol03
0481:0104
048A:Ol06

206472
FC
7665
207370AND [SI+72],AH
CLD
J8E 0168
AND [8P+OI+70],DHThe same display appears if you enter:U 048A:l00 L 7

or
U 048A:100 L 8or
U 048A:l00 L 9

12-61

WriteCommandPurpose:W rites the data being debugged to diskette.

Format:W [address [drive sector sector]]

Remarks: The maximum number of sectors that can be
written with a single Write command is hex 80.
DEBUG displays a message if a diskette write
error occurs. You can retry the write operationby pressing F3 to redisplay the Write command,then press the Enter key.
The Write command has two format options:
Option 1
Use this option to write data to diskette
beginning at a specified address. For example:
W address drive sector sector

12-62

WriteCommand

The data beginning at the specified address iswritten to the diskette in the indicated drive.
The data is written starting at the specified
starting relative sector (first sector) andcontinues until the requested number of sectors
are filled (second sector).
Notes:
1.

Be extremely careful when you write
data to absolute sectors because anerroneous sector specification will
destroy whatever was o~ the diskette atthat location.

2.

If only an offset is entered for the
beginning address, the W commandassumes the segment contained in the
CS register.

3.

Remember, the starting sector and thesector count are both specified inhexadecimal.

For example:
W 1FD 1100 A

The data beginning at CS:01FD is written to thediskette in drive B, starting at relative sectorhex 100 (256) and continuing for hex OA (10)sectors.

12-63

WriteCommand

Option 2
This option allows you to use the Writecommand without specifying parameters or only
specifying the address parameter. For example:
Wor

Waddress
When issued without parameters (or whenissued with only the address parameter), theWrite command writes the file (whose filespec is
properly formatted in the file control block at
CS:5C) to diskette.
This condition is met by specifying the filespec
when starting the DEBUG program, or by using
the Name command.
Note: If DEBUG was started with afilespec and subsequent Name commands
were used, you may need to enter a new
Name command for the proper filespec
before issuing the Write command.

12-64

WriteCommand

In addition, the BX and CX registers must be set
to the number of bytes to be written. They may
have been set properly by the DEBUG or Loadcommands, but might have been changed by a
Go or Trace command. You must be certain the
BX and CX registers contain the correct values.
The file beginning at CS: 1 00, or at the location
specified by address, is written to the diskette in
the drive specified in filespec or the default
drive if none was specified.
The debugged file is written over the original
file that was loaded into memory, or into a new
file if the filename in the FCB didn't previously
exist.
Note: An error message is issued if you try
to write a file with an extension of .EXE or.HEX. These files must be written in a
specific format that DEBUG cannot
support.

12-65

WriteCommandIf you find it necessary to modify a file withan extension of .EXE or .HEX, and theexact locations to be modified are known,
use the following procedure:

12-66

1.

RENAME the file to an extension
other than .EXE or .HEX.

2.

Load the file into memory using the
DEBUG or Load command.

3.

Modify the file as needed in memory,
but do not try to execute it with the
Go or Trace commands. Unpredictable
resul ts would occur.

4.

Write the file back using the Writecommand.

5.

RENAME the file back to its correct
name.

Summary of DEBUG Commands

The following chart is provided for quickreference.
The section called "Format Notation" in Chapter
6 explains the notation used in the format of thefollowing commands.
CommandPurposeFormatAssemble

Assembles statements

A [address]

CompareCompares memory

C range address

Dump

Displays memory

D [address]orD [range]

Enter

Changes memory

E address [ltst]

Fill

Changes memory blocks

F range ltst

Go

Executes with optional
breakpoints

G [=address][address[address ... ]]Hexari thmetic Hexadecimal add-subtract H value value
Figure 8 (Part 1 of2). DEBUG Commands

12-67

FormatCommandPurpose

Input

Reads/ displays input byte I portaddress

Load

Loads file or absolutediskette sectors

L [address [ drive
sector sector]]

Move

Moves memory block

M range address

Name

Defines files andparameters

Nfilespec[filespec... ]OutputSends output byteo portaddress
byte

Quit

Ends DEBUG program

Q

Register

Displays registers/flags

R [registername]

SearchSearches for characters

S range list

Trace

Executes and displaysT[=address] [value]

Unassemble

Unassembles instructions U [address]orU [range]Write

W rites file or absolutediskette sectors

Figure 8 (Part 2 of2). DEBUG Commands

12-68

W [address [ drive
sector sector]]

Notes:13-2

Introduction

With DOS Version 2.00 you can issue special
character sequences from within your programthat can be used to control screen cursor
positioning. You can also reassign the meaning of
any key in the keyboard.
Notes:
1.

The control sequences defined below are
valid only when issued through DOS
function calls 1, 2, 6, and 9, and require
the presence of the extended screen andkeyboard control device driver. This canbe accomplished by placing thecommand:
DEVICE=ANSI.SYS

in your CONFIG.SYS (configuration)
file. Note that the size of DOS inmemory will be increased by the size of
the ANSI.SYS program.
2.

The default value is used when no
explicit value, or a value of zero, is
specified.

3.

# - Numeric Parameter. A decimal
number specified with ASCII characters.

4.

In the control sequences described
below, ESC is the 1 byte code for ESC(hex 1B), not the three characters "ESC."For example, ESC [2;10H could becreated under DEBUG as follows:e200 18 "[2;10H"

13-3

Cursor Control

Cursor Position
CUP

Function

ESC [#;#H

Moves the cursor to the position specified
by the parameters. The first parameter
specifies the line number and the second
parameter specifies the column number.
The default value is one. If no parameter isgiven, the cursor is moved to the home
position.

Cursor Up
CUU

Function

ESC [#A

Moves the cursor up one line withoutchanging columns. The value of I}
determines the number of lines moved. The
default value for I} is one. This sequence isignored if the cursor is already on the top
line.

13-4

Cursor Down
CUD

Function

ESC [#8

Moves the cursor down one line withoutchanging columns. The value of II
determines the number of lines moved. The
default value for II is one. The sequence isignored if the cursor is already on thebottom line.

Cursor Forward
CUF

Function

ESC [#C

Moves the cursor forward one column
without changing lines. The value of II
determines the number of columns moved.
The default value for II is one. Thissequence is ignored if the cursor is alreadyin the rightmost column.

Cursor Backward
CUB

Function

ESC [#0

Moves the cursor back one column withoutchanging lines. The value of II determines
the number of columns moved. The default
value for II is one. This sequence isignored if the cursor is already in theleftmost column.

13-5

Horizontal and Vertical Position
HVP

Function

ESC [#;#f

Moves the cursor to the position specified
by the parameters. The first parameter
specifies the line number and the second
parameter specifies the column number.
The default value is one. If no parameter isgiven, the cursor is moved to the home
position (same as CUP).

Device Status Report
DSR

Function

ESC [6n

The console driver will output a CPR
sequence on receipt ofDSR (see below).

Cursor Position Report
CPR

Function

ESC [#;#R

The CPR sequence reports the current
cursor position through the standard input
device. The first parameter specifies thecurrent line and the second parameter
specifies the current column.

13-6Save Cursor Position
SCP

Function

ESC[sThe current cursor position is saved. This
cursor position can be restored with the
RCP sequence.

Restore Cursor Position
RCP

Function

ESC [uRestores the cursor to the value it had when
the console driver received the SCP
sequence.

13-7

Erasing

Erase in Display
ED

Function

ESC[2J

Erases all of the screen and the cursor goesto the home position.

Erase in LineEL

FunctionESC[kErases from the cursor to the end of theline and includes the cursor position.

13-8Mode Of Operation

Set Graphics Rendition
SGR

Function

ESC

Sets the character attribute specified by theparameter( s). All following characters will
have the attribute according to theparameter( s) until the next occurrence of
SGR.

[#; ... ;#m

Parameter Meaning0
All attributes Off(normal white on black)1
Bold On (high intensity)
4
Underscore On(IBM Monochrome Display only)
Blink On
5
Reverse video On
7
Cancelled On (invisible)
8Black foreground30
Red foreground
31
Green foreground32
Yellow foreground33
Blue foreground34
Magentaforeground
35
Cyan foreground36
White foreground37
40
Black background41
Red background42
Green background
Yellow background43
44
Blue background
Magenta background45
46
Cyan background
White background47
13-9

Set Mode
FunctionSM
ESC (=#hor ESC (=hor ESC (=Ohor ESC (?7h

Invokes the screen width or type specified
by the parameter.
Parameter Meaning
40x25 black and white040x25 color1
80x25 black and white2
80x25 color3
4320x200 color
320x200 black and white- 5
640x200 black and white6
wrap at end of line7
(typing past end-of-line
results in new line)

Reset ModeRM
ESC (=#1

or ESC(=Ior ESC (=01or ESC (?71

Function
Parameters are the same as SM (Set Mode)
except that parameter 7 will reset wrap at
end-of-line mode (characters past end-of-line
are thrown away).
Note:

13-10

The character I is a lowercase L.

Keyboard Key Reassignment
The control
sequence isFunction

The first ASCII code in the control
ESC [#;#; ... #psequence defines which code is being
or ESC [" string"; por ESC [#;"string";#; mapped. The remaining numbers
define the sequence of ASCII codes#;"string";#p
generated when this key isor any othercombination of intercepted. However, if the firststrings andcode in the sequence is zero (NUL)then the first and second code makedecimalup
an extended ASCII re-definition
numbers(see the Technical Reference manual
for a list of all the ASCII and
extended ASCII codes).

Here are some examples:1.

Reassign the Q and q key to the A and a key(and the other way as well):
ESC [65;81 P A becomes Q
ESC [97; 113p a becomes q
ESC (81 ;65p Q becomes A
ESC [113;97p q becomes a2.

Reassign the FlO key to a DIR command
followed by a carriage return:
ESC [O;68;"dir";13p

The 0;68 is the extended ASCII code for the
FlO key. 13 decimal is a carriage return.

13-11

Notes:13-12

MEDIA Descriptor Byte .............
INPUT or OUTPUT ............
Non Destructive Input
No Wait ......................
STATUS .......................
FLUSH ........................

14-21
14-23
14-25
14-25
14-26

The CLOCK$ Device .................... 14-26
Sample Device Driver ................... 14-27

14-2

Introduction

The DOS Version 2.00 device interface links thedevices together in a chain. This allows new device
drivers for optional devices to be added to DOS.

Device Driver Format

A device driver is a .COM file with all of the code
in it to implement the device. In addition it has a
special header at the front of it that identifies it asa device, defines the strategy and interrupt entry
points, and defines various attributes of the device.
Note: For device drivers, the. COM file must
not use the ORG 100H. Because it does not
use the program segment prefix, the device
driver is simply loaded; therefore, the. COM
file must have an orgin of zero (ORG 0 or no
ORG statement).

Types of Devices
There are two basic types of devices:•

Character devices•

Block devices
14-3

Character Devices
These are devices that are designed to do character
1/0 in a serial manner like CON, AUX, and PRN.
These devices have names like CON, AUX,
CLOCK$, and you can open channels (handles or
FCBs) to do input and output to them.
Note: Because character devices have only
one name, they can support only one device.

Block Devices
These devices are the "fixed disk or diskette
drives" on the system, they can do random 1/0 inpieces called blocks (usually the physical sector
size of the disk). These devices are not named as
the character devices are, and cannot be opened
directly. Instead they are mapped via the drive
letters (A, B, C, etc.). Block devices can have units
within them. In this way, a single block driver canbe responsible for one or more disk or diskette
drives. For example, block device driver ALPHA
can be responsible for drives A, B, C and D. Thismeans that ALPHA has four units defined andtherefore takes up four drive letters. The way thedrive units and drive letters correspond isdetermined by the position of the driver in the
chain of all drivers. For example, if device driver
ALPHA is the first block driver in the device chain,
and it has defined four units, then those units will
be A, B, C and D. If BETA is the second block
driver, and it defines three units, then those units
will be E, F and G. DOS Version 2.00 is not
limited to 16 block device units as previous
versions were. The new limit is 63, but drives are
assigned alphabetically through the collating
sequence, so after drive Z, the drive" characters"
get a little strange (like <,\ , ».

14-4

Device Header
A device header is required at the beginning of adevice driver. Here is what the Device Header
looks like:
Description

Definition

Pointer to next device header

DWORD

Attribute

WORD

Pointer to device strategy

WORD

Pointer to device interrupt

WORD

Name/unit field

8 BYTES

Next Device Header Field
The pointer to the next device header field is adouble word field (offset followed by segment)that is set by DOS at the time the device driver isloaded. However, it is important that this field be
set to -1 prior to load time (when it is on the disk
as a .COM file) unless there is more than one
device driver in the .COM file. If there is morethan one driver in the file, the first word of the
double word pointer should be the offset of thenext driver's Device Header.
Note: If there is more than one device driverin the. COM file, the last driver in the file
must have the pointer to next Device Header
field set to -1.

14-5

Attribute Field
The next field in the header describes to thesystem the attributes of the device. They are as
follows:
bit 15 = 1 if character deviceo if block device
bit 14 = 1 if IOCTL is supported
o if it is not
bit 13 = 1 if non IBM format (block only)
o if IBM format
bit 3 = 1 if current clock deviceo if it is not
bit 2 = 1 if current NUL deviceo if it is not
bit 1 = 1 if current standard output deviceo if it is not
bit 0 = 1 if current standard input deviceo if it is not

All other bits must be off.
The most important bit is bit 15, which tells thesystem that it is a block or a character device. With
the exception of bits 13 and 14, the rest are forgiving character devices special treatment andmean nothing on a block device. These special
treatment bits allow you to tell DOS that yournew device driver is the new standard input device
and standard output device (the CON device). Thiscan be done by setting bits 0 and 1 to 1. Similarly,
a new CLOCK$ device could be installed by
setting that attribute bit.

14-6

Although there is a NUL device attribute bit, theNUL device cannot be reassigned. This is an attributethat exists for DOS so it can tell if the NUL device
is being used. The non IBM format bit applies only
to block devices and affects the operation of theGet BPB (BIOS Parameter Block) device call(covered later in this chapter). The other bit ofinterest is the IOCTL bit. This is used for both
block and character devices, and tells DOS
whether the device is able to handle control strings(through the IOCTL system call).
If a driver cannot process control strings, it should
initially set this bit to o. This way DOS can return
an error if an attempt is made through the IOCTL
system call to send or receive control strings to thedevice. A device that is able to process suchcontrol strings should initialize this bit to 1. For
devices of this type, DOS will make the calls to the
IOCTL input and the IOCTL output device
functions to send and receive IOCTL strings.
The IOCTL functions allow data to be sent to andfrom the device without actually doing a normal
read or write. In this way, the device can use thedata for its own use (like setting a baud rate, stop
bits, changing form lengths, etc.). It is up to thedevice to interpret the information passed to it,
but it must not be treated as a normal VO request.

Strategy and Interrupt Routines
These two fields are the pointers to the entry
points of the strategy and interrupt routines. They
are word values, so they must be in the same
segment as the Device Header.

14-7

Name Field
This is an 8-byte field that contains the name of acharacter device, or the number of units of a blockdevice. If it is a block device, the number of units
can be put in the first byte. This is optional,
because DOS will fill in this location with the value
returned by the driver's INIT code. (Refer.to"Installation of Device Drivers" in this chapter.)

Creating a Device Driver

In order to create a device driver that DOS caninstall, a . COM file must be created with theDevice Header at the start of the file. Rememberthat for device drivers, the code should not be
originated at IOOH, but rather at o. The link field(pointer to next Device Header) should be -1
unless there is more than one device driver in the.COM file. The attribute field and entry points
must be set correctly.
If it is a character device, the name field should be
filled in with the name of that character device.
The name can be any legal 8-character filename.

14-8

DOS always processes installable device drivers
before handling the default devices, so to install a
new CON device, simply name the device CON(just be sure to set the standard input device andstandard output device bits in the attribute word
on a new CON device). The scan of the device list
stops on the first match, so the installable device
dri ver takes precedence.
Note: Because DOS can install the driver
anywhere in memory, care must be taken in
any far memory references. You should not
expect that your driver will always be loadedat the same place every time.

Installation of Device Drivers

DOS Version 2.00 allows new device drivers to beinstalled dynamically at boot time by reading andprocessing the device options in the CONFIG. SYS
file.
DOS calls a device driver at it's strategy entry
point first, passing in a Request Header the
information describing what DOS wants the device
driver to do.

14-9

The strategy routine does not perform the request,
but rather it enqueues the request (saves a pointerto the Request Header). The second entry point is
the interrupt routine, and is called by DOS
immediately after the strategy routine returns. The"interrupt" routine is called with no parameters.
Its function is to perform the operation based on
the queued request and set up any return
information.
DOS passes the pointer to the Request Header in
ES: BX. This structure consists of a fixed length
header (Request Header) followed by data
pertinent to the operation to be performed.
Note: It is the responsibility of the device
driver to preserve the machine state (forexample, save all registers on entry, andrestore them on exit).
The stack used by DOS will have enoughroom on it to save all of the registers. If more
stack space is needed, it is the device drivers
responsibility to allocate and maintainanother stack.
All calls to device drivers are FAR calls, and
FAR returns should be executed to return toDOS. (See "Sample Device Driver" listing at
the end of this chapter.)

14-10

Request Header

BYTE length in bytes of theRequest Header plus any data at
the end of the Request Header
BYTE unit code
The subunit the operation
is for (minor device).
Has no meaning for character
devices.
BYTE command code
WORD Status
8 BYTE area

reserved for DOS
Data appropriate to theoperation

Unit CodeThe unit code field identifies which unit in yourdevice driver the request is for. For example, if
your device driver has 3 units defined, then thepossible values of the unit code field would be 0, 1,
and 2.

14-11

Command CodeThe command code field in the Request Header
can have the following values:

14-12

Code

Function

o

INIT

1

MEDIA Check (Block only, NOP for
character)

2

BUILD BPB (Block only, NOP for
character)

3

IOCTL input (only called if IOCTL bit is 1)

4

INPUT (read)

5

NON-DESTRUCTIVE INPUT NO WAIT
(Character devices only)

6

INPUT STATUS (Character devices only)

7

INPUT FLUSH (Character devices only)

8

OUTPUT (write)

9

OUTPUT (write) with verify

10

OUTPUT STATUS (Character devices only)

11

OUTPUT FLUSH (Character devices only)

12

IOCTL output (only called if IOCTL bit is 1)

BUILD BPB and MEDIA CHECKBUILD BPB and MEDIA CHECK, for blockdevices only, are explained here.
DOS calls MEDIA CHECK first for a drive unit.
DOS passes it's current Media Descriptor byte (see"Media Descriptor Byte" later in this chapter).
MEDIA CHECK returns one of the following four
results:•

Media Not Changed•

Media Changed•

Not Sure

DOS will call BUILD BPB under the following two
conditions:•

If "Media Changed" is returned•

If "N ot Sure" is returned and there are no
dirty buffers (buffers with changed data, notyet written to disk).

Status Word
The status word in the Request Header.

. . 10 9 8 7 .6 5 4 .3 .2 .1 .0

15 14 13 12 11
I

E
R
R

RESERVED

B
U

0

S

N

0

ERROR CODE (bit 15 on)

The status word is zero on entry and is set by thedriver interrupt routine on return.

14-13

Bit 8 is the done bit. When set it means theoperation is complete. For DOS 2.00 the Driver
just sets it to one when it exits.
Bit 15 is the error bit. If it is set, then the low 8
bits of the status word indicate the error. The
errors are:
00 Write Protect Violation
01 Unknown Unit
02 Device Not Ready

03 Unknown command
04 CRC Error
05 Bad Drive Request Structure Length
06 Seek Error
07 Unknown Media
08 Sector Not Found
09 Printer Out of Paper
OA Write Fault
OB Read Fault
OC General Failure
Bit 9 is the busy bit that is set by status calls.
For output on character devices: If it is 1 onreturn, a write request (if made) would wait forcompletion of a current request. If it is 0, there isno current request, and a write request (if made)would start immediately.
For input on character devices with a buffer: If
it is 1 on return, a read request (if made) would go
to the physical device. If it is 0 on return, thenthere are characters in the device buffer and a read
would return quickly, it also indicates that the user
has typed something. DOS assumes all character
devices have an input type ahead buffer. Devices
that do not have them should always returnbusy = 0 so that DOS will not continuously wait
for something to get into a buffer that does notexist.

14-14

One of the functions defined for each device isINIT. This routine is called only once when thedevice is installed and never again. There areseveral things returned by the INIT routine. First,
there is a location of the first free byte of memory
after the device driver (like a terminate and stayresident) that is stored in the ending address field.
In this manner, initialization code can be used
once and thrown away in order to save space.
After sending the ending address field, a character
device driver can set the status word and return.
While block devices are installed in the same way
as character devices, they must return additional
information. The number of units for the device
driver is returned, and this determines the logicalnames that the devices will have. For example, if
the current maximum logical device letter is F at
the time of the install call, and the block device
driver INIT routine returns 3 units, then theirlogical names will be G, H, and 1. This mapping isdetermined by the position of the driver in thedevice list, and the number of units on the device.
The number of units returned by IN IT will
override the value in the name/unit field of theDevice Header.
In addition, a pointer to a BPB (BIOS Parameter
Block) pointer array is also returned. This is apointer to an array of n word pointers, where n is
the number of units defined. These word pointers
point to BPBs. In this way, if all of the units are
the same, the entire array can point to the same
BPB in order to save space.
Note: This array must be protected (below
the free pointer set by the return).

14-15

The BPB (BIOS Parameter Block) contains
information pertinent to the devices like sector
size, sectors per allocation unit, etc. The sector
size in the BPB cannot be greater than the
maximum allowed (set at DOS initialization time).
The last thing that INIT of a block device must
pass back is the "media descriptor byte". This bytemeans nothing to DOS, but is passed to devices sothat they know what parameters DOS is currently
using for a particular Drive-Unit.
Block devices may take several approaches; they
may be dumb or smart. A dumb device would define
a unit (and therefore a BPB) for each possible
media drive combination. Unit 0 = drive 0 single
side, unit 1 = drive 0 double side, etc. For thisapproach, media descriptor bytes would mean
nothing. A smart device would allow multiple
media per unit. In this case, the BPB table
returned at INIT must define space large enoughto accommodate the largest possible media
supported (sector size in BPB must be as large as
maximum sector size that DOS is currently using).
Smart drivers will use the "media byte" to pass
information about what media is currently in aunit.

Function Call Parameters
All strategy routines are called with ES:BX
pointing to the Request Header. The interrupt
routines get the pointers to the Request Header
from the queue the strategy routines store themin. The command code in the Request Header tells
the driver which function to perform.
Note: All DWORD pointers are stored
offset first, then segment.

14-16

INIT
Command code=O

ES:BX
13-BYTE Request Header
BYTE number of units (not set by character
devices)
DWORD Ending Address
DWORD Pointer to BPB array(not set by character devices)
The driver must do the following:•

Set the number of units (block devices only).

•

Set up the pointer to the BPB array (blockdevices only).

•

Perform any initialization code (to modems,
printers, etc.).

•

Set up the ending address for resident code.

•

Set the status word in the Request Header.
Note: If there are multiple device drivers ina single .COM file, the ending address
returned by the last INIT called will be theone DOS uses. For the sake of simplicity, it isrecommended that all of the device drivers ina single .COM file return the same ending
address.

14-17

MEDIA CHECK
Command code=l

ES:BX
13-BYTE Request Header
BYTE Media Descriptor from DOS
BYTE return information
The driver must perform the following:•

Set the return byte:-1 Media has been changedo Don't know if media has been changed
1 Media has not been changed•

Set the status word in the Request Header.

BUILD BPB (BIOS Parameter Block)Command code=2

ES:BX

13-BYTE Request Header
BYTE Media Descriptor from DOS
DWORD Transfer Address (buffer address)
DWORD Pointer to BPB table

14-18

The driver must perform the following:•

Set the pointer to the BPB.

•

Set the status word in the Request Header.

The driver must determine the correct media thatis currently in the unit to return the pointer to the
BPB table. The way the buffer is used (pointerpassed by DOS) is determined by the non-IBM
format bit in the attribute field of the device
header. If the bit is zero (device is IBM format
compatible) then the buffer contains the first
sector of the FAT (most importantly the FAT idbyte). The driver must not alter this buffer in thiscase. If the bit is a one, then the buffer is a one
sector scratch area that can be used for anything.
If the device is IBM format compatible, then it
must be true that the first sector of the first FAT is
located at the same sector for all possible media.
This is because the FAT sector is read before themedia is actually determined.

14-19

The information relating to the BPB for aparticular media is kept in the boot sector for the
media. In particular, the format of the boot sector. is:

3 BYTE near JUMP to boot code
8 BYTE OEM name and version

WORD bytes per sector/\

BYTE sectors per allocation unit
(must be a power of 2)
WORD reserved sectors(starting at logical sector 0)
BYTE number of FATs
WORD number of root dir entries(maximum allowed)

B
P
B

WORD number of sectors in logical image(total sectors in media, including
boot sector, directories, etc.)
BYTE media descriptor
WORD number of sectors occupied
by a single FATWORD sectors per track
WORD number of heads
WORD number of hidden sectors

14-20

\V

The three words at the end are optional. DOS does
not care about them because they are not part ofthe BPB. They are intended to help the device
driver understand the media. Sectors per track may
be redundant because it can be calculated from thetotal size of the disk. The number of heads isuseful for supporting different multi-head drives
that have the same storage capacity but adifferent number of surfaces. The number ofhidden sectors is useful for supporting drive
partitioning schemes.

MEDIA Descriptor Byte
Currently the media descriptor byte has been
defined for a few media types:
Media descriptor

byte->

1 1 1 1 1 x x x76543210

Bit

Meaningo

1=2 sided
O=not 2 sided
1=8 sector
O=not 8 sector
1=removable O=not removablemust be set to 1

1
2
3-7

14-21

Examples of current DOS media descriptor bytes:•

5 1/4" Diskettes:
hex Fe 1 sided 9 sector
hex FD 2 sided 9 sector
hex FE 1 sided 8 sector
hex FF 2 sided 8 sector•

Fixed Disks:hex F8 (Fixed disk)•

8" Diskettes:
Hex FE (IBM 3740 Format). Single sided,
single density, 128 bytes per sector, soft
sectored,4 sectors per allocation unit, 1
reserved sector, 2 FATs, 68 directory entries,
77*26 sectors.
Hex FD (IBM 3740 Format). Dual sided,
single density, 128 bytes per sector, soft
sectored, 4 sectors per allocation unit, 4reserved sectors, 2 FATs, 68 directory entries,
77*26 sectors.
Hex FE. Single sided, double density, 1024
bytes per sector, soft sectored, 1 sector per
allocation unit, 1 reserved sector, 2 FATs, 192
directory entries, 77*8*2 sectors.
Note: The two MEDIA descriptor bytes thatare the same for 8" diskettes (hex FE) is not a
misprint. To establish whether a diskette issingle density or double density, a read of asingle density address mark should be made. If
an error occurs, the media is double density.

14-22

INPUT or OUTPUT
Command codes=3,4,8,9, and 12

ES:BX
13-BYTE Request Header
BYTE Media descriptor byte
DWORD transfer address (buffer address)
WORD byte/sector Count
WORD starting sector number(no meaning on character devices)
The driver must perform the following:•

Do the requested function.

•

Set the actual number of sectors (bytes)
transferred.

•

Set the status word in the Request Header.
Note: No error checking is performed on an
IOCTL call. However, the driver must set thereturn sector (byte) count to the correct
number transferred.

14-23

The following applies to block device drivers:
Under certain circumstances the device driver may
be asked to do a write operation of 64K bytes that
seems to be a wrap around of the transfer address inthe device driver request packet. This arises due toan optimization added to the write code in DOS. It
will only happen on WRITEs that are within asector size of 64K bytes on files that are being
extended past the current end of file. It isallowable for the device driver to ignore thebalance of the WRITE that wraps around, if it sochoses. For example, a WRITE of 10000R bytes
worth of sectors with a transfer address of xxxx: 1
could ignore the last two bytes.
Remember: A program that uses DOS function
calls can never request an input or output
operation of more than FFFFR bytes; therefore, awrap around in the transfer (buffer) segment
cannot occur. It is for this reason that you canignore bytes that would have wrapped around in
the transfer segment.

14-24

Non Destructive Input No Wait
Command code=5

ES:BX

13-BYTE Request Header
BYTE read from device

The driver must perform the following:•

Return a byte from the device.

•

Set the status word in the Request Header.

This call is analagous to the console input statuscall on previous versions of DOS. If the character
device returns busy bit = 0 (characters in buffer),then the next character that would be read isreturned. This character is not removed from the
input buffer (hence the term Non Destructive
Input). This call allows DOS to look ahead one
input character.

STATUS
Command codes=6 and 10

ES:BX

I

13-BYTE Request Header

All the driver must do is perform the operationand set the status word in the Request Header
accordingly.

14-25

FLUSH
Command codes=7 and 11

ES:BX

I 13-BYTE Request Header
This call tells the driver to flush (terminate) all
pending requests that it has knowledge of. Its
primary use is to flush the input queue on
character devices. The driver must set status wordin the Request Header upon return.

The CLOCK$ Device

A popular add on feature is a "Real Time Clock"board. To allow these boards to be integrated into
the system for TIME and DATE, there is a special
device (determined by the attribute word) which is
the CLOCK$ device. In all respects, this device
defines and performs functions like any othercharacter device (most functions will be set done
bit, reset error bit, return). When a read or write
to this device occurs, exactly 6 bytes aretransferred. The first two bytes are a word which isthe count of days since 1-1-80. The third byte is
minutes, the fourth hours, the fifth 1/100 seconds,
and the sixth seconds. Reading the CLOCK$
device gets the date and time, writing to it sets thedate and time.

14-26

Sample Device Driver...

; ................ **** .........................**.......
5

;
;

6

;

7
8
9
10

•
•

PROLOG
THIS IS AN INST~LLABLE DEVICE DRIVER FOR AN
IN STORAGE DISKETTE (VIRTUflU WITH 180K C~P~CITY ••; ~ ....*••**** •• *.....****.....*.**' •• ~U..H***H***t.*
0000

CSEG

SEGHENT PARr. PUBLIC 'COIlE"
H~CRO(S)111~

STr-TUS MCRO
IFIDN
OR
ENDIF
IFInN
OR
[NDIF
IFIDN
OP.
EHDIF
IFNB
OR
ENDIF
ENDH

13
11

15
16
17
lH
19
20
21

27
23
2~

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
~1

12

n

44
~5

16
17
18

STATE,EP.R,RC(STIITE> ,(DONE>
ES:WORD PTP. SRH_STr.JLI/IBXJ ,0100H(STr-TE>,(BUSn
ES: WORD PTR SRH_STII_FLDIBXJ ,0200H(ERR) ,(ERROR)
ES:WORD PTR SRH_STAJLDIBX),1000H(Rc)
ES: WORD PTR SRH_ST~_FLDIBXJ, RC

EQUATES; RE~D/WR ITE" 0000" 0000" 0001" 0002" 0003" 000~SRH
EOU
SRH_LENEDU
SRH_LEN_FLD EIIU
SRH_UCO _FLD EOU
SRH_CCDJLD EQU
SRH_STAJLD EDU
SRH-'~(ESJLD EQU

0
13
SIlH
SRH+l
SRH+2
SRH+3
SRH+5

;STATIC REQUEST HEADER START;LENGTH;FIELD;
UNIT CODE FIELD;
COHH~ND CODE FIELD;STATUS FIELD;
RESERVED ARE~ FIELD

liD
liD_LEN

SRH+SRH_LEN
1/lD+IID_LEN
4
DTAH/TA_LEN;IIEDI~ DESCRIPTOR BYTELENGTH; [/ISK TRANSFER ADDRESS; DTA LENGTH; BYTE/SECTOR COUNT,LENGTH;STr.RTIH6 S~CTOR NUHBERLENGTH" OOOD" 0001" OOOEo 0001" 0012" 0002" 0014" 0002COUHT
COUNT _LEN
SSN
SSN_LEN" OOOERET _BYTE

Dl~[lT~_LEN

,

EQU
Eau
EQU
EOU
EQU
EQU
EOU
EOU

COUNT +COUHT _LEN;

; /lEDIA CHECK

~9

50
51

52
55
56
57

1I!1+IID_LEN; BYTE RETURNED FROII DRIVER

DTA+DTA_LEN
4;rOINTER TO BPB

,

53
5~

EQU

; BUILl/ BPB" 0012" 0004

BPBh_PTR
EauBPBA] TR_LEN EOULENGTH; INIT

14-27

58
59
60
61
62
63
64
65
66
67
68
69
70
71

·ooon
0001
• ooOE~ 0010~ 0004= 0012
·0014

UNITS
Eau
UNITS_LEN EOU
BR_MIDR_O EAU
BR_ADDU Eau
BR_ADDR_LEN Eau
BPB _PTR_ OFF Eau
BPU'TR_SEG Eau

0000

VDSK

0000
= 0000BEGIN:
START

~

92
93
91
95
96
97
98
99
100
101
102
103
10~

105
106
107
108
109
110
111
112

UNITS+UNI TUEN
BR_ADDR_0+2
4
8R_ADDR_0+BR_ADDR_LEN
BPB_PTR_OFF +2

,

72
73
74
75
76
77
78
79
80
81
82
83
81
85
86
87
88
89
90
91

SRH+SRH_LEN
1

0000
0004
0006
0008
OOM
OOOB

FF FF FF FF
2000
OOEl ROOEC R
01
07 [
??

PROC
FAR
ASSUIIE CS : CSEG, ES : CSEG, OS : CSEG

EOU$
SPECIAL DEVICE HEADER
OIl-1; POINTER TO NEXT DEVICENEXUEV;BLOCK DEVICE (NOH-IBH FORHilTl
ATTRIBUTE ow
2000H
OW
OEV _STRATEGY;POINTER TO DEVICE STRATEGYSTRATEGYWOINTER TO DEVICE INTERRUPT HIINDLER
IHTERRUPT OW
DEV_INT
DEV_N~ME; NUHBER Of BLOCK DEVICES
DB
I; 7 BYTES OF FILLER
OB
7 DUP(?);
0012 1??1
0011 m?

RH_OFFDW
RH_SEGDW; BIOS PARMETER BLOCK
BPB
EOU
$
OW
512
DB
1
OW
1
DB
2
OW
61
OW
360
DB
OFCH
OW
2

~ 00160016 0200
0018 01
0019 0001
OOlB 02
001C OO~O
001E 0168
0020 Fe0021 0002;REOUEST HE~D~R OFFSET; REQUEST HEADER SEGIIENT;SECTOR sm;SECTORS/I\LLOCIITION UNIT
i NUHBER OF RESERVElI SECTORS; NUHBER OF FliTS;NUHBER OF DIRECTORY ENTRIESi TOTAL NUHBER OF SECTORS;HEDI~ DESCRIPTORiNUHBER OF SECTORS OCCUPIED BY FAT;
0023 0016 R

BPB]TR OW
B~B; CURRENT VIRTUAL DISK INFORMATIONTOTALDWVERIFYDB
START _SEC OWVDISK_PTR DW
USER_DTADO?
$
BOOT_REC
EOU
3 OUP(O)DB

0025 n110027 00
0028 0000
002~ 0000
002C ??11????
= 00300030
03 r;DIOS PARAIIETER BLOCK POINTER ARRAY (I ENTR);TOTAL SECTORS TO TRANSFER;VERIFY I=YES, O=NO
;STARTING SECTOR NUIIBER;STARTING SEGHENT OF VIRTRUAL DISK;POINTER TO CALLERS DISK TRANSFER ADDRESS; DUHHY DOS BOOT RECORD; 3 BYTE JUHP TO BOOT CODE (NOT BOOTABLE>00~9 42 40 20 20 32
2E 30
003B 0200
0030 01
003E 0001

0033

14-28

DB

'IBH 2.0'; VENDOR I~ENTIFICA TION

DW
DB
OW

512
1

;NUHBER OF BYTES IN A SECTOR;1 SECTOR PER ALLOCATION UNIT
; 1 RESERVED SECTOR

1

113
IH
US
116
117
118
119
120
121

122
In
124
125
126

12J
128
129
130
131
132
133
134
135
136
137
139
139
140
141
112
143
141
Wi
116
IH
118
H'I
150
151
152
153
154
15~j
156
157
15S
159
160
161
162
163
161
165
166
167

09

0040 020041 0040
0043 0168
0045 FC00~6 0002

OW
OW
DB
OW

2
64
360
OFCH
2

i2 FATSiHUHBER OF DIRECTORY ENTRIES
i360 TOTAL SECTORS IN I"AGE
iTELLS DDS THIS IS A SINGLE SIDED 9 SECTOR [iNUHBER OF SECTORS IN FAT

BYTE
INIT
"EDIUHECI(BUILUPB
IOCTUNINPUT
NIUNPUTIN_STATIN_FLUSHOUTPUT
OUT_VERIFYOUT_STATOUT_FL,USH
IOCTL_OUT

iIHITImZATIoN
iKEDIA CHECK (BLOCK ONLY)iBUILD BPB
i IOCTL INPUTiINPUT (READ)
iNON_DESTRUCTIVE INPUT NO WAIT (CHAR ONLY)i INPUT STATUS
iINPUT FLUSH
iOUTPUT (WRITE)i OUTPUT (WRITE> WITH VERIFYiOUTPUT STATUS
i OUTPUT FLUSH
i IOCTL OUTPUT

FUNCTION TABLE
00~8

0048
004A
004C
004E
0050
0052
0054
0056
0059
005A
OOSC
005E
0060

0062
0062
0066
006A
006E
0072
0076
0078
007C
007D
007D
0070
0081
0081
0086
008B
008D
008F
0091
0095
0098

FUNTAB
0105 R
01B8 R
01CC R
0212 R
0212 R
0212 R
0212 R
0212 R
0241 R
0280 R
0212 R
0212 F:0212 R

26: BB 47 OE
2E: (\3 002C R
26: 8B 47 10
2E: 113 002E R
26~ 88 47 12
32 E4
2E: A3 0025 R
C3

2E: III 0028 R
B9 0020
F7 El
2E: 88 16 002A R
03 DO
8E DII
33 F6
2E: Al 0025 P.
B9 0200
F7 El
009~ 08 CO
009C 75 03
009E BB FFFF
001'11OOAI 9100(:2 C3
00A3

LABEL
DW
OW
OW
OW
DW
DW
DW
OW

DW
llW

nw
DW
DW

iLOCAL PROCEDURESi
IN_SAVE PROC NEAR
AX,ES:WORD PTk DTA[BX]HOViSAVE C~LLERS OTA
CS:USER_DTA,AX
HOV
AX,ES:WORD PTR [ITA+2[BXJ
MOV
CS: USER_DTA+2 ,AX
HOV
HOV
AX, ES: WORD PTR COUNHBX] iGH NUKBER OF SECTORS TO READ
AH,AH
XOR
CS:TDTAL,~X
HOViHOVE NUKBER OF SECTORS TO TOTALRET
IN_SAVE ENDPi
CALC_~DDR PROC HEAR
IIX, CS: ST flRT _SEC
MOV
iGG STARTING SECTOR NU"BER
eX,20Hil,OV 512 TO CX SEGIlENT STYLE
KOV
jlUlTIPL Y TO GET ACTUAL SECTOR
CXKULDX, CS: VDISK_PTR
iGET SEGKENT OF VIRTUAl DISKMOViADO THflT SEGKENT TO INITIAL SEGKENT
ADD
OX/AX
DS,DY.
i SIIVE THA T AS THE ACTUI'J.. SEGKENT
MOV
51,51
;IT'S ON II PARAGRAPH BOUNDARY
XOR
I'lX, CS :TOTALi TOTIIL NUKBER OF SECTORS TO READ
MOV
CX,512i BYTES PER SECTORMOVCXi HUlTIPLY TO GET COpy LENGTH
HUL
ftX,ftXiCHECK FOR GREATER THAN 61K
OR
HOVUT
JNZ
flX,OFFFFHiHOVE IN FOR 64K
MOV
HOVE_IT:CX,AXiHOVE LEHGTH TO CXXCHGRETCALC_ADDR ENDP

14-29

168
169
170

171
172

00A3
00A3 E8 007D R
00A6 2E: 8E 06 002E R
001\8 2E: 88 3E 002C R

00110 88 C70082 03 Cl
001l~ 73 07
0086 88 FFFF
00119 2ll C70088 88 C8OOItD
OOBD F3/ M
OOBF C3OOCO
OOCO
OOCO f8 007D R
00C3 IE
OOC~ 07
00C5 8HE
00C7 2E: BE IE 002E R
OOCC 2E: 88 36 002C R

202
203
201

205

MOV
flDD
JNC
/lOV
SUB
HO'J

AX,DI
AX,CX
READ_COPY
AX,OFFFFH
AX,DI
CX,flX

iGET OFFSET OF DIA
iADD COPY LENGTH TO ni CARRY FLAG " 0, NO WRAP
iHAX LENGTHiSUBTRflCl DrA OFFSET FROM HAX
iUSE THAT flS COPY LENGTH TO AVOID WRAP

RE~D_CO~Y:

REP

HDVSB
RET

i DO THE "READ"

SECTOR_RE~D ENDP,

SECTOR_WRITE PROC NEAR
CflLL
Cf:LC_flDDR
PUSH
OS
POP
ES
HOV
DI,SI
/lOV
IIS,CS: USEfcDrf:+2
SI,CS:USER_DTiI
HOV

iCALCUUHE STARTING "SECTOR"
iESATABLISH ADDRESS~BILITY

i ES: 01 POINT TO "DISK"; OS: SI POINT TO C~LLERS DU,; CHECK FOR DT~ WR~P

191

195
196
197
198
199
200
201

iCALCULATE THE STARTING "SECTOR"iSET DESTINATION (ES:[I!) TO POINTiTO CALLERS DTA

i CHECK FOR [ITfl WRAP IN CASE WE CAME THROUGH VIA VERIFY

173

m

175
176
177
178
179
180
181
182
183
181
185
186
187
188
189
190
191
192
193

SECTOR_REf:D PkOC NEAR
CALC_ADDR
CALL
ES,CS:USER_DTA+2
MOV
DI,CS:USER_DTA
MOV

0001
0003
00D5
0007
OODA
OODC
00[1[
OODE
00£0
OOEI

14-30

88 C6
03 Cl
73 07
B8 FFFF
2B C6
8B C8
F3/ M
C3

HOV

; HOVE DT f: OfFSET ro AX~DD

f:X,SI:'IX,CXJNCWRITE_COPY
HOVAX,OFFFFH
I\X,SI
SUlI
HOV
CX,AX
WRITl_COPY:
REP
HOVSB
RET
SECTOR_WRITE ENDP

i liDO COPY LENGTH TO OFFSET; CARRY FL~G " 0, NO SEGltE Nr WRIlP; HOVE IN Hi\X COPY LENGTH;SUBTRACT DTA OFFSET FROH HAX;USE AS NEW COpy LENGTH TO i\VOID WRAP
;00 THE "WRITE"

206
207
208
209
210
21l
212
213
214
215
216
21l
218
219
220
221

222
223
224
225
226
?:'7
229

PAGE
DEVICE STRATEGY
OOEI
00E1
00E6

oon

2E: 8C 06 0014 R
2E: 89 IE 0012 R
CB

2~1

242

2H
241
2~5

2~6

21.7
248
2~9

250

:m
252

OOEC
OOED
OOEE
OOEF
OOFO
00F1
00F2
00F3
00F4

i [t F V ICE

INTERRUPT

FC
IE
06
50
53
51

5'
57
~6

iSAVE SEGHENT OF REilUEST HEADER POINTER
i SAVE OFFSET OF

HANDLER

DEV_INT:i PRESERVE HACHINE STATE ON ENTRY
CLII
PUSH
DS
PUSH
ES
PUSH
AX
PUSH
BX
PUSH
CX
PUSH
OX
PUSH
DI
PUSH
SI

,

i DO THE BR~NCH ~CCORDING TO THE FUNCTION PASSED
00F5
00F9
00f'B
OOFF
0101
0103

26: 8A 47 02
DO CO
aD 3E 00~8 R
32 E4
03 F8
FF 25

,
0105
0105
0106
0107
OIOC
010E
0110
0112
0117
011A
011C
0122
0126

2S3

om

251
255

012F
0133
0137
013C
013E

256
257
258

CS:RH_SEG,ES
CS : RH_OFF ,BX

,
OOEC

m

230
231
232
233
234
235
236
237
238
239
210

DEV _STRATEGY:
IIOV
IIOV
RET

2~V

01~2

260

0145

AL,ES: [8X)+2

IIOV
ROL

~L,l

LE~

DI ,FUNT~B

XOR
ADD
JHP

DI,AX
WORD PTR[DIli GET FUNCTION BYTE
iGET OFFSET INTO TABLE
iGET ~DDRESS OF FUNCTION TABLE~H,:'IH

INIT

INlT:
OE
51\
2E: 8D 06 021':0 R
BI 04
D3 C8
03 DO
2E: 89 16 0021\ R
B8 2DOO
03 DO
26: C7 47 OE 0000
26: 89 57 10
26: C6 U OD 01
811 16 0023 R
26: 89 57 12
26: 8C 4F 14
2£: 8E 06 002A R
33 FF
SD 36 0030 R
F9 0018
F3/ M

REP

PUSH
POP
LEA
IIOV
ROR
ADD
IIOV
HOV
nOD
IIOV
MOV
HOV
LEn
HOV
IIOV
IIOV
XOR
LEi\
IIOV
HO')S8CSDX~XJCS:VDISKi CURRENT CS TO DX;GET ADDRESS OF VIRTUAL DISK

CL,1
AX,CL

; DIVIDE n 16 (PARAGRAPH FORII);ADD TO CURRENT CS VALUE
CS: VDISK_PTR ,DX;SAVE ~S STARTING SF.GIIENT OF VIRTU~L DISK
i\X,2DOOH; ADD 2DOOH PARAGRAPHS TO STARTING
DX,nx
SEGMENT OF VunUAL III SI(i
ES :IIORD PTR BR_ADDR_OCBXJ ,0
ES: Bk_ADDR_I [BXJ ,DX;HIlKE THAT THE BREAK ADDRESS
ES: BYTE PTR UNITS[BXl,l iNUHBER OF DISKETTE UNITSDX,BPB_PTR;GH ADDRESS OF BPB POINTER ARR~Y
ES: BPB_PTR_OFFEBXl, DX is/\vE OFFSET IN DAHl PACKET
ES: Bf'B_PTR_SEG [!lXl, CS iSf:VE SEGIIENT IN DATA P(:CKET
ES,CS:VDISK_PTR;GET SfARTING SECTOR OF VIRTUAL DISK
I1I,DIiZERO OUT DI (BOOl RECORD)
SI, BOOT _REC
i~DDRESS OF BOOT RECORD
CX,24;COPY 21 BYTES OF BOOT RECORD
DX,~X

14-31

261

262
263
264
265
266
267
268
269
270
271
272
273

m

275
276
277
278
279
280
281
282
283
294
285
286
287

288
289
290
291
292
293

2E: C7 06 0028 R 0001
om 2E: C7 06 0025 R 0002
0155 E8 007D R
0158 IE
0159 07015~ 8B FE
015C 32 CO
015E F3/ AA
0160 C6 01 FC
0163 C6 ~4 01 FF
0167 C6 41 02 FF
0168 a016e 56
016D 2E : C7 06 0028 R 0003
0174 2E: C7 06 0025 R 0002
017D E8 007D R
om IE
017F 070180 88 FE
0182 5E
0183 IF018~ F3/ M
0186 2E : C7 06 0028 R 0005
0180 2E: C7 06 0025 R C004
019~ E8 007D R
0197 32 CO
0199 IE
019(: 07
019B 33 FF
F3/ AAom 2E: BE 06 0011 R
01M 2E: 8B IE 0012 R
0117

om

29~

01t.9

295
2%
297
298
299
300
301
302
303
3M
305
306
307
308
309
310
311
312
313

01~F

m

315

26: 81 4F 03 0100
26: 81 iF 03 COOO
01BS E9 0289 R

REP

REP

REP

,

"DV
"DV
C/ILL
PUSH
PDP
"OV
XOR
STOSB
"OU
"OU
"OV
PUSH
PUSH
"OU
HOV
CALL
PUSH
POP
"OV
POP
POP
HOUSB
"OV
"OV
CALL
XOR
PUSH
POP
XOR
sroSB
"OV
HOV
STI'lTUS
OR
OR
J"P

CS:IIDRD PTR START_SEC,1
CS:1I0RD PTR TOTflL,2iCI'ILCULI'ITE ADDRESS OF LOGIC~L SECTOR 1
CALC_I'IDDR
DS
ES
DI,SI
i"OUE THt.T ADDRESS TO ES:DI"L,IILiZERO OUT FAT ARE~
DS:SYTE PTR [SIl,OFCH iSET THE FIRST FAT ENTRY[IS: BYTE PTR HS!], OFFH
[lS:BYTE PTR 2[SIJ,OFFH
DS
iSAUE POINTER TO HITSION THE ST"CK
CS:1I0RD PTR STt.Rl_SEC,3
CS:WORD PTR TOTIIL,2iCALCULATE t.DDRESS OF LOGICAL SECTOR 3
Ct.LU1DDR
DS
ES
DI,SI
i"OVE THAT ADDRESS TO ES:DI
SI
iRESTORE ADDRESS TO FIRST FATDS
iCOPY FIRST FAT TO SECOND FAT
CS:1I0RD PTR START_SEC;5
CS:1I0R[1 PTR TOTflL,4iCALCUL:HE ADDR OF L.S. 5 (START OF DIR)
CALC_ADDR
t.L,ALDS
i SET UP ES: DI TO POINT TO IT
ESDI,DIiZERO OUT DIRECTORY
ES ,CS: RH_SEG;RESTORE ES: BX TO REQUEST HEIIDER
8X,CS:RH_OFFiSET STI'lTUS 1I0RD (DONE, NOERROR)
DONE, HOERROR, 0
ES:WORD PTR SRH_STn_FUI[BXJ ,0100H
ES:1I0RD PTR SRH_STA_FLD[BXJ ,0
EXIT

i "HilA CHf.CK
0188

HEDIn_CHE.CK:

i "E[lIA CHECK (BLOCK OHL Y)

SET HEDI~ NOT CHnNGED
01B8 26: C6 47 OE 01
018D 26: 81 4F 03 0100
01C3 26: Bl ~F 03 0000
01C9 E9 0288 R

ES:BYTE PTR RET_BYTHBXJ,1 iSTDRE IN RETURN BYTEHOV
i TURN ON THE DONE BITSTATUS DONE, HOERROR, 0
ES:WORD PTR SRH_STfl]LDrBXJ,OI00H
OR
ES:IIOR!) PTR SRH_STA_FLD[BXJ ,0
OR
JHP
EXIT
i BUILD BIOS PARMETE.R BLOCK

01CC
OICC 06
01CD 5301CE 2E : C7 06 0028 R 0000

14-32

BUILD_BPB:
PUSH
PUSH
HOV

;SAVE SRH SEGHEHT
ESi S(:VE SRH OFFSET
BX
CS : 1I0RD PTR START _SEC, 0

316
317
318

31Y
320
321
322

32J
321

32S
326
327
328
329
330
331
332
333
33~

335
336
337
338

m

3~0

311
3'~2

343
~~~

0105 2E: C7 06 0025 R 0001
01DC £8 007D R
01DF OE
OlEO 07
om 8D 3E 0016 R
01E5 83 C6 OB
01E8 B9 OOOD
01EB F3/ M
01E9 58
olEE 07
om 8D 16 0016 R
01n 26: 89 57 12
01F7 26: 8C 1F 11
01FB 26: 89 57 OE
om 26: 8C 1F 10

HOV
CALL
PUSH
PDP
LB
~DD

REP

0203 26: 81 1F 03 0100
0209 26: 81 4F 03 0000
020F EB 77 90

HOV
HOVSB
POP
POP
LB
HOV
HOV
HOV
HOV
STATUSDR
OR
JHP

CS:WORD PfR TOTAL,I
C~LC_ADDRi CALCULATE ADDRESS OF FIRST SECTOR

CSESDI,BPB
51,11CX,13iADDRESS OF BIDS PARAHETER BLOCKiADD 11 TO 51
iLEMGTH OF BPB

iRESTORE OFFSET OF SRH
ESi RESTORE SEGHENT OF SRH
DX,BPB
iGET BPB :'lRR~Y POIHTER
ES : BPBA_PTR[BY,l ,DY.
i SAVE PTR TO BPB T~BLE
ES: BPBA_PTR+2[BXl ,CS
ES :DT~[BY.l ,DXi OFFSET OF SECTOR BUFFER
ES: DTM2[BXl ,CS[lONE, NOERROR, 0
ES:WORD PTR SRH_SH_FL[I[BXl,0100H
ES:IIORD PTR SRH_STr._FLlI[BX1,O
EXIT
BX; THE FOLLOIIH!G EHTRIES ARE FOR NOT SUI-PORTED BY THIS DEVICE
0212
0212
0212
0212
0212
0212
0212

10CTL_IN:
IOCR_OUT:
ND_I~PUT:iNON_DESTRUCTIVE INPUT ~O WMT (CH~R ONLY>;INPUT STi\TUS; INPUT FLUSH
i OUTPUT smus
i OUTPUT FLUSH

HUTnT:
IN_FLUSH:
OUl_ST~T:

OUT_flUSH:

,

315
3~6

; DISK REA[I

347
3~U

3~9

0212
0212 E8 0062 R

350
351
352
353
354
355
356
357
359
359
360
361
362
363

0215
0219
0210
0221
0225
0228
0220

36~

0241
0241 E8 0062 R
0244 26 8D ~7 14
024R 2E A3 0028 R
024C 26 88 ~7 120250 2E ~3 0025 R
0254 E8 OOCO R

365
31,6
367
36R
369
370

INPU1:
CALL
HOV
HOV
HOV
HOV

IN_SAVE;CALL THE INITIAL SAVE ROUTINESSN[BXl ;SET STARTING SECTOR NUHBER
CS : START _SEC ,~X;SAVE STARTING SECTOR NUHBER
AX,ES:WORD PTR COUNHBXl
CS:TOT~L,AX; SAVE TOTAL SECTORS TO TRANSFER
C~LL
SECTOUEAD;READ IN THAT HANY SECTORSHOVDX, CS: RH_OFF;RESTORE ES: BX AS REQUEST HEADER POINTER
HOV
ES ,CS: RH_SEG
SlWIS IIONE I NOERROR I 0; SET STATUS WORD (DONE I NOERROR)
ES:WORD PTR SRH_STi\JLD[BX1,010OH
OR
ES: WORD PTR SRH_STA_FUI[BX1,O
OR
JHP
EXIT

26 88 47 11
2E A3 0028 R
26 88 17 12
2E A3 0025 R
E8 00n3 R
2E: 8B IE 0012 R
2E: 8E 06 0014 R

0232 26: B1 4F 03 0100
0238 26: 81 ~F 03 0000
onE ED ~8 90~X ,ES: IIORD PTR

i DISK WRITEOUTPUT:
CALL
HOV
HOV
HOV
HOV
CALL

;OUTPUT (WRITE)
IN_SAVE
AX,ES: WOR[I PTR SSN[BXl i GET STARTING SECTOR NUHBER
CS:START_SEC,AX
iSET
AX,ES:WOR[I PTR COUNHBXl
CS:TOlAL,IIX
iSAVE TOll'lL SECTORS TO WRITESECTOR_WRITE;I/RITE OUT THOSE SECTORS

14-33

371
372

373
371
375
376
377
378
379
380
3RI

382
393
38~

385
3116
387
3811
389
390
391
392
393
394
395
396
397
398
399

100
'.01
402
403

404
'.05

0257 2E: 8[4 IE 0012 R
025C
0261
0267
0269
026F
0271

2E: 8E 06 0014 R
2E: 80 3E 0027 R 00
74 08
2E: C6 06 0027 R 00
EB Al

0271

26: 81 '.F 03 0100

0277 26: 81 J!F 03 0000
0270 E8 09 90
0280
0280 2E: C6 06 0027 R 01
0286 ED B9

MOV
HOV
CHP
JZ
HOV
JHP
HO_VERIFY:STIITUSOROR
JHP
OUT _VERIFY :HOV
JHP[4X I CS: RH_OFF
ES/CS :RH_SEG
CS:BYTE PTR VERIFY,O
NO_VERIFY
CS: BYTE PTR VERIFY, 0INPUTiRESTORE ES:BY. AS REQUEST HEADER POIHTERi WRITE VERIFY SETiNO, NO IIRITE VERIFY
iRESET VERIFY IHDIC/\TOR
i READ THOSE SECTORS BACK IN[lONE, NOERROR ,0i SET DONE, NO ERROR III ST ~ TUS WORD
ES:I/ORD PTR SRH_ST~_FlD[BX]/OIOOH
ES : WORD fTR SRH_STfl]lD[BX] ,0
EXIT
iOUTPUT (WRITE> WITH VERIFY
CS:BYTE PIR VERIFY,I
iSET THE ')ERIFY Fl:'lG
OUTPUTi 8R/\NCH TO OUTPUT ROUTINE

ii COMMON EXIT

,
0288
0288
0289
028f.
028B
028C
0280
028E
028F
0290
0291
02AO

EXIT:
POP
POP
POP
POP
POP
POP
POP
POP
RET

5E
5F
5/\
59

58
58
07
IF

ell

SI

LO]:
i H~CRO TO ~LIGN THE VIRTU~l DISK ON ~ PARAGRflPH BOUNDARY
if ($-START> HOD 16($-STARTl+16-«$-START) HOD 16)
ORG
~ndif

~ 02M
02110
02AO

406

14-34

i RESTORE All OF THE REGISTERS

01
[IX
CX
(IX
AX
ES
OS

VDISK
VDSK

csm

Eau
EHDP
ENDS
END

BEGIN

Appendix E. DOS Control Blocks
and Work Areas ......................... E-1
DOS Memory Map ................... E-1
DOS Program Segment ............... E- 3
Program Segment Prefix.............. E-8
File Control Block ................... E-10
Standard File Control Block ...... E-11
Extended File Control Block
E-14
Appendix F. Executing Commands
from Within an Application... . . . . . . .. . .

F-1

Appendix G. Fixed Disk Information ....
Fixed Disk Architecture ..............
System Initialization .................
Boot Record/Partition Table .........
Technical Information ...............

G-1
G-1
G-2
G-4
G-6

Appendix H. EXE File Structureand Loading ...........................

H-1

Appendix I. Running Compilers
and Assemblers .........................
Using Compilers and Assemblers
with Fixed Disk .....................
Exceptions ...........................
Appendix J. Running the Pascal
Compiler ...............................
Using Pascal Hex Patchwith Fixed Disk .....................

A-ii

1-1
1-1
1-3
J-1
J-1

Appendix K. Considerations for
Using Applications .................... . K-l
Accounting Package by BPI
Systems, Inc. . ..................... . K-3
Accounting Packages Version 1.00 by
Peachtree Software, Inc. . .......... . K-3
Accounting Packages Version 1.10 by
Peachtree Software, Inc. . .......... . K-3
Arithmetic Games 1 and 2 ........... . K-4
Asynchronous Communications
Support Version 1.00 .............. . K-5
The Procedure ................. . K-5
Asynchronous Communications
Support Version 2.00 .............. . K-7
The Procedure ................. . K-8
EasyWriter Version 1.10 ............ . K-I0
Fact Track ......................... . K-12
PFS:File ........................... . K-14
Using PFS:File with the
IBM Fixed Disk ............... . K-14
Storing a PFS:File on the
Fixed Disk .................... . K-14
Copying PFS:File to theFixed Disk .................... . K-15
Error Conditions ............... . K-16
Running the PFS:File Programfrom a Fixed Disk ............. . K-17
Changing Settings When Using
the Fixed Disk ................ . K-IT

A- iiiPFS:Report .........................
Using PFS:Report with the IBM
Fixed Disk .....................
Storing a PFS:File on the
Fixed Disk .....................
Copying PFS: Report to theFixed Disk .....................
Error Conditions ................
Running the PFS:Report Programfrom a Fixed Disk ..............
Changing Settings When Using theFixed Disk ...................•.
The Dow Jones Reporter
Version 1.00 .......................
SNA 3270 Emulation and RJE Support
Version 1.00 .......................
The Procedure ..................
Typing Tutor ........................
VisiCalc Version 1.10 by VisiCorp .....
Putting DOS 2.00 on Your
Program Diskette ..............
3101 Emulator Version 1.00 ..........
The Procedure ..................

A-iv

K-18
K-18
K-18
K-19
K-20
K-21
K-21
K-22
K-23
K-23
K-25
K-26
K-26
K-28
K-28

Appendix A. DOS Version 2.00
Enhancements

The information in this appendix is divided into
two categories----'-those topics that apply to allusers, and those topics that apply to system
programmers or application developers. In eachcase, a brief description of the feature or change isoffered, and you are referred to another section of
the book for further details.

For All Users
DOS Version 2.00 incorporates the following new
and changed features:•

Special characters. The characters <, >, , andnow have special meanings to DOS, and canno longer be used in filenames. If you havefiles whose names contain any of thesecharacters, they should be renamed (using
your old version of DOS) before attempting to
use them with DOS Version 2.00.

•

Configuration file. You can create a file ofspecial commands that DOS will read eachtime it starts up. The commands allow you to
specify the number of disk buffers DOS
should use, the names of device drivers, andadditional information concerning DOS
operation. Please refer to "Configuring Your
System" in Chapter 5 (Section 1) for
additional information.

A-I

•

Support for one or more fixed disk devices. The disk
can be divided into multiple partitions, each
usable by a different operating system. You
can start (boot) your operating system fromthe fixed disk, and utility programs included
to perform disk initialization, backup, andrestore functions. If you have a fixed disk,
please read the "Preparing Your Fixed Disk"
information in Chapter 4 for setup
instructions and the BACKUP and RESTORE
commands in Chapter 6 for their respectivefunctions.

•Support for increased diskette capacity. Beginningwith DOS Version 2.00, DOS formats
diskettes at 9 sectors per track, which
increases capacity from 163840 to 184320
characters of information for single-sided
diskettes, and from 327680 to 368640
characters for dual-sided diskettes. The
smaller capacity diskettes created by DOS
Version 1.00 or DOS Version 1.10 (8 sectors
per track) are also usable with DOS Version
2.00. You do not need to reformat them.
Please see the FORMAT and DISKCOPY
commands in Chapter 6 for more information.

•

Multiple disk buffers. A disk buffer is an area ofuser memory that DOS reserves at startup andis used for performing disk and disketteoperations. DOS normally allocates two disk
buffers at start-up time. Some users, however,will find that certain applications, such as database applications, may run faster if DOS has
more buffers available to it. DOS Version
2.00 allows you to specify the number ofbuffers that DOS should reserve at start-up
time. Please refer to "Configuring Your
System" in Chapter 9 for instructions on
specifying additional buffers.

A-2

•

Tree-Structured Directories. This new featureallows you to place related groups of files intheir own directories-all on the same disk.
The individual directories are isolated fromeach other, giving the appearance of separate
disks. Therefore, a search for a file in a given
directory will not "see" files in otherdirectories on the same disk.
Each directory, beginning with the normal
system directory (called the root directory) may
contain special entries naming otherdirectories on the same disk. These otherdirectories, in turn, may contain entries foreven more directories, and so on. Whenviewed in a logical order beginning with theroot directory, the directory structure appears
much like a diagram of a family tree-thus theterm tree-structured directories.
You may add or remove directories, copy files
from one directory to another, instruct DOS
to look in a specific directory to locate a file,etc. For complete details, please refer to
Chapter 5 "Using Tree-Structured
Directories" .

•Disk Volume Labels. This feature allows you to
specify a unique volume label (up to 11
characters) at the time you format a disk. The
volume label is placed in the root directory,
and is included in the displays produced by
the DIR, CHKDSK, and TREE commands.
Please refer to the FORMAT command forfurther information.

A-3

•

Extended DOS screen and keyboard control. Thisfeature allows you to issue special character
sequences from within your program that
DOS will use for screen cursor positioning
and color, and further allows you to assign themeaning of any key on the keyboard. For
example, you may assign the character string"DIR A:" to the FlO key so that simply
pressing the FlO key has the same result asentering the DIR A: command. Please refer to"Using Extended Screen and Keyboard
Control" in Chapter 13, and "Configuring
Your System" in Chapter 9 for more detailed
information.

•

Redirection of Standard Input and Output. Thisfeature applies to all DOS programs that readfrom the keyboard or write to the screen (thestandard input and output devices). By using
the special characters < (for input) and> (foroutput), you can cause a program to receiveits input from a source other than the
keyboard, or to direct its output to a
destination other than the screen. For
example, the command:
DIR A:> DIRLIST

causes the directory listing from drive A to beplaced in a file named DIRLIST on the default
drive. Device names can also be used. For
example, the command:
DIR A:>PRN

causes the directory listing to appear on theprinter instead of the screen. Please refer to"Redirection of Standard Input and Output"
in Chapter 10 for further information.

A-4

•

Piping of standard input and output. This featureallows the standard output of one program tobe used as the standard input to another. DOS
acts as a "pipeline" to direct the output of thefirst program to the input of the secondthus, the term "piping." For further
information and an example of its use, pleaserefer to "Piping of Standard Input and
Output" in Chapter 10.

New Commands
The following new commands have been added to
DOS Version 2.00. Please consult the commanddescriptions in Chapter 6 and Chapter 10 for
further details and examples of their use.

ASSIGN
Allows you to reassign drive letters so that arequest for a given drive can be routed to adifferent drive.

BACKUP
Backs up one or more files from a fixed disk to
diskettes.

BREAK
Allows you to specify when DOS should check fora Ctrl- Break being entered at the keyboard.
Normally, DOS only performs this check during
screen, keyboard, printer, or auxiliary device
operation. With this command, you can instruct
DOS to check for Ctrl- Break whenever a program
requests DOS to perform any function (such as
disk operations). In this way, it is possible to"break out" of a program that performs few orno screen or keyboard operations (such as acompiler).

CLS
Clears the screen when used from a batch file or
the keyboard.

CTTY
Allows you to define a different primary console,
so that a remote terminal device can be used inplace of the standard screen and keyboard. This
command also reverses this assignment, to restore
the keyboard and screen as the standard input andoutput devices.

ECHO, IF, FOR, SHIFT, GOTO
New sub commands provided to extend theflexibility of batch processing.

A-6

FDISK
Initializes and configures a fixed disk.
Note: This command must be used before
you use your fixed disk for the first time.
Please refer to Chapter 4 " Preparing Your
Fixed Disk".

GRAPHICS
Allows the Shift- PrtSc keys (display screen
contents on printer) to print the image of agraphics display screen.

MKDIR, RMDIR and CHDIR
Create, remove, and inform DOS to use a
directory other than the system directory.

PATH
Allows you to specify one or more paths of
directory names that DOS will search if thecommand you have issued was not found in thecurrent directory. They allow conditional
execution of commands within a batch file bycausing DOS to check for specified conditions.

PRINT
Prints a queue (list) of files on the system printerwhile you are using the system for other work.

A-7

PROMPT

Allows you to change the system prompt to adesired string.
RECOVER

Recovers a specific file that cannot be copied orotherwise used because of a defective spot on thedisk that prevents the file from being read. This
command also recovers multiple files when the
directory has been damaged.

RESTORE·

Restores one or more files from a diskette to a
fixed disk.

SET

Allows you to enter keywords and parameters intoa DOS" environment" that is accessible bycommands and applications.

TREE

Displays the entire directory structure of thespecified disk.

VER

Displays the DOS version number on the screen.

A-8

VERIFY
Instructs DOS to perform a verify operation (or tostop performing the verify) each time data is
written to disk, until a new verify command isissued to turn the verify feature off. The verify
operation increases assurance that the data wasproperly recorded on disk (that is, it can be read
without error).

VOL
Displays the volume label of the disk in thespecified drive.

Enhanced Commands
The following commands, that existed in DOS
Version 1.10, have been enhanced for DOS
Version 2.00. For more detailed information,please consult the individual commanddescriptions in Chapter 6 and Chapter 10.

CHKDSK
Supports the fixed disk, the new and old disketteformats, and analyzes all directories on thevolume. It also enables you to create files
containing all sectors that were found to beallocated but were not associated with a file, sothat you can recover "lost" data. An importantfeature is that, unlike Version 1.10 CHKDSK, it
will take no corrective action on the disk being
analyzed unless instructed to do so.

A-9

COMP
The file compare utility now allows multiple files
to be compared. For example, you can compare allof the files on one disk with their counterparts onanother disk. Also, COMP no longer prompts you
to insert diskettes before comparing.

DEBUG
Now contains a command allowing you to enter
assembly language statements that are assembled
directly into memory.

DIR
Now displays the volume identification of thespecified disk and clearly identifies entries that
contain the names of other directories. It also
displays the amount of available space left on the
disk.

DISKCOPY and DISKCOMP
Support the new 9-sector-per-track disketteformat.

EDLIN
The line editor contains several new subcommands
for more flexible management of source data.
They include commands to copy and move lines,
and to merge the contents of another file. The
Replace and Search commands have been changed
to begin their search at the current line plus one.

A-to

ERASENow requires you to press the Enter key after
entering the YIN response to the
Are you sure (YIN)?

message that appears when you instruct DOS
to erase all of the files on a volume. This isintended to prevent accidental erasure of all files
from the larger capacity devices supported by DOS
Version 2.00.

FORMATNow formats diskettes at 9 sectors per track (inDOS 1.00 and 1.10 diskettes were formatted at 8
sectors per track), allowing each new diskette tohold more data. It also allows you to specify avolume identification that is recorded in the disk's
directory. Support for initialiZing a fixed disk isalso included.

LPT2:, LPT3:, and COM2:
Now recognized as valid device names by DOS,and can be used in place of filenames.

A-IIFor Programmers•

DOS Version 2.00 includes the ability to
install your own device drivers for characteror block-oriented devices. Please refer to
Chapter 14 "Installable Device Drivers" formore details.

•

Three changes were made to internalfunctions that cause different results fromthose obtained on DOS Version 1.10:
1.

The function call (hex 1B) that
previously returned a pointer to the fileallocation table now returns a pointer toonly the table's identification byte, forpurposes of de terming the disk type. Allapplications that use call hex I B toobtain the file allocation table should bechanged to use interrupt hex 25 to readthe file allocation table directly from thedisk. The file allocation table always
begins at logical sector 1, and its size canbe determined from the information
returned by call hex 36. We recommendthat you avoid using calls hex IB andhex IC.

2.

The mapping of logical sectors on dual
sided diskettes has been rearranged tofacilitate program loading and to improvesystem performance.
This change allows DEBUG to load anentire file with a single L command.
Applications that use interrupts hex 25
and hex 26 on multi-sided disks or
diskettes may require modification tooperate properly on DOS Version 2.00.
Please see the description of Int 25 inAppendix D.

A-12

3.

•

Additional bits have been defined in thefile attribute byte of the DOS disk
directory. Programs that depended upon
the file attribute byte being equal to zero
if a file was not a hidden or system file
may not work correctly. (See Appendix C
for the definition of the new attributebits.)A new set of function calls has been madeavailable to provide a wide variety of services.
We suggest that systems programmers andapplication developers review all of Appendix
D for details on these new functions.

A-13

Notes:A-14

Appendix B. DOS Technical
Information

Appendixes B-K are intended to supply
technically oriented users with information about
the structure, facilities, and program interfaces ofDOS. It is assumed that the reader is familiar withthe 8088 architecture, interrupt mechanism, andinstruction set.

DOS Structure
DOS consists of the following four components:
1.

The boot record resides on track 0, sector 1,
side 0 of every disk formatted by the
FORMAT command. It is put on all disks inorder to produce an error message if you try
to start up the system with a non-DOS
diskette in drive A. For fixed disks, it resides
on the first sector (sector 1, head 0) of thefirst cylinder of the DOS partition.

2.

The Read-Only Memory (ROM) BIOS
interface module (file IBMBIO.COM)
provides a low-level interface to the ROM
BIOS device routines.

B-1

3.

The DOS program itself (file IBMDOS.COM)
provides a high-level interface for user
programs. It consists of file management
routines, data blocking/deblocking for the
disk routines, and a variety of built-infunctions easily accessible by user programs.
(Refer to Appendix D.)
When these function routines are invoked bya user program, they accept high-level
information via register and control block
contents, then (for device operations)translate the requirement into one or morecalls to IBMBIO to complete the request.

4.

The command processor, COMMAND. COM.

DOS Initialization
When the system is started (either System Reset or
power ON with the DOS diskette in drive A), theboot record is read into memory and given
control. It checks the directory to assure that thefirst two files listed are IBMBIO.COM andIBMDOS.COM, in that order. (An error message isissued if not.) These two files are then read intomemory. (IBMBIO.COM must be the first file inthe directory, and its sectors must be contiguous.)
The initialization code in IBMBIO.COM
determines equipment status, resets the disk
system, initializes the attached devices, causes
device drivers to be loaded, and sets the
low-numbered interrupt vectors. It then relocates
IBMDOS.COM downward and calls the first byte
of DOS.

B-2

As in IBMBIO.COM, offset 0 in DOS contains ajump to its initialization code, which will later beoverlaid by a data area and the commandprocessor. DOS initializes its internal working
tables, initializes interrupt vectors for interrupts
hex 20 through hex 27 and builds a Program
Segment Prefix (see Appendix E) for
COMMAND. COM at the lowest available segment,
then returns to IBMBIO.COM.
The last remaining task of initialization is for
IBMBIO.COM to load COMMAND. COM at thelocation set up by DOS initialization.
IBMBIO.COM then passes control to the first byte
of COMMAND.

The Command Processor
The command processor supplied with DOS (fileCOMMAND.COM) consists of four distinctly
separate parts:•

A resident portion resides in memory
immediately following IBMDOS. COM and its
data area. This portion contains routines toprocess interrupt types hex 22 (terminate
address), hex 23 (CTRL-BREAK handler), andhex 24 (critical error handling), as well as aroutine to reload the transient portion if
needed. (When a program terminates, achecksum methodology determines if the
program had caused the transient portion to
be overlaid. If so, it is reloaded.) Note that all
standard DOS error handling is done within
this portion of COMMAND. This includes
displaying error messages and interpreting the
reply of Abort, Retry, or Ignore. (See message
Disk error reading drive x under"Device Error Message" at the beginning ofChapter 8.)

B-3

•

An initialization portion follows the resident
portion and is given control during startup.
This section contains the AUTOEXEC fileprocessor setup routine. The initialization
portion determines the segment address at
which programs can be loaded. It is overlaid
by the first program COMMAND loads
because it's no longer needed.

•

A transient portion is loaded at the high endof memory. This is (portion 3) the commandprocessor itself, containing all of the internal
command processors, the batch file processor,and (portion 4) a routine to load and execute
external commands (files with filename
extensions of .COM or .EXE). This "loader" isat the highest end of memory, and is invokedby the EXEC function call to load programs.
Portion 3 of COMMAND produces the systemprompt (such as A», reads the commandfrom the keyboard (or batch file) and causes it
to be executed. For external commands, itbuilds a command line and issues an EXEC
function call to load and transfer control tothe program.

Appendix E contains detailed information
describing the conditions in effect when a programis given control by EXEC.

B-4

Available DOS Functions
DOS provides a significant number of functions touser programs, all available through issuance of aset of interrupt codes. There are routines for
keyboard input (with and without echo andCtrl-Break detection), console and printer output,
constructing file control blocks, memory
management, date and time functions, and avariety of disk, directory, and file handling
functions. See "DOS Interrupts and Function
Calls" in Appendix D for detailed information.

File Management Notes
Through the INT 21 (function call) mechanism,
DOS provides methods to create, read, write,
rename, and erase files. Files are not necessarily
written sequentially on disk-space is allocated as
it is needed, and the first location available on thedisk is allocated as the next location for a file
being written. Therefore, if considerable filecreation and erasure activity has taken place, newly
created files will probably not be written insequential sectors.
However, due to the mapping (chaining) of filespace via the File Allocation Table, and thefunction calls available, any file can be used ineither a sequential or random manner.

B-5

There are two sets of function calls that support
file management. The new, extended set of calls is
the preferred method (functions 39 through 57).
Through these calls, sequential and random fileaccesses are simpler than using the traditional(FCB oriented) set of calls. The FCB calls continue
to function as in the past: By using the current
block and current record fields of the FCB, and thesequential disk read or write functions, you canmake the file appear sequential-DOS will do thecalculations necessary to locate the proper sectors
on the disk. On the other hand, by using therandom record field, and random disk functions,
you can cause any record in the file to be accessed
directly-again, DOS will locate the correct sectors
on the disk for you.
Space is allocated in increments called clusters. For
single sided diskettes, this unit of allocation is one
sector; for dual sided diskettes, each cluster is twoconsecutive sectors in length. The cluster size of a
fixed disk is determined at FORMAT time, and isbased on the size of the DOS partition.

The Disk Transfer Area (DTA)
The Disk Transfer Area (also commonly calledbuffer) is the memory area DOS will use to containthe data for all file reads and writes that are
performed with the traditional (FCB) set offunction calls. This area can be at any location
within memory, and should be set by yourprogram. (See function call hex lA.)

B-6

Only one DTA can be in effect at a time, so it is
the program's responsibility to inform DOS what
memory location to use before using any disk reador write functions. Once set, DOS continues to usethat area for all disk operations until anotherfunction call hex 1A is issued to define a new DTA.
When a program is given control by COMMAND,a default DTA has already been established athex 80 into the program's Program Segment
Prefix, large enough to hold 128 bytes.
When using the extended file management
function calls, you specify a buffer address when
you issue the read or write call. There is no need to
set a DTA address.

Error Trapping
DOS provides a method by which a program canreceive control whenever a disk or device
read/write error occurs, or when a bad memory
image of the file allocation table is detected. Whenthese events occur, DOS executes an INT hex 24
to pass control to the error handler. The default
error handler resides in COMMAND.COM, but
any program can establish its own by setting theINT hex 24 vector to point to the new error
handler. DOS provides error information via theregisters and provides Abort, Retry, or Ignore
support via return codes. (Refer to Appendix D"DOS Interrupts and Function Calls".)

B-7

Notes:B-8

Appendix C. DOS Disk Allocation

All disk and diskettes formatted by DOS are
created with a sector size of 512 bytes. The DOS
area (entire diskette for diskettes, DOS partition
for fixed disks) is formatted as follows:

Boot record - variable size
First copy of file allocationtable - variable size
Second copy of file allocationtable - variable size
Root directory - variable size
Data area

Allocation of space for a file (in the data area) isdone only when needed (it is not pre-allocated).
The space is allocated one cluster (unit ofallocation) at a time. A cluster is always one ormore consecutive sectors, and all of the clusters
for a file are" chained" together in the File
Allocation Table.

C-l

The clusters are arranged on disk to minimize head
movement for multi-sided media. All of the space
on a track (or cylinder) is allocated before moving
on to the next track. This is accomplished by using
the sequential sectors on the lowest-numberedhead, then all the sectors on the next head, and soon until all sectors on all heads of the track areused. Then, the next sector to be used will be
sector 1 on head 0 of the next track.
For fixed disk, the size of the file allocation tableand directory are determined when FORMAT
initializes it, and are based on the size of the DOS
partition.
For diskettes, the following table can be used:

#
Sides
1
2
1
2

Sectors/
Track

FAT size
Sectors

Dir
Dir
Sectors/
Sectors Entries Cluster

8
8

1
1
2
2

4

64

7

112

4

64

7

112

9
9

1
2
1
2

Files in the data area are not necessarily written
sequentially on the disk. The data area space isallocated one cluster at a time, skipping overclusters already allocated. The first free cluster
found will be the next cluster allocated, regardlessof its physical location on the disk. This permits
the most efficient utilization of disk space because
clusters made available by erasing files can beallocated for new files. (Refer to the description ofthe "DOS File Allocation Table".)C2

DOS Disk Directory
FORMAT initially builds the root directory for all
disks. Its location (logical sector number) and the
maximum number of entries are available throughthe device driver interfaces.
Since directories other than the root directory are
actually files, there is no limit to the number of
entries they may contain. Sub-directories can beread as data files, using an extended FeB with theappropriate attribute byte.
All directory entries are 32 bytes in length, and arein the following format (byte offsets are indecimal):0-7

Filename. The first byte of this fieldindicates its status.
hex 00

Never been used. This is used tolimit the length of directory
searches, for performancereasons.

hex E5

Was used, but the file has beenerasedhex 2 EThe entry is for a directory. If
the second byte is also hex 2 E,
then the cluster field contains
the cluster number of thisdirectory's parent directory (hex0000 if the parent directory is
the root directory).

Any other character is the first characterof a filename.

C-3

C-4

8-10

Filename extension.

11

File attribute. The attribute byte ismapped as follows (values are inhexadecimal) :01

File is marked read-only. An attempt
to open the file for output using
function call hex 3 D results in anerror code being returned. Thisvalue can be used along with othervalues below.

02

Hidden file. The file is excluded
from normal directory searches.

04

System file. The file is excluded
from normal directory searches.

08

The entry contains the volume label
in the first 11 bytes. The entry
contains no other usable
information, and may exist only inthe root directory.

10

The entry defines a sub-directory,
and is excluded from normal
directory searches.

20

Archive bit. The bit is set on
whenever the file has been written to
and closed. It is used by
backup/ restore functions of the
FDISK utility for determining
whether or not the file was changed
since it was last backed up. This bit
can be used along with otherattribute bits.

Note: The system files (IBMBIO.COM
and IBMDOS.COM) are marked as read
only, hidden, and system files. Files canbe marked hidden when they are created.
Also, the read-only, hidden, system, andarchive attributes may be changed
through the CHMOD function call.
12-21

Reserved.

22-23

Time the file was created or last updated.
The time is mapped in the bits as follows:
hh
> <
mm
> < xx >15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0<

where:
hh is the binary number of hours (0-23)
mm is the binary number of minutes(0-59)
xx is the binary number of two-second
increments
24-25

Date the file was created or last updated.
The mm/ddlyy are mapped in the bits asfollows:

<

25
> <
24
>
15 14 1 3 12 11 10 9' 8 7 6 5 4 3 2 1 0
Y Y Y Y Y Y ymmmmddddd

where:
mm is 1-12
dd is 1-31
yy is 0-119 (1980-2099)

C-5

26-27

Starting cluster; the relative cluster
number of the first cluster in the file.
Note that the first cluster for data spaceon all fixed disks and diskettes is always
cluster 002.
The cluster number is stored with theleast significant byte first.
Note: System programmers, see"DOS File Allocation Table" fordetails about converting cluster
numbers to logical sector numbers.

28-31

File size in bytes. The first word contains
the low-order part of the size. Both words
are stored with the least significant byte
first.

DOS File Allocation Table
This information is presented for the benefit ofsystem programmers who wish to develop device
drivers. It explains how DOS uses the File
Allocation Table to convert the clusters of a file tological sector numbers. The driver is thenresponsible for locating the logical sector on disk.
We wish to emphasize that this information should
not be used for any other purpose. We
recommend that system utilities use the DOS file
management function calls rather thaninterpreting the FAT.

C6

The File Allocation Table (FAT) is used by DOS toallocate disk space for a file, one cluster at a time.
The FAT consists of a 12-bit entry (1.5 bytes) for
each cluster on the disk.
Note that the first two FAT entries map a portionof the directory; these FAT entries contain
indicators of the size and format of the disk.
The second and third bytes always contain hex
FFFF. The first byte is used as follows:
Hex Value

Meaning

FF

Dual sided, 8 sector- per- track
diskette.

FE

Single sided, 8 sector-per-track
diskette.

FD

Dual sided, 9 sector-per-track
diskette.

Fe

Single sided, 9 sector-per-track
diskette.

F8

Fixed disk

The third FAT entry begins the mapping of thedata area (cluster 002).

C-7

Each entry contains three hexadecimal characters,either:000

if the cluster is unused and available,orFFs-FFFto indicate the last cluster of a file,orxxx

any other hexadecimal charactersthat are the cluster number of thenext cluster in the file. The cluster
number of the first cluster in the file
is kept in the file's directory entry.
Note: The values FFO-FF7 areused to indicate reserved
clusters (FF7 indicates a badcluster if it is not part of an
allocation chain), and FFS-FFF
are used as end-of-file marks.

The File Allocation Table always begins on logicalsector 1 (second actual sector on a diskette or in a
fixed disk partition), following the boot record. Iflarger than 1 sector, the sectors are contiguous.
Two copies of the FAT are written, one following
the other, for integrity. The FAT is read into oneof the DOS buffers whenever needed (open,
allocate more space, etc.), and that buffer is given
a high priority to keep it in memory as long as
possible, for performance reasons.

C-8

How to Use the File Allocation Table
Obtain the starting cluster of the file from thedirectory entry.
Now, to locate each subsequent cluster of the file:1.

Multiply the cluster number just used by 1.5(each FAT entry is 1.5 bytes long).

2.

The whole part of the product is an offset into
the FAT, pointing to the entry that maps thecluster just used. That entry contains thecluster number of the next cluster of the file.

3.

Use a MOV instruction to move the word at
the calculated FAT offset into a register.

4.

If the last cluster used was an even number,keep the low-order 12 bits of the register;otherwise, keep the high-order 12 bits.

5.

If the resultant 12 bits are hex FF8-FFF, there
are no more clusters in the file. Otherwise,
the 12 bits contain the cluster number of thenext cluster in the file.

To convert the cluster to a logical sector number(relative sector, such as that used by INT 25 and26 and by DEBUG):
1.

Subtract 2 from the cluster number.

2.

Multiply the result by the number of sectors
per cluster.

3.

Add the logical sector number of the
beginning of the data area.

C-9

Notes:C-IO

Appendix D. DOS Interrupts andFunction Calls

Interrupts
Note: We recommend that a program
wishing to examine or set the contents of any
interrupt vector use the DOS function calls(hex 35 and hex 25) provided for those
purposes, and avoid referencing the interrupt
vector locations directly.
DOS reserves interrupt types hex 20 to hex 3F for
its use. This means absolute memory locations
hex 80 to hex FF are reserved by DOS. The
defined interrupts are as follows with all values inhexadecimal.
20

Program terminate. Issuing Interrupt
hex 20 is the traditional way to exit froma program. This vector transfers to thelogic in DOS for restoration of theterminate, Ctrl-Break, and critical error
exit addreses to the values they had on
entry to the program. All file buffers areflushed. All files changed in length should
be closed (see function call hex 10 andhex 3E) prior to issuing this interrupt. If
the changed file is not closed, its length,
date, and time are not recorded correctlyin the directory.

0.1

In order for a program to pass acompletion (or error) code whenterminating, it must use either function
call hex 4C (exit) or hex 31 (terminate
and stay resident). These two new
methods are preferred over using
interrupt hex 20, and the codes returnedby them can be interrogated in batchprocessing (see ERRORLEVEL
subcommand of batch processing).
Important: Every program must ensurethat the CS register contains the segment
address of its Program Segment Prefix
control block prior to issuing interrupt
hex 20.

D-2

21

Function request. Refer to "Function
Calls" in this appendix.

22

Terminate address. The address found at
this interrupt location is the address towhich control transfers when the
program terminates. This address iscopied into the program's Program
Segment Prefix at the time the segment
is created. If a program wishes to executea second program it must set theterminate address prior to issuing the
EXEC function call to execute the newprogram. Otherwise, when the second
program executes, its termination would
cause transfer to its host's termination
address. This address, as well as theCtrl-Break address below, may be set via
DOS function call hex 25. Do not issue
this interrupt directly.

23

Ctrl-Break exit address. If the user enters
Ctrl-Break during screen, printer, or
asynchronous communications adapter
operations, an interrupt type hex 23 is
executed. (If BREAK is on, the interrupt
hex 23 is issued on any function call.) If
the Ctrl-Break routine saves all registers,
it may end with a return-from-interrupt
instruction (IRET) to continue program
execution. If the program returns with along return, the carry flag is used todetermine whether the program will be.aborted or not; if the carry flag is set, it
will be aborted, otherwise execution
will continue (as with a return by IRET).
If the Ctrl-Break interrupts functions
9 or 10, buffered I/O, then /\ C,carriage-return, and linefeed are output.
If execution is then continued with an
IRET, I/O continues from the start of theline. When the interrupt occurs, allregisters are set to the value they had
when the original function call to DOS
was made. There are no restrictions onwhat the Ctrl-Break handler is allowed todo, including DOS function calls, as longas the registers are unchanged if IRET
is used.
If the program creates a new segment andloads in a second program which itself
changes the Ctrl-Break address, thetermination of the second program andreturn to the first causes the Ctrl-Breakaddress to be restored to the value it had
before execution of the second program.
(I t is restored from the second program's
Program Segment Prefix.)

D-3

24

Critical error handler vector. When acritical error occurs within DOS, control
is transferred with an interrupt 24H. On
entry to the error handler, AH will haveits bit 7=0 (high-order bit) if the error
was a disk error (probably the mostcommon occurrence), bit 7=1 if not.
BP:SI contains the address of a Device
Header Control Block from which
additional information can be retrieved(see below).

.

The registers will be set up for a retry
operation, and an error code will be in
the lower half of the DI register with theupper half undefined. These are the error
codes:
Error Code

o
1
2
3
4
5

6
7
8

9
A
B
C

D-4

Description
Attempt to write on
write-protected diskette
Unknown unit
Drive not ready
Unknown command
Data error (CRC)
Bad request structure
lengthSeek error
Unknown media type
Sector not found
Printer out of paper
Write fault
Read fault
General failure

The user stack will be in effect (the first
item described below is at the top of thestack), and will contain the following
from top to bottom:

IP
CS
FLAGS

AX
BX

DOS registers from issuing
INT hex 24

User registers at time of original
INT hex 21 request

ex

DX
SI
DI

BP
DS

ES
IP

From the original interrupt
hex 21 from the user to DOS

es
FLAGS

The registers are set such that if an IRET
is executed, DOS will respond according
to (AL) as follows:(AL)=O

ignore the error.

=1

retry the operation.

=2

terminate the program throughinterrupt hex 23.

D-5

Disk Errors
If it is a hard error on disk (AH bit 7=0), registerAL contains the failing drive number (0 = drive A,etc.); AH bits 0-2 indicate the affected disk area
and whether it was a read or write operation, as
follows:
Bit 0=0 if read operation,
1 if write operation
Bits 2-1 (affected disk area)o 0 DOS area (system files)o 1 file allocation table
1 0 directory
1 J data area

Other Errors
If AH bit 7=1, then the error occurred on acharacter device, or was the result of a badmemory image of the FAT. The device header
passed in BP: SI can be examined to determine
which case exists. If the attribute byte high order
bit indicates a block device, then the error was a
bad FAT. Otherwise, the error is on a character
device.
If a character device, the contents of AL areunpredictable, the error code is in DI as above.

D-6

Notes:1.

Before giving this routine control fordisk errors, DOS performs five retries.

2.

For disk errors, this exit is taken only forerrors occurring during an interrupt hex
21 function call. It is not used for errors
during an interrupt hex 25 or hex 26.

3.

This routine is entered in a disabled state.

4.

The SS, SP, DS, ES, BX, ex, and DX
registers must be preserved.

5.

This interrupt handler should refrainfrom using DOS function calls. If
necessary, it may use calls 1 through 12.
Use of any other call will destroy the
DOS stack and will leave DOS in an
unpredictable state.

6.

The interrupt handler must not change
the contents of the device header.

7.

If the interrupt handler will handle errors
itself rather than returning to DOS, it
should restore the application program's
registers from the stack, remove all but
the last 3 words on the stack, then issue
an IRET. This will return to the program
immediately after the INT 21 thatexperienced the error. Note that if this isdone, DOS will be in an unstable state
until a function call higher than 12 isissued.

D-7

The device header pointed to by BP:SI isformatted as follows:
DWORD Pointer to next device(FFFF if last device)
WORD Attributes
Bit 15 = 1 if character device, 0 if block
ifbit 15 is 1
Bit 0 = 1 if Current standard input
Bit 1 = 1 if Current standard output
Bit 2 = 1 if Current NUL device
Bit 3 = 1 if Current CLOCK device
Bit 14 is the IOCTL bit
WORD Pointer to Device driver strategy
entry point
WORD Pointer to Device driver interrupt
entry point
8-BYTE character device named field
for block devices the first byte is
the number of units
To tell if the error occurred on a block or
character device you must look at bit 15
in the attribute field (WORD at
BP:SI+4).
If the name of the character device isdesired, look at the eight bytes startingat BP:SI+10.

D-8

25

Absolute disk read. This transfers
control directly to the DOS BIOS. Upon
return, the original flags are still on thestack (put there by the INT instruction).
This is necessary because return
information is passed back in the current
flags. Be sure to pop the stack to prevent
uncontrolled growth. The request is asfollows:(AL)

Drive number (for example,
O=A or l=B)

(eX)
(DX)

Number of sectors to read
Beginning logical sector
number(DS:BX) Transfer address

The number of sectors specified aretransferred between the given drive andthe transfer address. Logical sector numbers
are obtained by numbering each sector
sequentially starting from track 0, head 0,
sector 1 (logical sector 0) and continuingalong the same head, then to the next
head until the last sector on the last headof the track is counted. Thus, logicalsector 1 is track 0, head 0, sector 2;
logical sector 2 is track 0, head 0, sector
3; and so on. Numbering then continues
with sector 1 on head of the next track.
Note that although the sectors aresequentially numbered (for example,
sectors 2 and 3 on track in the example
above), they may not be physicallyadjacent on disk, due to interleaving.
Note that the mapping is different fromthat used by DOS Version 1.10 fordual-sided diskettes.

°

°

D-9

All registers except the segment registers
are destroyed by this call. If the transfer
was successful the carry flag (CF) will be
zero. If the transfer was not successful
CF=l and (AX) will indicate the error as
follows. (AL) is the DOS error code thatis the same as the error code returned in
the low byte of DI when an INT hex 24 isissued, and (AH) will contain:hex 80hex 40hex 20hex 10hex 08hex 04hex03
hex 02hex 00

D-IO

Attachment failed torespond
SEEK operation failed
Controller failure
Bad CRC on diskette read
DMA overrun on operation
Requested sector not foundWrite attempt on
write-protected diskette
Address mark not foundError other than types
listed above

26

Absolute disk write. This vector is thecounterpart of interrupt 25 above.
Except for the fact that this is a write, thedescription above applies.

27

Terminate but stay resident. This vector
is used by programs that are to remain
resident when COMMAND regains
control. This is the traditional method
for DOS programs to remain resident
upon termination.

A new DOS function call has been
established that allows the terminating
program to pass a completion (or error)
code to DOS, that can be interpreted
within batch processing (see function callhex 31). After initialiZing itself, theprogram must set DX to its last addressplus one in the segment in which it isexecuting (the offset at which otherprograms can be loaded), then execute an
INT 27 H. DOS then considers the
program as an extension of DOS, so theprogram is not overlaid when otherprograms are executed. This concept isvery useful for loading programs such as
user-written interrupt handlers that mustremain resident.
Notes:
1.

This interrupt must not be used
by .EXE programs which areloaded into the high end ofmemory.

2.

This interrupt restores theinterrupt 22, 23, and 24 vectors
in the same manner as INT 20.
Therefore, it can not be used to
install permanently resident
Ctrl-Break or Critical Error
Handler routines.

3.

The maximum size of memorythat can be made resident by
this method is 64K. You can use
call hex 31 to make a larger
program resident.

D-l1

28

Used internally by DOS.

29-2E

Reserved for DOS.

2F

Used internally by DOS.

30- 3 F

Reserved for DOS.

Function Calls
DOS provides a wide variety of function calls forcharacter device VO, file management, memory
management, date and time functions, executionof other programs, and others. They are grouped
as follows (call numbers are in hexadecimal):

D-12

0-12

Traditional character device VO

12-24

Traditional file management

25-26

Traditional non-device functions

27-29

Traditional file management

2A-2E

Traditional non-device functions

2F-38

Extended function group

39-3B

Directory group

3C-46

Extended file management group

47

Directory group

4S-4B

Extended memory management group

4C-4F

Extended function group

54-57

Extended function group

Functions 2 F through 57 are new for DOS Version
2.00. Where similar functions exist in both thisgroup and the group of traditional calls, werecommend using the new calls. They have been
defined with simpler interfaces and provide more
powerful functions than their traditionalcounterparts. However, if you use these newfunction calls your program cannot be run on DOS
Versions 1.00 or 1.10.
When DOS takes control, it switches to an internal
stack. User registers are preserved unless
information is passed back to the requester as
indicated in the specific requests. The user stackneeds to be sufficient to accommodate theinterrupt system. It is recommended that it behex so in addition to the user needs.

D-13

Error Return Table
Many of the new function calls return the carryflag clear if the operation was successful. If anerror condition was encountered, the carry flag isset, and AX contains one of the following binary
error return codes:
Code Condition
1
2

3
4
5
6
7
8

9
10
11
12
13
15
16
17
18

Invalid function number
File not found
Path not foundToo many open files (no handles left)
Access denied
Invalid handle
Memory control blocks destroyed
Insufficient memory
Invalid memory block address
Invalid environment
Invalid format
Invalid access code
Invalid data
Invalid drive was specified
Attempted to remove the current directory
Not same device
No more files

Several of the calls accept an ASCIZ string as
input. This consists of an ASCII string containing
an optional drive specifier, followed by a directory
path, and in some cases a filename. The string isterminated by a byte of binary zeros. For example:
B:\ LEVELl\ LEVEL2\FI LEl

followed by a byte of zeros.
Note: All calls that accept path names will
accept a forward slash or a backslash as a path
separator character.

D-14

The new calls supporting files or devices use an
identifier known as a "handle." When you createor open a file or device with the new calls, a 16-bit
binary value is returned in AX. This is the"handle" (sometimes known as a token) that you
will use in referring to the file after it's been
opened.
The following handles are pre-defined by DOS andcan be used by your program. You do not need toopen them before using them:
0000

Standard input device. Input can be
redirected.

0001

Standard output device. Output can be
redirected.

0002

Standard error output device. Output
cannot be redirected.

0003

Standard auxiliary device.

0004

Standard printer device.

D-15

Invoking DOS Functions
Most of the function calls require input to bepassed to them in registers. After setting theproper register values, the function may be
invoked in one of these ways:

D-16

1.

Place the function number in AH and executea long call to offset hex 50 in your Program
Segment Prefix. Note that programs using
this method will not operate correctly on
DOS Verisons 1.00 and 1.10.

2.

Place the function number in AH and issue
interrupt type hex 21.

3.

There is an additional mechanism provided
for pre-existing programs that were writtenwith different calling conventions. Thismethod should be avoided for all new
programs. The function number is placed in
the CL register and other registers are set
according to the function specification. Then
an intrasegment call is made to location 5 inthe current code segment. That location
contains a long call to the DOS function
dispatcher. Register AX is always destroyed if
this mechanism is used; otherwise, it is thesame as normal function calls. This method isvalid only for function calls 0- 24(hexadecimal) .

The functions are as follows with all values inhexadecimal.

oProgram terminate. The terminate,Ctrl-Break, and critical error exit addresses
are restored to the values they had on entry to
the terminating program, from the values
saved in the Program Segment Prefix. All filebuffers are flushed, but any files which havebeen changed in length but not closed will not
be recorded properly in the directory. Control
transfers to the terminate address. This callperforms exactly the same function as INT
20H. It is the program's responsibility toensure that the CS register contains thesegment address of its Program Segment
Prefix control block prior to calling thisfunction.
Note: Calls hex 1 through hex C use thestandard devices listed at the end of the"Error Return Table" in this chapter.

1

Keyboard input. Waits for a character to beread at the standard input device (unless one
is ready), then echoes the character to thestandard output device and returns it in AL.
The character is checked for a Ctrl-Break. If
Ctrl-Break is detected, an interrupt hex 23 is
executed.
Note: For functions 1, 6, 7, and 8,
extended ASCII codes will require twofunction calls. (See the IBM Personal
Computer BASIC manual for a
description of the extended ASCII
codes.) The first call returns 00 as anindicator that the next call will return anextended code.

D-17

2

Display output. The character in DL is output
to the standard output device. The backspacecharacter results in moving the cursor left one
position, writing a space at this position andremaining there. If a Ctrl-Break is detected
after the output, an interrupt hex 23 is
executed.

3

Auxiliary (Asynchronous Communications
Adapter) input. Waits for a character from thestandard auxiliary device, then returns thatcharacter in AL.
Notes:

D-18

1.

Auxiliary (AUX, COM1, COM2)
support is unbuffered andnon-interrupt driven.

2.

At startup, DOS initializes the first
auxiliary port to 2400 baud, noparity, one stop bit, and 8-bit word.

3.

The auxiliary function calls (3 and 4)
do not return status or error codes.
For greater control, it isrecommended that the ROM BIOS
routine (INT hex 14) be used.

4

Auxiliary (Asynchronous Communications
Adapter) output. The character in DL is
output to the standard auxiliary device.

5

Printer output. The character in DL is output
to the standard printer device.

6

Direct console I/O. If DL is hex FF, AL
returns with the zero flag clear and an input
character from the standard input device if
one is ready. If a character is not ready, thezero flag will be set. If DL is not hex FF, thenDL is assumed to have a valid character that is
output to the standard output device. Thisfunction does not check for Ctrl-Break, or
Ctrl-PrtSc.
7

Direct console input without echo. Waits fora character to be read at the standard input
device (unless one is ready), then returns thecharacter in AL. As with function 6, no checks
are made on the character.

8

Console input without echo. This function is
identical to function 1, except the key is notechoed.

9

Print string. On entry, DS:DX must point to acharacter string in memory terminated by a $(hex 24). Each character in the string will be
output to the standard output device in thesame form as function 2.

A

Buffered keyboard input. On entry, DS:DX
point to an input buffer. The first byte mustnot be zero and specifies the number ofcharacters the buffer can hold. Characters areread from the standard input device andplaced in the buffer beginning at the thirdbyte. Reading the standard input device andfilling the buffer continues until Enter is read.
If the buffer fills to one less than the
maximum number of characters it can hold,then each additional character read is ignoredand causes the bell to ring, until Enter is read.
The second byte of the buffer is set to thenumber of characters received, excluding thecarriage return (hex OD), which is always thelast character. Editing of this buffer is
described in Chapter 3.

D-19

D-20

B

Check standard input status. If a character isavailable from the standard input device, AL
will be hex FF. Otherwise, AL will be 00. If
a Ctrl-Break is detected, an interrupt typehex 23 is executed.

C

Clear standard input buffer and invoke astandard input function. Clear the standard
input buffer of any pre-typed characters, thenexecute the function number in AL (only 1, 6,
7, 8, and A are allowed). This forces thesystem to wait until a character is typed.

D

Disk reset. Flushes all file buffers. Fileschanged in size but not closed are notproperly recorded in the disk directory. Thisfunction need not be called before a diskettechange if all files written have been closed.

E

Select disk. The drive specified in DL (O=A,
l=B, etc.) is selected (if valid) as the default
drive. The number of drives (total of disketteand fixed disk drives) is returned in AL. If thesystem has only one diskette drive, it will becounted as two to be consistent with thephilosophy of thinking of the system as
having logical drives A and B. BIOS
equipment determination (INT IlH) can beused as an alternative method, returning theactual number of physical diskette drives.

F

Open file. On entry, DS:DX point to a
current unopened file control block (FCB).
The directory is searched for the named fileand AL returns hex FF if it is not found. If it isfound, AL returns 00 and the FCB is filled asfollows:
If the drive code was 0 (default drive), it ischanged to the actual drive used (l=A, 2=B,etc.). This allows changing the default drive
without interfering with subsequent
operations on this file. The current block field(FCB bytes C-D) is set to zero. The size of therecord to be worked with (FCB bytes E-F) is
set to the system default of hex 80. The sizeof the file and the date are set in the FCB
from information obtained from thedirectory.
It is your responsibility to set the record size
(FCB bytes E- F) to the size you wish to thinkof the file in terms of, if the default hex 80 is
insufficient. It is also your responsibility to set
the random record field and/or current record
field. These actions should be done after open
but before any disk operations are requested.

10

Close file. This function must be called after
file writes to ensure all directory information
is updated. On entry, DS:DX point to an
opened FCB. The current disk directory is
searched and if the file is found, its position iscompared with that kept in the FCB. If thefile is not found in its correct position in thecurrent directory, it is assumed the diskette
was changed and AL returns hex FF.
Otherwise, the directory is updated to reflect
the status in the FCB and AL returns 00.

D-21

11

Search for the first entry. On entry, DS:DX
point to an unopened FCB. The current disk
directory is searched for the first matching
filename (name could have "?"s indicating any
letter matches) and if none are found, AL
returns hex FF. Otherwise, AL returns 00 andthe locations at the disk transfer address are
set as follows:
If the FCB provided for searching was anextended FCB, then the first byte at thedisk transfer address is set to hex FF,
followed by five bytes of zeros, then theattribute byte from the search FCB, thenthe drive number used (l=A, 2=B, etc.),
then the 32 bytes of the directory entry.
Thus, the disk transfer address contains avalid unopened extended FCB with thesame search attributes as the search FCB.
If the FCB provided for searching was anormal FCB, then the first byte is set to thedrive number used (l=A, 2=B), and the next
32 bytes contain the matching directory entry.
Thus, the disk transfer address contains a valid
unopened normal FCB.
Notes:
If an extended FCB is used, thefollowing search pattern is used:
1.

D-22

If the FCB attribute byte is zero,
only normal file entries are found.
Entries for volume label,
sub-directories, hidden and systemfiles, will not be returned.

2.

If the attribute field is set for hidden
or system files, or directory entries,
it is to be considered as an inclusive
search. All normal file entries plus all
entries matching the specified
attributes are returned. To look at
all directory entries except thevolume label, the attribute byte may
be set to hidden + system + directory(all 3 bits on).

3.

If the attribute field is set for thevolume label, it is considered an
exclusive search, and only the volume
label entry is returned.

The attribute bits are defined in the "DOSDisk Directory" section of Appendix C.
12Search for the next entry. After function 11
has been called and found a match, function
12 may be called to find the next match to an
ambiguous request (?s in the search filename).
Both inputs and outputs are the same asfunction 11. The reserved area of the FCB
keeps information necessary for continuing
the search, so no disk operations may be
performed with this FCB between a previous
function 11 or 12 call and this one.

13

Delete file. On entry, DS:DX point to an
unopened FCB. All matching current
directory entries are deleted. If no directory
entries match, AL returns hex FF, otherwise
AL returns 00.

D-23

D-24

14

Sequential read. On entry, DS:DX point to an
opened FCB. The record addressed by thecurrent block (FCB bytes C-D) and thecurrent record (FCB byte 1 F) is loaded at thedisk transfer address, then the record address
is incremented. (The length of the record isdetermined by the FCB record size field.) If
end-of-file is encountered, AL returns either
01 or 03. A return of 01 indicates no data in
the record; 03 indicates a partial record is readand filled out with zeros. A return of 02
means there was not enough space in the disk
transfer segment to read one record, so thetransfer was ended. AL returns 00 if thetransfer was completed successfully.

15

Sequential write. On entry, DS:DX point toan opened FCB. The record addressed by thecurrent block and current record fields (sizedetermined by the FCB record size field) is
written from the disk transfer address (or, inthe case of records less than sector sizes, isbuffered up for an eventual write when asector's worth of data is accumulated). The
record address is then incremented. If thediskette is full, AL returns 01. A return of 02
means there was not enough space in the disk
transfer segment to write one record, so thetransfer was ended. AL returns 00 if thetransfer was completed successfully.

16

Create file. On entry, DS:DX point to an
unopened FCB. The current disk directory is
searched for a matching entry, and if found, it
is re-used. If no match was found, thedirectory is searched for an empty entry, andAL returns FF if none is found. Otherwise, theentry is initialized to a zero-length file, the fileis opened (see function F), and AL returns 00.
The file may be marked hidden during its
creation by using an extended FCB containing
the appropriate attribute byte.

17

Rename file. On entry, DS:DX point to amodified FCB which has a drive code and afile name in the usual position, and a second
file name starting 6 bytes after the first(DS:DX+hex 11) in what is normally areserved area. Every matching occurrence ofthe first name in the current directory ischanged to the second (with the restrictionthat two files cannot have the same name andextension). If "?"s appear in the second name,then the corresponding positions in theoriginal name will be unchanged. AL returns
FF if no match was found or if an attempt wasmade to rename to a filename that alreadyexisted, otherwise 00.

18

Used internally by DOS.

D-25

19

Current disk. AL returns with the code of thecurrent default drive (O=A, I=B, etc.). 'lA Set disk transfer address. The disk transfer
address is set to DS:DX. DOS does not allow
disk transfers to wrap around within thesegment, or overflow into the next segment.
1 B Allocation table information. On return,
DS:BX point to a byte containing the FAT
identification byte for the default drive, DX
has the number of allocation units, AL has thenumber of sectors per allocation unit, and CX
has the size of the physical sector.
Note:

Beginning with DOS Version

2.00, this call no longer returns theaddress of a complete File Allocation
Table, because the FAT's are no longer
kept resident in memory.
1 C Allocation table information for specificdrive. This call is identical to call hex 1 B
except that on entry, DL contains the numberof the drive from which the information
should be gotten (0 = default, 1= A, etc.).
ID Used internally by DOS.

D-26

IE

Used internally by DOS.

1F

Used internally by DOS.

20

Used internally by DOS.

21

Random read. On entry, DS:DX point to an
opened FeB. The current block and current
record fields are set to agree with the random
record field, then the record addressed bythese fields is read into memory at the current
disk transfer address. If end-of-file isencountered, AL returns either 01 or 03. If 01
is returned, no more data is available. If 03 isreturned, a partial record is available filled out
with zeros. A return of 02 means there was
not enough space in the disk transfer segment
to read one record, so the transfer was ended.
AL returns 00 if the transfer was completed
successfully.

22

Random write. On entry, DS:DX point to an
opened FeB. The current block and current
record fields are set to agree with the random
record field, then the record addressed bythese fields is written (or in the case of records
not the same as sector sizes - buffered) fromthe disk transfer address. If the diskette is full
AL returns 01. A return of 02 means there was
not enough space in the disk transfer segment
to write one record; so, the transfer wasended. AL returns 00 if the transfer wascompleted successfully.

23

File size. On entry, DS:DX point to an
unopened FeB. The diskette directory is
searched for the first matching entry and if
none is found, AL returns FF. Otherwise, therandom record field is set to the number ofrecords in the file (in terms of the record size
field rounded up) and AL returns 00.
Note: Be sure to set the FeB record
size field before using this function call;otherwise, erroneous information will be
returned.

D-27

24

Set random record field. On entry, DS:DX
point to an opened FCB. This function sets
the random record field to the same fileaddress as the current block and record fields.

25

Set interrupt vector. The interrupt vector
table for the interrupt type specified in AL is
set to the 4- byte address contained in DS: DX.
Note that the original contents of theinterrupt vector can be obtained through callhex 35.

26

Create a new program segment. On entry, DX
has a segment number at which to set up a
new program segment. The entire hex 100
area at location zero in the current program
segment is copied into location zero in the
new program segment. The memory size
information at location 6 in the new segment
is updated and the current termination,
Ctrl-Break exit and critical error addresses
from interrupt vector table entries forinterrupt types 22, 23, and 24 are saved in the
new program segment starting at hex OA.
They are restored from this area when the
program terminates.
Note: Use of this call should be
avoided, now that DOS contains the
EXEC function call (hex 4B).

D-28

27

Random block read. On entry, DS:DX point
to an opened FeB, and ex contains a record
count that must not be zero. The specified
number of records (in terms of the record size
field) are read from the file address specified
by the random record field into the disk
transfer address. If end-of-file is reached
before all records have been read, AL returns
either 01 or 03. A return of 01 indicates
end-of-file and the last record is complete. A
return of 03 indicates the last record is apartial record. If wrap-around above address
hex FFFF in the disk transfer segment would
have occurred, as many records as possible areread and AL returns 02. If all records are read
successfully, AL returns 00. In any case, ex
returns with the actual number of records
read, and the random record field and thecurrent block! record fields are set to address
the next record (the first record not read).

28

Random block write. Essentially the same asfunction 27 above, except for writing and awrite-protect check. If there is insufficientspace on the disk, AL returns Oland norecords are written. If ex is zero upon entry,
no records are written, but the file is set tothe length specified by the random record
field, whether longer or shorter than thecurrent file size. (Allocation units are releasedor allocated as appropriate.)

D-29

29

Parse filename. On entry, DS:SI point to acommand line to parse, and ES:DI point to a
portion of memory to be filled with anunopened FCB. The contents of AL are used
to determine the action to take, as shown
below:

bit:<ignored>7 6 5 43 2

1

0

If bit 0 = 1, then leading separators arescanned off the command line at DS: SI.
Otherwise, no scan-off of leading separators
takes place.
If bit 1 = 1, then the drive ID byte in the result
FCB will be set (changed) only if a drive wasspecified in the command line being parsed.
If bit 2 = 1, then the filename in the FCB will
be changed only if the command line contains
a filename.
If bit 3 = 1, then the filename extension in the
FCB will be changed only if the command line
contains ,a filename extension.
Filename separators include the following
characters: . ;, = + plus TAB and SPACE.
Filename terminators include all of thesecharacters plus \, <, >, I , /, ", [, ], and any
control characters.
The command line is parsed for a filename of
the form d: filename. ext, and if found, acorresponding unopened FCB is created at
ES:DI. If no drive specifier is present, thedefault drive is assumed. If no extension ispresent, it is assumed to be all blanks. If thecharacter * appears in the filename orextension, then it and all remaining charactersin the name or extension are set to ?.
D-30

If either? or * appears in the filename orextension, AL returns 01; if the drive specifier
is invalid AL returns FF; otherwise 00.
DS:SI will return pointing to the firstcharacter after the filename and ES:DI will
point to the first byte of the formatted FCB.
If no valid filename is present, ES:DI+1 willcontain a blank.
Note: This call is not useful forcommand lines containing path names.
2A Get date. Returns date in CX:DX. CX has
the year (1980-2099 in binary), DR has themonth (1-Jan, 2-Feb, etc.) and DL has the day.
If the time-of-day clock rolls over to the nextday, the date is adjusted accordingly, taking
into account the number of days in eachmonth and leap years.
2B Set date. On entry, CX:DX must have a valid
date in the same format as returned byfunction 2A, above. If the date is indeed valid
and the set operation is successful, AL returns
00. If the date is not valid, AL returns FF.
2C Get time. Returns with time-of-day in
CX:DX. Time is actually represented as four
8-bit binary quantities as follows. CR has thehours (0-23), CL has minutes (0-59), DR has
seconds (0-59), DL has 1/100 seconds (0-99).
This format is readily converted to a printableform yet can also be used for calculations,such as subtracting one time value fromanother.
2D Set time. On entry, CX:DX has time in thesame format as returned by function 2C,
above. If any component of the time is not
valid, the set operation is aborted and AL
returns FF. If the time is valid, AL returns 00.

D-31

2E Set/reset verify switch. On entry, DL must
contain 0, and AL must contain 1 to turnverify on, or 0 to turn verify off. When on,
DOS will perform a verify operation eachtime it performs a diskette write to assure
proper data recording. Although disk .
recording errors are very rare, this function
has been provided for those user applications
in which you may wish to verify the proper
recording of critical data. Note that thecurrent setting of the verify switch can beobtained through call hex 54.
2F

Get DTA. On return, ES:BX contains thecurrent DTA transfer address.

30

Get DOS version number. On return, AL
contains the major version number. AH
contains the minor version number.
Note: If AL returns zero, it can beassumed that it is a pre-DOS Version
2.00 system.

31

D-32

Terminates process and remain resident(KEEP process). On entry, AL contains abinary exit code. DX contains the memory
size value in paragraphs. This function callterminates the current process and attempts
to set the initial allocation block to thenumber of paragraphs in DX. It will not free
up any other allocation blocks belonging tothat process. The exit code passed in AL isretrievable by the parent through Wait
(function call hex 4DO) and can be tested
through the ERRORLEVEL batch
sub commands.

32

Used internally by DOS.

33

Ctrl-Break check. On entry, AL contains 00
to request the current state of control-breakchecking, 01 to set the state. If setting thestate, DL must contain 00 for OFF or 01 forON. DL returns the current state (00 = OFF,
01 = ON).

34

Used internally by DOS.

35

Get vector. On entry, AL contains ahexadecimal interrupt number. The CS:IP
interrupt vector for the specified interrupt isreturned in ES:BX. Note that interrupt
vectors can be set through call hex 25.

36

Get disk free space. On entry, DL contains adrive: 0 = default, 1 = A, etc. On return, AX
returns FFFF if the drive number was invalid.
Otherwise, BX contains the number ofavailable allocation units (clusters), DX
contains the total number of clusters on thedrive, CX contains the number of bytes per
sector, and AX contains the number of sectors
per cluster.
Note: This call returns t~e same
information in the same registers (except
for the FAT pointer) as the get FAT
pointer call (hex 1 B) did in previous
versions of DOS.

37

Used internally by DOS.

D-33

38

Return country dependent information(international). On entry, DS:DX points to a
32-byte block of memory in which returned
information is passed and AL contains afunction code. In DOS 2.00, this function
code must be zero. The following informationis pertinent to international applications:I

I

I WORD Date/time format

If-----------4
I BYTE ASCIIZ string
I
I currency symbolI~ollowed by~te of zer~ ~I BYTE ASCIIZ string

I

I thousands separatorI+-,ollowed by ~te of zeros-l

I BYTE ASCIIZ string decimal I
I separatorI

I followed by byte of zeros I+-----------4
I 24 bytes

I

I Reserved

I

L-----------L.,The date and time format has the following
values and meaning:° USA standard=

h:m:s mldly

1 = Europe standard h:m:s dimly

2 = Japan standard
39

D-34

h:m:s d:m:yCreate a sub-directory (MKDIR). On entry,
DS:DX contains the address of an ASCIIZ
string with drive and directory path names. If
any member of the directory path does notexist, then the directory path is not changed.
On return, a new directory is created at theend of the specified path. Error returns are 3
and 5 (refer to error return table).

3A Remove a directory entry (RMDIR). On
entry, DS: DX contains the address of an
ASCIIZ string with the drive and directory
path names. The specified directory isremoved from the structure. The current
directory cannot be removed. Error returns
are 3 and 5 (refer to error return table). Notetha t code 5 is returned if the specified
directory is not empty.
3B Change the current directory (CHDIR). On
entry, DS: DX contains the address of an
ASCIIZ string with drive and directory path
names. If any member of the directory pathdoes not exist, then the directory path is notchanged. Otherwise, the current directory is
set to the ASCIIZ string. Error return is 3
(refer to the error return table).
3C Create a file (CREA1). On entry, DS:DX
contains the address of an ASCIIZ string withthe drive, path, and filename. CX contains theattribute of the file. This function call createsa new file or truncates an old file to zero
length in preparation for writing. If the file
did not exist, then the file is created in theappropriate directory and the file is given theread/write access code. The file is opened forread/write, and the handle is returned in AX.
Error returns are 3, 4, and 5 (refer to the error
return table). If an error code of 5 is returned,
either the directory was full or a file by thesame name exists and is marked read-only.
Note that the change mode function call(hex 43) can later be used to change the file's
attribute.

D-35

3D Open a file. On entry, DS:DX contains theaddress of an ASCIIZ string with the drive,path, and filenames. AL contains the accesscode. On return, AX contains an error code ora 16-bit file handle associated with the file.
The following values are a1.lowed for theaccess code:o = file is opened for reading.
1 = file is opened for writing.
2 = file is opened for both reading
and writing.
The read/write pointer is set at the first byteof the file and the record size of the file is
1 byte (the read/write pointer can be changed
through function call hex 42). The returned
file handle must be used for subsequent input
and output to the file. The file's date and time
can be obtained or set through call hex 57,
and its attribute can be obtained through callhex 43. Error returns are 2,4, 5, and 12 (referto the error return table).
Note: This call will open any normal orhidden file whose name matches thename specified.
3E Close a file handle. On entry, BX contains thefile handle that was returned by "open." On
return, the file will be· closed and all internalbuffers are flushed. Error return is 6 (refer tothe error return table).

D-36

3F Read from a file or device. On entry, BX
contains the file handle. CX contains thenumber of bytes to read. DS:DX contains thebuffer address. On return, AX contains thenumber of bytes read. If the value is zero,then the program has tried to read from theend of file. This function call transfers (CX)
bytes from a file into a buffer location. It is
not guaranteed that all bytes will be read For
example, reading from the keyboard will readat most one line of text. If this read is
performed from the standard input device, theinput can be redirected (see "Redirection ofStandard Input and Output" in Chapter 10).
Error returns are 5 and 6 (refer to the error
return table).
40

Write to a file or device. On entry, BX
contains the file handle. CX contains thenumber of bytes to write. DS: DX contains theaddress of the data to write. Write transfers(CX) bytes from a buffer into a file. AX
returns the number of bytes actually written.
If this value is not the same as the number
requested, it should be considered an error(no error code is returned, but your program
can compare these values). The usual reason
for this is a full disk. If this write is performed
to the standard output device, the output canbe redirected (see" Redirection of Standard
Input and Output" in Chapter 10). Error
returns are 5 and 6 (refer to the error returntable).

D-37

41

Delete a file from a specified directory(Unlink). On entry, DS:DX contains theaddress of an ASCIIZ string with a drive, path,and filename. Global filename characters are
not allowed in any part of the string. Thisfunction call removes a directory en try
associated with a filename. Read-only files
cannot be deleted by this call. To delete oneof these files, you can first use call hex 43 tochange the file's attribute to 0, then delete thefile. Error returns are 2 and 5 (refer to theerror return table).

42

Move file read/write pointer (Lseek). On
entry, AL contains a method value. BX
contains the file handle. CX:DX contains thedesired offset in bytes (CX contains the mostsignificant part). On return, DX:AX contains
the new location of the pointer (DX contains
the most significant part).
It moves the read/write pointer according to
the following methods:
AL 0 = The pointer is moved to offset(CX:DX) bytes from the
beginning of the file.
AL 1 = The pointer is moved to thecurrent location plus offset.
AL 2 = The pointer is moved to theend-of-file plus offset. Thismethod can be used to determine
file's size.
Error returns are 1 and 6 (refer to the error
return table).

D-38

43

Change file mode (CRMOD). On en try, AL
contains a function code, and DS:DX contains
the address of an ASCIIZ string with the drive,path, and filename. If AL contains 01 then thefile will be set to the attribute in CX. (See"DOS Disk Directory" in Appendix C for theattribute byte description.) If AL is 0 then the
file's current attribute will be returned in CX.
Error returns are 2, 3, and 5 (refer to the error
return table).

44

I/O control for devices (IOCTL). On entry,
AL contains the function value. BX contains
the file handle. On return, AX contains thenumber of bytes transferred for functions 2,
3, 4, and 5 or status (00 = not ready, FF =ready) for functions 6 and 7, or an error code.
Use IOCTL to Set or Get device information
associated with open device handle, orsend/receive control strings to the device
handle. The following function values areallowed in AL:
0= Get device information (returned inDX).
1 = Set device information (determined

by DX). Currently, DR must be zerofor this call.
2 = Read CX number of bytes into

DS:DX from device control channel.
3 = Write CX number of bytes from
DS:DX to device control channel.
4 = Same as 2, but use drive number in
BL (0 = default, 1 = A, etc.).

D-39

5 = Same as 3, but use drive number in
BL (0 = default, 1 = A, etc.).
6 = Get input status.
7 = Get output status.

IOCTL can be used to get infornlation about
device channels. You can make calls on
regular files, but only function values 0, 6, and7 are defined in that case. All other calls
return an "invalid function" error.

Calls AL=O and AL=l. The bits of DX aredefined as follows:
BIT
R Ic
E IT

I
I

S IR IIL I

Reserved

IIIEIRIRIIIIIIIIIS
IA IE ,SIS ,SIS
ID FIWIS CIN1CIC
E I I
IL U 0 IIVI
IKILITIN,0

ISDEV = 1 if this channel is a device.
o if this channel is a disk file(bits 8-15 = 0 in this case).
If ISDEV= 1
EOF = 0 if end-of-file on input.
BIN = 1 if operating in binary mode(no checks for Ctrl-Z).
= 0 if operating in ASCII mode
(checking for Ctrl- Z as
end-of-file).
ISCLK = 1 if this device is the clock
device.
ISNUL = 1 if this device is the nulldevice.
D-40

ISCOT = 1 if this device is the console
output.
ISCIN = 1 if this device is the console
input.
CTRL = 0 if this device cannot processcontrol strings via calls AL=2
andAL=3.
CTRL = 1 if this device can processcontrol strings via calls AL=2
and AL=3. Note that this bit
can not be set by function callhex 44.
If ISDEV = 0
EOF = 0 if channel has been written.
Bits 0-5 are the block device
number for the channel(0 = A, 1 = B, ... ).
Bits 15, 8-13,4 are reserved and should not bealtered.
Note:

DR must be zero for call AL=l.

Calls AL=2, AL=3, AL=4, AL=5. These four
calls allow arbitrary control strings to be sentor received from a character device. The Callsyntax is the same as the Read and Write calls,
except for calls 4 and 5 which accept a drive
number in BL instead of a handle in BX. An"invalid function" error is returned if the
CTRL bit is zero. An "access-denied" code isreturned by calls 4 and 5 if the drive is invalid.
Error returns are 1, 6, and 1 3 (refer to theerror return table).

D-41

Calls 6 and 7. These calls allow you to check if
a file handle is ready for input or output. If
used for a file, AL always returns FF until
end-of-file is reached, then always returns. 00
unless the current file position is changed
through call hex 42. When used for a device,
AL returns FF for ready or zero for not ready.
45

Duplicate a file handle (DUP). On entry, BX
contains the file handle. On return, AX
contains the returned file handle. Thisfunction call takes an opened file handle andreturns a new file handle that refers to thesame file at the same position. Error returns
are 4 and 6 (refer to the error return table).
Note: If you move the read/write
pointer of either handle, the pointer forthe other handle will also be changed.
!

46

Force a duplicate of a handle (DUP). On I
entry, BX contains the file handle. ex I
contains a second file handle. On return,.' theex file handle will refer to the same stream as
the BX file handle. If the ex file handle wasan open file, then it is closed first. Error
return is 6 (refer to the error return table).
Note: If you move the read/write
pointer of either handle, the pointer forthe other handle will also be changed.

D-42

47

Get Current directory. On entry, DL contains
a drive number (0 = default, 1 = A, etc.) and
DS: SI point to a 64- byte area of user memory.
The full path name (starting from the root
directory) of the current directory for the
specified drive is placed in the area pointed toby DS: SI. Note that the drive letter will not
be part of the returned string. The string will
not begin with a backslash and will beterminated by a byte containing hex 00. The
error returned is 15.

48

Allocate memory. On entry, BX contains thenumber of paragraphs requested On return,
AX:O points to the allocated memory block. If
the allocation fails, BX will return the size ofthe largest block of memory available inparagraphs. Error returns are 7 and 8 (refer tothe error return table).

49

Free allocated memory. On entry, ES contains
the segment of the block being returned. On
return, a block of memory is returned to thesystem pool that was allocated by call hex 48.
Error returns are 7 and 9 (refer to the error
return table).

4A SETBLOCK-Modify allocated memory blocks.
On entry, ES contains the segment of theblock. BX contains the new requested block
size in paragraphs. DOS will attempt to"grow" or" shrink" the specified block. If thecall fails on a grow request, then on return,
BX contains the maximum block size
possible. Error returns are 7, 8, and 9 (refer tothe error return table).

D-43

4B Load or execute a program (EXEC). Thisfunction call allows a program to load anotherprogram into memory and (default) begin
execution of it. DS:DX points to the ASCIIZ
string with drive, path, and filename of thefile to be loaded. ES:BX points to a parameter
block for the load and AL contains a function
value. The following function values areallowed:o=Load and execute the program. A
program segment prefix is established
for the program and the terminate
and control-break addresses are set
to the instruction after the EXEC
system call.
Note: When control is returned, allregisters are changed including thestack. You must restore SS, SP and
any other required registers before
proceeding.

3 = Load, do not create the program
segment prefix, and do not begin
execution. This is useful in loading
program overlays.

D-44

For each of these values, the block pointed toby ES: BX has the following format:

AL = 0 Load/execute program
WORD segment address of environment
string to be passed
DWORD pointer to command line to beplaced at PSP+ Boh
DWORD points to default FCB to bepassed at PSP+ 5 Ch
DWORD pointer to default FCB to bepassed at PSP+ 6Ch

AL = 3 Load overlay
WORD segment address where file will be
loadedWORD relocation factor to be applied tothe image

D-45

Note that all open files of a process are
duplicated in the newly created process afteran EXEC. This is extremely powerful; theparent process has control over the meaningsof standard input, output, auxiliary, andprinter devices. The parent could, forexample, write a series of records to a file,
open the file as standard input, open a listing
file as standard output, and then execute asort program that takes its input fromstandard input and writes to standard output.
Also inherited (or copied from the parent) isan "environment." This is a block of text
strings (less than 32K bytes total) that convey
various configuration parameters. The
following is the format of the environment(always on a paragraph boundary):
Byte ASCIIZ string 1
Byte ASCIIZ string 2

Byte ASCIIZ string n
Byte of zeroD-46

Typically the environment strings have theform:parameter=value

For example, the string VERIFY=ON could
be passed. A zero value of the environment
address will cause the newly created process toinherit the parent's environment unchanged.
The segment address of the environment isplaced at offset hex 2C of the Program
Segment Prefix for the program being
invoked. Error returns are 1, 2, 5, 8, 10, and
11 (refer to the error return table).
Notes:
1.

When your program received control, allof available memory was allocated to it.
You must free some memory (see callhex 4A) before EXEC can load theprogram you are invoking. Normally, you
would shrink down to the minimum
amount of memory you need, and free
the rest.

2.

The EXEC call uses the loader portion of
COMMAND.COM (at the high end ofmemory) to perform the loading. If yourprogram has overlaid the loader, this callwill attempt to re-Ioad the loader, thus
destroying the contents of the last 1536
bytes of memory. If you have used the"Allocate Memory" call to allocate allof memory and the loader has been
overlaid, the EXEC call will return anerror due to insufficient memory to load
the loader.

D-47

4C Terminate a process (Exit). On entry, AL
contains a binary return code. This function
call will terminate the current process,transferring control to the invoking process.
In addition, a return code can be sent. The
return code can be interrogated by the batch
subcommands IF and ERRORLEVEL and by
the wait function call (4D). All files open at
the time are closed.
4D Retrieve the return code of a sub-process(Wait). This function call returns the Exit
code specified by another process (via callhex 4C or call hex 31) in AX. It returns the
Exit code only once. The low byte of this codeis that sent by the exiting routine. The highbyte is zero for normal termination, 01 if
terminated by Crtl-Break, 02 if terminated as
the result of a critical device error, or 03 if
terminated by function call hex 31.

D-48

4E Find first matching file (FIND FIRS1). On
input, DS: DX points to an ASCIIZ string
containing the drive, path, and filename of thefile to be found. The filename portion cancontain global filename characters. CX
contains the attribute to be used in searchingfor the file. See function call hex 11 for a
description of how the attribute bits are used
for searches. If a file is found that matches the
specified drive, path, and filename andattribute, the current DTA will be filled in as
follows:
21 bytes - reserved for DOS use on

subsequent find next calls
1 byte- attribute found

2 bytes- file's time

2 bytes- file's date

2 bytes- low word of file size

2 bytes- high word of file size

13 bytes - name and extension of file
found, followed by a byte of zeros. All
blanks are removed from the name andextension, and if an extension is present,
it is preceded by a period. Thus, thename returned appears just as you would
enter it as a command parameter. Suchas, TREE. COM followed by a byte ofzeros. Error returns are 2 and 18 (refer tothe error return table).

D-49

D-50

4F

Find next matching file. On input, thecurrent DTA must contain the informationthat was filled in by a previous Find First call(hex 4E). No other input is required. This callwill find the next directory entry matching thename that was specified on the previous Find
First call. If a matching file is found, thecurrent DTA will be set as described in callhex 4E. If no more matching files are found,error code 18 is returned (refer to the error
return table).

50

Used internally by DOS.

51

Used internally by DOS.

52

Used internally by DOS.

53

Used internally by DOS.

54

Get verify state. On return, AL returns 00 if
verify is OFF, 01 if verify is ON. Note that theverify switch can be set through call hex 2E.

55

Used internally by DOS.

56

Rename a file. On input, DS:DX points to an
ASCIIZ string containing the drive, path, andfilename of the file to be renamed. ES: DI
points to an ASCIIZ string containing thepath and filename to which the file is to berenamed. If a drive is used in this string, it
must be the same as the drive specified or
implied in the first string. The directory paths
need not be the same, allowing a file to be
moved to another directory and renamed in
the process. Error returns are 3, 5, and 1 7(refer to the error return table).

57

Get/Set a file's date and time. On input, AL
contains 00 or 01. BX contains a file handle. If
AL=OO on entry, DX and CX will return thedate and time from the handle's internal table,
respectively. If AL=01 on entry, the handle's
date and time will be set to the date and timein DX and CX, respectively. The date andtime formats are the same as those for the
directory entry described in Appendix C,
except that when passed in registers, the bytes
are reversed (that is, DR contains the loworder portion of the date, etc.). Error returns
are 1 and 6 (refer to the error return table).

D-51

Notes:D-52

Appendix E. DOS Control Blocks
and Work Areas

DOS Memory Map
0000:0000

Interrupt vector table

0040:0000

ROM communication area

0050:0000

DOS communication area

xxxX:oooo

IBMBIO.COM - DOS interface to
ROM I/O routines

XXXX:OOOOIBMDOS.COM - DOS interrupt
handlers, service routines (INT 21
functions)
DOS buffers, control areas, and installed
device drivers

XXXX:OOOO

Resident portion of COMMAND. COM- Interrupt handlers for interrupts
hex 22 (terminate), hex 23 (Ctrl-Break),hex 24 (critical error), and code toreload the transient portion.

XXXX:OOOO

External command or utility - (.COMor .EXE file)

XXXX:oooo

User stack for .COM files (256 bytes)

XXXX:oooo

Transient portion of COMMAND. COM- Command interpreter, internal
commands, batch processor, external
command loader.

E-lNotes:1.

Memory map addresses are insegment: offset format. For example,
0070:0000 is absolute address hex 0700.

2.

The DOS Communication Area is used asfollows:
0050:0000

Print screen status flag storeoPrint screen not active
or successful print
screen operation

1

Print screen inprogress

255

Error encounteredduring print screen
operation

0050:0001

Used by BASIC

0050:0004

Single-drive mode statusbyteoDiskette for drive A
was last used

1

Diskette for drive B
was last used

0050:0010 - 0021 Used by BASIC
0050:0022 - 002F Used by DOS for

diskette initialization
0050:0030 - 0033 Used by MODE

command

E-2

All other locations within the 256 bytes
beginning at 0050:0000 are reserved for
DOS use.
3.

User memory is allocated from the lowest
end of available memory that will satisfy
the request for memory.

DOS Program Segment
When you enter an external command, or invoke a
program through the EXEC function call, DOS
determines the lowest available address to use as
the start of available memory for the program
being invoked. This area is called the Program
Segment (it must not be moved).
At offset 0 within the Program Segment, DOS
builds the Program Segment Prefix control block.
(See below.) EXEC loads the program at offset
hex 100 and gives it control.
The program returns from EXEC by a jump tooffset 0 in the Program Segment Prefix, by issuingan INT 20, by issuing an INT 21 with register
AH=O or hex 4C, or by calling location hex 50 in
the Program Segment Prefix with AH=O orhex 4C.
Note: It is the responsibility of all programs
to ensure that the CS register contains thesegment address of the Program Segment
Prefix when terminating via any of thesemethods except call hex 4C.

E-3

All four methods result in transferring control to
the resident portion of COMMAND. COM(function call hex 4C allows the terminatingprocess to pass a return code). All of thesemethods result in turning to the program thatissued the EXEC. During this returning process,interrupt vectors hex 22, hex 23, and hex 24(terminate, Ctrl-Break, and critical error exit
addresses) are restored from the values saved in
the Program Segment Prefix of the terminating
program. Control is then given to the terminate
address. If this is a program returning to
COMMAND, control transfers to its transient
portion. If a batch file was in process, it iscontinued; otherwise, COMMAND issues thesystem prorript and waits for the next command to
be entered from the keyboard.
When a program receives control, the following
conditions are in effect:
For all programs:•

The segment address of the passed
environment is contained at offset hex 2C in
the Program Segment Prefix.
The environment is a ,series of ASCII strings(totaling less than 32K) in the form:
NAME=parameter

E-4

Each string is terminated by a byte of zeros,and the entire set of strings is terminated byanother byte of zeros. The environment built
by the command processor (and passed to all
programs it invokes) will contain a
COMSPEC= string at a minimum (theparameter on COMSPEC is the path used by
DOS to locate COMMAND.COM on disk).
The last PATH and PROMPT commands
issued will also be in the environment, alongwith any environment strings entered throughthe SET command (see Chapter 10).
The environment that you are passed is
actually a copy of the invoking processenvironment. If your application uses a"terminate and stay resident" concept, you
should be aware that the copy of theenvironment passed to you is static. That is, itwill not change even if subsequent SET,
PATH, or PROMPT commands are issued.
•

Offset hex 50 in the Program Segment Prefix
contains code to invoke the DOS function
dispatcher. Thus, by placing the desired
function number in AH, a program can issue along call to PSP+ 50 to invoke a DOS
function, rather than issuing an interrupt typehex 21.

•

Disk transfer address (DTA) is set to hex 80(default DTA in the Program Segment
Prefix).

•File control blocks at hex 5C and hex 6C areformatted from the first two parameters
entered when the command was invoked.
Note that if either parameter contained a path
name, then the corresponding FCB willcontain only a valid drive number. The
filename field will not be valid.

E-5

•

An Unformatted parameter area at hex 81
contains all the characters entered after thecommand name (including leading andimbedded delimiters), with hex 80 set to thenumber of characters. If the <, >, or :parameters were entered on the command
line, they (and the filenames associated withthem) will not appear in this area, because
redirection of standard input and output istransparent to applications.

•

Offset 6 (one word) contains the number ofbytes available in the segment.

•

Register AX reflects the validity of drive
specifiers entered with the first two
parameters as follows:
AL=FF if the first parameter contained
an invalid drive specifier (otherwise
AL=OO)
AH=FF if the second parametercontained an invalid drive specifier(otherwise AH=OO)

For .EXE programs:

E-6•

DS and ES registers are set to point to theProgram Segment Prefix.

•

CS, IP, SS, and SP registers are set to thevalues passed by the linker.

For .COM programs:•

All four segment registers contain thesegment address of the initial allocation
block, that starts with the Program Segment
Prefix control block.

•All of user memory is allocated to theprogram. If the program wishes to invoke
another program through the EXEC function
call, it must first free some memory throughthe Setblock (hex 4A) function call, toprovide space for the program being invoked.

•

The Instruction Pointer (IP) is set to hex 100.

•

SP register is set to the end of the program's
segment. The segment size at offset 6 isreduced by hex 100 to allow for a stack of that
size.

•

A word of zeros is placed on the top of thestack.

The Program Segment Prefix (with offsets inhexadecimal) is formatted as follows.

E-7

Program Seg,ment Prefix(offsets in hex)
O~------------~-----------------Top ofLong call to
INT hex 20 memory Reserved DOS function dis1
patcher (5 bytes)2
8~------4-----~------~----~~~CTRL-BREAK
Terminate address
exit address(lP,CS)(lP)
10 CTRL- BREAK
exit address(CS)

CRITICAL ERROR
exit address(lP, CS)

Used by DOS

2C ,..._____I Note 31

Formatted Parameter Area 1
formatted as standard unopened FCB

6CI

Formatted Parameter Area 2
formatted as standard unopened FCB(overlaid if FCB at hex 5C is opened)
80~------------------------------~

Unformatted parameter area
(default disk transfer area)
100 ,"----_ _ _ _ _ _

E-8

....

..

~

~

---JJ

1.

First segment of available memory is insegment (paragraph) form (for example, hex
1000 would represent 64K).

2.

The word at offset 6 contains the number ofbytes available in the segment.

3.

Offset hex 2C contains the segment address ofthe environment.

4.

Programs must not alter any part of the PSP
below offset hex 5 C.

E-9

-7r--T------------r---,I hex FF I
Zeros
I. Attribute I- eFCxtBenslon.
O'~-------+------~------------------------------------~~----~

Drive

Filename (8 bytes) or Reserved device nameStandard
FCB

81~-------+--------------------------------------,-------------~

Filename extension

Current block

Record size

16
24
~

u
0

~

~

32

Current
recordRandom record
number (low part)

Random record
number (high part)

~

0

4-4

(Offsets are in decimaQ~dUnshaded areas must be filled in by the using program.

U

Shaded areas are filled in by ODS and must not be modified.

0

Q)

....

~

~

o

~

~

Standard File Control Block
The standard file control block (FCB) is defined asfollows, with the offsets in decimal:
Byte

FunctionoDrive number. For example,
Before open: 0 - default drive
1 - drive A
2 - drive B
etc.
After open:

1 - drive A
2 - drive Betc.
A 0 is replaced by the actual drive
number during open.
1-8

Filename, left-justified with trailingblanks. If a reserved device name isplaced here (such as LPTl), do notinclude the optional colon.

9-11Filename extension, left- justified withtrailing blanks (can be all blanks).

12-13

Current block number relative to thebeginning of the file, starting with zero(set to zero by the open function call). A
block consists of 128 records, each of thesize specified in the logical record size
field. The current block number is usedwith the current record field (below) for
sequential reads and writes.

E-l1

14-15

Logical record size in bytes. Set to hex 80
by the open function call. If this is notcorrect, you must set the value because
DOS uses it to determine the proper
locations in the file for all disk reads andwrites.

16-19

File size in bytes. In this 2-word field, thefirst word is the low-order part of the
size.

20-21

Date the file was created or last updated.
The mm/dd/yy are mapped in the bits asfollows:

<

21
> <
20
>
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Y Y Y Y Y Y ymmmmddddd
where:
mm is 1-12
dd is 1-31
yy is 0-119 (1980-2099)

E-12

22-31

Reserved for system use.

32

Current relative record number (0-127)
within the current block. (See above.)
You must set this field before doing
sequential read/write operations to thediskette. (This field is not initialized by
the open function call.)33-36

Relative record number relative to thebeginning of the file, starting with zero.
You must set this field before doing
random read/write operations to thediskette. (This field is not initialized by
the open function call.)If the record size is less than 64 bytes,
both words are used. Otherwise, only the
first three bytes are used. Note that if
you use the File Control Block at hex 5 C
in the program segment, the last byte of
the FCB overlaps the first byte of theunformatted parameter area.
Notes:
1.

An unopened FCB consists of the
FCB prefix (if used), drive number,and filename/ extensions properly
filled in. An open FCB is one inwhich the remaining fields have been
filled in by the Create or Openfunction calls.

2.

Bytes 0-15 and 32-36 must be set by
the user program. Bytes 16- 31 are
set by DOS and must not be changed
by user programs.

3.

All word fields are stored with theleast significant byte first. For
example, a record length of 128 isstored as hex 80 at offset 14, andhex 00 at offset 15.

E-13

Extended File Control Block
The extended File Control Block is used to createor search for files in the disk directory that havespecial attributes.
It adds a 7-byte prefix to the FCB, formatted asfollows:
Byte

Function

FCB-7

Flag byte containing hex FF to
indicate an extended FCB.

FCB-6 to FCB-2

Reserved.

FCB-l

Attribute byte. See "DOS Disk
Directory" in Appendix C for
attribute bit definitions. Also
refer to function call hex 11(search first) for details on using
the attribute bits during
directory searches. Thisfunction is present to allow
applications to define their own
files as hidden (and thereby
exclude them from directory
searches), and to allow selective
directory ~earches.

Any references in the DOS Function Calls (refer toAppendix D) to an FCB, whether opened orunopened, may use either a normal or extended
FCB. If using an extended FCB, the appropriate
register should be set to the first byte of theprefix, rather than the drive-number field.

E-14

Appendix F. Executing
Commands from
Within an Application

Beginning with DOS Version 2.00, application
programs may invoke a secondary copy of thecommand processor. Your program may pass a
DOS command as a parameter, that the secondarycommand processor will execute as though it had
been entered from the standard input device. The
procedure is:1.

Assure that adequate free memory (17K)
exists to contain the second copy of thecommand processor and the command it is to
execute.

2.

Build a parameter string for the secondarycommand processor in the form:
1 byte = length of parameter string
xx byte = parameter string
1 byte = hex OD (carriage return)For example, the assembly statement below
would build the string to cause execution of a
DISKCOPY command:
DB 17,"\C DISKCOPY A: B:", 13

F-l

3.

Use the EXEC function call (hex 4B, function
value 0) to cause execution of the secondary
copy of the command processor (the drive,
directory and name of the commandprocessor can be gotten from the
COMSPEC=parameter in the environment
passed to you at PSP+ hex 2C). Remember toset offset 2 of the EXEC control block topoint to the parameter string built above.

Refer to Chapter 10, "Advanced Commands" foradditional information about invoking a second
copy of the command processor.

F-2

Appendix G. Fixed Disk
Information

The IBM Personal Computer Fixed Disk Support
Architecture has been designed to meet thefollowing objectives:•

Allow multiple operating systems to utilize
the fixed disk without the need todump/restore when changing operating
systems.

•

Allow a user-selected operating system to be
started from the fixed disk.

Fixed Disk Architecture
The architecture is defined as follows:•

In order to share the fixed disk among
operating systems, the disk may be logicallydivided into 1 to 4 "partitions." The spacewithin a given partition is contiguous, and canbe dedicated to a specific operating system.
Each operating system may" own" only one
partition. The number and sizes of thepartitions is user-selectable through a fixed
disk utility program. (The DOS utility is
FDISK.COM.) The partition information is
kept in a partition table that is imbedded in
the master fixed disk boot record on the first
sector of the disk.

G-l

•

Any operating system must consider its
partition to be an entire disk, and must ensurethat its functions and utilities do not accessother partitions on the disk.

•

Each partition can contain a boot record on
its first sector, and any other programs or datathat you choose-including a copy of an
operating system. For example, the DOS
FORMAT command may be used to format(and place a copy of DOS in) the DOS
partition, in the same manner that a disketteis formatted. With the FDISK utility, you
may deSignate a partition as "bootable"(active)-:-the master fixed disk boot record
will cause that partition's boot record toreceive control when the system is started orrestarted.

System Initialization
The System initialization (or system boot)sequence is as follows:

G-2

1.

System initialization first attempts to load an
operating system from diskette drive A. If thedrive is not ready or a read error occurs, itthen attempts to read a master fixed disk bootrecord from the first sector of the first fixed
disk on the system. If unsuccessful, or if nofixed disk is present, it invokes ROM BASIC.

2.

If successful, the master fixed disk bootrecord is given control and it examines thepartition table imbedded within it. If one of
the entries indicates a "bootable" (active)
partition, its boot record is read (from thepartition's first sector) and given control.

3.

If none of the partitions is bootable, ROM
BASIC is invoked.

4.

If any of the boot indicators is invalid, or if
more than one indicator is marked asbootable, the message Invalid partition
table is displayed and the system enters an
enabled loop. You may then insert a systemdiskette in drive A and use system reset torestart from diskette.

5.

If the partition's boot record can't be
successfully read within 5 retries due to readerrors, the message Error loading operating
system appears and the system enters an
enabled loop.

6.

If the partition's boot record does not containa valid" signature" (see" Boot
Record/Partition Table"), the message
Missing operating system appears, and thesystem enters an enabled loop.
Note: When changing the size or location of
any partition, you must ensure that allexisting data on the disk has been backed up(the partitioning process will" lose track" ofthe previous partition boundaries).

G-3

Boot Record/Partition Table
A fixed disk boot record must be written on thefirst sector of all fixed disks, and contains:1.

Code to load (and give control to) the bootrecord for 1 of 4 possible operating systems.

2.

A partition table at the end of the bootrecord. Each table entry is 16 bytes long, andcontains the starting and ending cylinder,
sector and head for each of 4 possible
partitions, as well as the number of sectors
preceding the partition and the number ofsectors 9ccupied by the partition. The "bootindicator" byte is used by the boot record todetermine if one of the partitions contains aloadable operating system. FDISK
initialization utilities mark a user-selectedpartition as "bootable" by placing a value ofhex 80 in the corresponding partition's bootindicator (setting all other partitions'indicators to zero at the same time.) The
presence of the hex 80 tells the standard bootroutine to load the sector whose location iscontained in the following 3 bytes. That
sector will be the actual boot record for theselected operating system, and it will be
responsible for the remainder of the system's
loading process (as it is from diskette). Allboot records are loaded at absolute address
0:7COO.

G-4

The partition table (with its offsets into theboot record) is as follows:
Offs Purpose

Head

Sector

Cylinder1 BE Partition 1 begin

boot ind

H

S

CYL

1C2 Partition 1 end

syst ind

H

S

CYL

1C6 Partition 1 rei sect

Low wordHigh word

1CA Partition 1 # sects

Low wordHigh word

1CE Partition 2 begin

boot ind

H

S

CYL

1 02 Partition 2 end

syst ind

H

S

CYL

1 06 Partition 2 rei sect

Low wordHigh word

1 OA Partition 2 # sects

Low wordHigh word

1 OE Partition 3 begin

boot ind

H

S

CYL

1 E2 Partition 3 end

syst ind

H

S

CYL

1E6 Partition 3 rei sect

Low wordHigh word

1 EA Partition 3 # sects

Low wordHigh word

1 EE Partition 4 begin

boot ind

H

S

CYL

1F2 Partition 4 end

syst ind

H

S

CYL

1 F6 Partition 4 rei sect

Low wordHigh word

1FA Partition'4 # sects

Low wordHigh word

1 FE Signaturehex 55hex AA

G-5

Technical Information
When shipped by IBM, the 10-megabyte fixeddisks are formatted with 512-byte sectors at aninterleave factor of 6 (17 sectors per track, 4 "heads
per cylinder). They contain no data or bootrecords.
The boot indicator byte must contain 0 for a
non-bootable partition, or hex 80 for a bootablepartition. Only one partition can be marked
bootable.
The "syst ind" field contains an indicator of theoperating system that" owns" the partition. Each
operating system can "own" only one partition.
The system indicators are:hex 00 - unknown (unspecified)hex 01 - DOS
The I-byte fields labelled "CYL" contain the
low-order 8 bits of the cylinder number-the highorder 2 bits are in the high order 2 bits of the "S"(sector) field. This corresponds with ROM BIOS
Interrupt hex 13 (disk I/O) requirements, to allow
for a 10-bit cylinder number.
The fields are ordered in such a manner that only 2
MOV instructions are required to properly set up
the DX and CX registers for a ROM BIOS call toload the appropriate boot record (fixed disk
booting is only possible from the first fixed disk
on a system, whose BIOS drive number (hex 80)
corresponds to the boot indicator byte.)

G-6

All partitions are allocated in cylinder multiples
and begin on sector 1, head 0. EXCEPTION: thepartition which is allocated at the beginning of thedisk starts at sector 2, to account for the disk's
master boot record.
The number of sectors preceding each partition on
the disk is kept in the 4-byte field labelled "reI
sect." This value is obtained by counting thesectors beginning with cylinder 0, sector 1, headof the disk, and incrementing the sector, head andthen track values up to the beginning of thepartition. Thus, if the disk has 17 sectors per trackand 4 heads, and the second partition begins atcylinder 1, sector 1, head 0, the partition's starting
relative sector is 68 (decimal)-there were 17
sectors on each of 4 heads on 1 track allocatedahead of it. The field is stored with the leastsignificant word first.

°

The number of sectors allocated to the partition is
kept in the"# of sects" field. This is a 4-byte field
stored least significant word first.
The last 2 bytes of the boot record (hex 55AA) areused as a signature to identify a valid boot record.
Both this record and the partition boot records
are required to contain the signature at offset
hex 1FE.
The Master disk boot record will invoke ROM
BASIC if no indicator byte reflects a "bootable"
system.
When a partition's boot record is given control, it
is passed its partition table entry address in the
DS: SI registers.

G-7

System programmers designing a utility toinitialize/manage a fixed disk must provide thefollowing functions at a minimum:

G-8

1.

Write the master disk boot record/partition
table to the disk's first sector to initialize it.

2.

Perform partitioning of the disk-that is,create or update partition table information(all fields for the partition) when the user
wishes to create a partition. This may belimited to creating a partition for only one
type of operating system, but must allow
repartitioning the entire disk, or adding apartition without interfering with existing
partitions (user's choice).

3.

Provide a means for marking a user-specified
partition as bootable, and resetting thebootable indicator bytes for all otherpartitions at the same time.

Appendix H. EXE File Structureand Loading

The . EXE files produced by the Linker program
consist of two parts:•

Control and relocation information•

The load module itself

The control and relocation information, which is
described below, is at the beginning of the file inan area known as the header. The load module
immediately follows the header. The load module
begins on a sector boundary and is the memory
image of the module constructed by the linker.
The header is formatted as follows:
Hex Offset

Contents

00-01

Hex 4D, hex 5A-This is the LINK
program's signature to mark the file as a valid.EXE file.

02-03

Length of image mod 512 (remainder after
dividing the load module image size by
512).

04-05

Size of the file in 512-byte increments(pages), including the header.

06-07

Number of relocation table items that
follow the formatted portion of the header.

08-09

Size of the header in 16-byte increments(paragraphs). This is used to locate thebeginning of the load module in the file.

H-lHex Offset

Contents

OA-OB

Minimum number of 16-byte paragraphs
required above the end of the loaded
program.

OC-OD

Maximum number of 16-byte paragraphs
required above the end of the loaded
program.

OE-OF

Offset of stack segment in load module (insegment form).

10-11

Value to be in the SP register when themodule is given control.

12-13

Word checksum - negative sum of all thewords in the file, ignoring overflow.

14-15

Value to be in the IP register when themodule is given control.

16-17

Offset of code segment within load module(in segment form).

18-19

Offset of the first relocation item within the
file.

lA-IB

Overlay number (0 for resident part of the
program).

H-2

The relocation table follows the formatted area
just described. The relocation table is made up of avariable number of relocation items. The numberof items is contained at offset 06-07. The
relocation item contains two fields-a 2-byte offset
value, followed by a 2-byte segment value. These
two fields contain the offset into the load moduleof a word which requires modification before themodule is given control. This process is called
relocation and is accomplished as follows:
1.

A Program Segment Prefix is built following
the resident portion of the program that is
performing the load operation.

2.

The formatted part of the header is read intomemory (it's size is at offset 08-09).

3.

The load module size is determined bysubtracting the header size from the file size.
Offsets 04-05 and 08-09 can be used for thiscalculation. The actual size is downward
adjusted based on the contents of offsets
02-03. Note that all files created by
pre-release 1.10 LINK programs always placeda value of 4 at that location, regardless ofactual program size. Therefore, we
recommend that this field be ignored if it
contains a value of 4. Based on the setting of
the high/low loader switch, an appropriate
segment is determined at which to load theload module. This segment is called the startsegment.

4.

The load module is read into memory
beginning at the start segment.

5.

The relocation table items are read into awork area (one or more at a time).

H-3

H-4

6.

Each relocation table item segment value isadded to the start segment value. This
calculated segment, in conjunction with therelocation item offset value, points to a wordin the load module to which is added the startsegment value. The result is placed back into
the word in the load module.

7.

Once all relocation items have beenprocessed, the SS and SP registers are set
from the values in the header and the startsegment value is added to SS. The ES and DS
registers are set to the segment address of theProgram Segment Prefix. The start segment
value is added to the header CS register value.
The result, along with the header IP value, isused to give the module control.

Appendix I. Running Compilers
and Assemblers

Using Compilers and Assemblers With
Fixed Disk
The following is a summary of how to run the IBM
Personal Computer compilers and the IBM
Personal Computer Macro Assembler with the
Disk Operating System (DOS) Version 2.00. For
the purposes of this appendix, the word compile will
also refer to assemble.
1.

Make sure to back up your original language
diskettes using the techniques describedwithin this book and/ or the respective
language books.

2.

Make sure all source code you will compile isin the current directory of your disk.

3.

Most of the language processors may belocated in any directory at compile time (seeexception list at the end of this appendix).

4.

When Compiling you should use thecommand lines as described in your language
book. You can modify the drive specifier inthe command line to indicate the location of
the particular language processor.

1-1

1-2

5.

When Linking, use the IBM Personal
Computer Linker, Version 2.00, provided
with DOS Version 2.00 diskette. The
instructions within this book and yourlanguage book will provide the necessary
information for linking.

6.

When running a program (.BAT, .COM, or a
.EXE file) it is not always necessary for that
program to be in the current directory (seethe PATH command in Chapter 6 of thisbook). However, if the program requires
another file at runtime; such as a data file or a
Common Runtime Module, then those files
must be in the current directory at runtime.

7.

It is possible for COMMAND. COM to be
overwritten in memory. Therefore, it isusually helpful to have a copy of
COMMAND.COM in the root directory of thedrive from which DOS was started.

Exceptions•

All IBM Personal Computer Language
Products:
All files accessed by your program must
be in the current directory at runtime.
Any Common Runtime Module used byyour program must be in the current
directory at runtime.

•

IBM Personal Computer BASIC Compiler:
BASRUN.EXE, if used at runtime, must
be in the current directory.

•

IBM Personal Computer COBOL Compiler:
COBOL. COM and its overlays must be in
the current directory at compile time.
To compile, you must use the commandline and indicate the drive location of theoverlays with the Ie parameter.
COBRUN.EXE must be in the current
directory at runtime.

•

IBM Personal Computer Pascal Compiler:
Pascal requires a hex update (see "Pascal
Hex Patch" in Appendix]) in order to
run this compiler from a drive other thandrive A.
PASKEY must be in the current
directory at compile time.

1-3Notes:1-4

Appendix]. Running the Pascal
Compiler

Using Pascal Hex Patch
With Fixed Disk
The IBM Personal Computer Pascal Compiler t.OO
requires that a special file called PASKEY be in thecurrent directory on diskette drive A. The
following hex update can be used so that the
Pascal compiler will look on the default drive forthis PASKEY file.
The following describes how to update your PAStdiskette. Follow the instructions carefully. If you
make a mistake don't panic. Just start again.
To update your PASt diskette, you need a blankformatted diskette. Put your DOS diskette indiskette drive A and the blank formatted diskettein diskette drive B. You must use the DOS
DISKCOPY command to make an exact copy ofyour PASt diskette.

}-1After the DISKCOPY program is started and you
see the message Strike any key when ready, insert
the ORIGINAL copy of the Pascal PASt diskettein diskette drive A. It must be the diskette fromyour IBM Personal Computer Pascal Compiler
package or an exact copy of it. Anything else will
not work. After you insert the diskettes, press theSpacebar to start the disk copy:
A>OISKCOPY A: I:
Insert source diskette in drive A:
Insert target diskette in drive I:
Strike any ~ey when ready

Copy another (Y/N)?N

Place your DOS diskette back in diskette drive B.
You now have an exact copy of your Pascal PAStdiskette in diskette drive B. You can now apply the
update to the PASt diskette with the DOS
DEBUG program on the DOS diskette.
The DEBUG program prompt is "-." All the things
that you type are after the "-."
When you are responding to the "-" prompt, youmust press the Enter key. Note that the xxxx in thedata displayed line will be filled with theappropriate memory addresses:

A>OEIUG-LOS: 100 1 A5 1
-DDS: 177 LA
xxxx:0177 41-3A 5041 5341455920
xxxx:0180 20

J-2

A: PASKEY

If you do not see the above line of data after the"DDS: t77 LA" command then you did something
wrong and you should start again. You can startagain by typing Q followed by Enter. This returns
you to DOS:-EDS: 177 'PASKEY ,-WDS: 100 1 A5 1-0
(Remember to enter the two blanks after
PASKEY.)You are now back in DOS; you should now
recreate your working PASt diskette from the
updated diskette and mark both diskettes so you
know which are the updated ones. The PASt.EXE
file on the updated PASt diskette will now look
for the PASKEY file in the current directory on
the default drive.

)-3

Notes:'J-4

Appendix K. Considerations for
Using Applications

If you have any of the following applications,please refer to the appropriate section in thisappendix for additional information about using
these applications with DOS 2.00:•

Accounting Packages by BPI Systems, Inc.

•

Accounting Packages Version 1.00 by
Peachtree Software, Inc.

•

Accounting Packages Version 1.10 by
Peachtree Software, Inc.

•

Arithmetic Games 1 and 2•

Asynchronous Communications Support
Version 1.00•

Asynchronous Communications Support
Version 2.00•

EasyWriter Version 1.10•

Fact Track•

PFS:File•

PFS: Report

K-l

K-2

•

SNA 3270 Emulation and RJE Support
Version 1.00•

The Dow Jones Reporter Version 1.00•

Typing Tutor•

VisiCalc Version 1.10•

3101 Emulator Version 1.00

Accoun ting Packages by
BPI Systems, Inc.
These packages are designed for, and should be
used only with DOS 1.00 or DOS 1.10. You should
not use these applications 'with DOS 2.00.

Accounting Packages Version 1.00 by
Peachtree Software, Inc.
These packages are designed for, and should be
used only with DOS 1.00 or DOS 1.1 o. You should
not use these applications with DOS 2.00.

Accoun ting Packages Version 1.10 by
Peachtree Software, Inc.
These packages are designed, to be used with either
DOS 1.10 or DOS 2.00. If you use these packages
with DOS 2.00 on a diskette-only system, youmust have 128K bytes memory and 320K byte
diskette drives in order to accommodate the larger
size of DOS 2.00 and BASIC 2.00.
The Accounting Packages Version 1.10 by
Peachtree Software, Inc. include functions
allowing both programs and data files to reside on
the IBM Personal Computer fixed disk. Whenusing the fixed disk, these packages requireDOS2.00 and 128K bytes of memory.
Data files created using Accounting Packages
Version 1.00 by Peachtree Software, Inc. may be
used with the Version 1.10 packages.

K-3

Arithmetic Games 1 and 2
When using the arithmetic games with DOS 2.00,
you must have a minimum of 96K bytes ofmemory. In addition, if you have a single-drive
IBM Personal Computer, you should use thesingle-drive setup procedure.

K-4

Asynchronous Communications
Support Version 1.00
To use this application with DOS 2.00 you musthave a minimum of 96K bytes of memory.
To install this application in a subdirectory on a
fixed disk, use the following procedure. This
procedure assumes the following:•

The name of the subdirectory is ASYNC.

•

The fixed disk is the default drive.

•

The fixed disk drive is drive C.

•

The root directory of the fixed drive contains
DOS 2.00.

The Procedure1.

Insert the Asynchronous Communications
Support diskette in drive A.

2.

Enter the following commands in order tocreate the subdirectory ASYNC and to copy
the files from drive A to drive C:
MD \ASYNC
Create the subdirectory
CD \ASYNC
Operate from it
COpy A:*.* C:\ASYNC
Copy all files on the application diskette
COPY C:\BASIC.COM C:\ASYNC
Copy BASIC. COM to the subdirectory
ERASE UPDATE. BAT
Not needed
ERASE MESSAGE
Not needed

K-5

3.

You must now patch TERMINAL. BAS by
doing the following:BASIC
Run BASIC
LOAD "TERMINAL.BAS
Load the program to be patched
115 DEF SEG=&H1300
Patch 1117 D$(1)="C:":D$(2)="A:"
Patch 2
210IDSEG=&H1300
Patch 3
SAVE "TERMINAL.BAS"
Save the patched program
SYSTEM
Leave BASIC and return to DOS 2.00

4.

You may now run the Asynchronous
Communications Support program by doing
the following:
CD \ASYNC
Operate from the subdirectory
AUTO EXEC
Run the program
CD \Return to the root directory
Notes:
1.

K-6

The use of the subdirectory name of
ASYNC is an example only. You may use
any name you wish.

2.

All file transfers will be to and from thefiles in the subdirectory unless theprinter is the destination.

3.

This program tests the length of afilespec, and does not accept
subdirectory names as part of a filespec.

4.

You may rename AUTOEXEC.BAT if
you choose.

Asynchronous Communications Support
Version 2.00
To use this application with DOS 2.00 you musthave a minimum of 96K bytes of memory.
To install this application in a subdirectory on a
fixed disk, use the following procedure. This
procedure assumes the following:•

The name of the subdirectory is ASYNC.

•

The fixed disk is the default drive.

•

The fixed disk drive is drive C.

•

The root directory of the fixed drive contains
DOS 2.00.

K-7

The Procedure1.

Insert the Asynchronous Communications
Support diskette into drive A.

2.

Enter the following commands in order tocreate the subdirectory ASYNC and to copy
the files from drive A to drive C:
MD \ASYNC
Create the subdirectory
CD \ASYNC
Operate from it
COpy A:*.* C:\ASYNC
Copy all files on the application diskette
COpy C:\BASIC.COM C:\ASYNC
Copy BASIC. COM to the subdirectory
ERASE UPDATE.BAT
Not needed
ERASE MESSAGE
Not needed3.

You may now run the Asynchronous
Communications Support program by doing
the following:
CD \ASYNC
Operate from the subdirectory
AUTO EXEC
Run the program
CD \Return to the root directory

K-8

4.

You may run the file conversion program,
FILECONV, by doing the following:
CD \ASYNC
Operate from the subdirectory
FILECONV
Run the FILECONV program
CD \Return to the root directory
Notes:
1.

The use of the subdirectory name of
ASYNC is an example only. You may use
any name you wish.

2.

All file transfers will be to and from thefiles in the subdirectory unless theprinter is the destination.

3.

This program tests the length of afilespec, and does not accept
subdirectory names as part of a filespec.

4.

You may rename AUTOEXEC.BAT if
you choose.

K-9

EasyWriter Version 1.10
To use EasyWriter Version 1.10 with DOS 2.00
it is recommended your IBM Personal Computer
have a minimum of 128K bytes of memory.
To copy DOS 2.00 to your EasyWriter program
diskette, use the following procedure:
1.

Follow the instructions in the "Startup"
section of your EasyWriter manual forcopying DOS to your EasyWriter program
diskette. While copying DOS 2.00 to theprogram diskette, you may see the message:
INSUFFICIENT DISK SPACE(or)SECTOR NOT FOUND ERROR WRITING DRIVE B
ABORT, RETRY, IGNORE?

If you see the second message above, enter I(for ignore).
Note: For a system with a fixed disk,
follow the instructions for copying DOS
2.00 to your EasyWriter program
diskette for a one-drive system.
Due to insufficient diskette space, the DOS 2.00
FORMAT.COM utility was not transferred to your
EasyWriter diskette. To use the FORMAT.COM
utility, insert the DOS 2.00 diskette in drive A anda blank diskette in drive B. Then type:
FORMAT B: and press the enter key. This will
format the diskette in drive B.
2.

EasyWriter 1.10 recognizes drive A anddrive B as the drives to read or write from for
EasyWriter files. Because the fixed drive is
initially defined as drive C, you must reassign
its name to be drive B. Enter:
ASSIGN B=C

K-I0

3.

You can have your fixed disk automaticallyassigned to be drive B every time you load
your EasyWriter program. Use the following
procedure to do this:a.

Copy DOS 2.00 onto your EasyWriterprogram diskette following the
instructions given above.

b.

Start DOS 2.00 from the fixed disk. The
DOS prompt C> should appear.

c.

Put your EasyWriter program diskette
into drive A.

d.

Enter COPY ASSIGN. COM A:e.

Enter COpy CON A:AUTOEXEC.BAT

f.

Enter DATEg.

Enter TIMEh.

Enter ASSIGN B=Ci.

Enter EWj.

Enter ASSIGNk.

Press the F6 key. Now press the Enterkey.

The fixed disk can now be used to store andread your EasyW riter data files. Every time
you load your EasyWriter program the fixed
disk will automatically be assigned as drive B.

K-ll

Fact Track
To use Fact Track with DOS 2.00 you need 96K
bytes of memory.
If you have DOS 1.10, you should use it to follow
one of the setup procedures documented in theFact Track user manual. The setup procedure
copies the necessary DOS programs onto the Fact
Track program diskette. From then on, start theFact Track program diskette in drive A.
If you have only DOS 2.00, and if you have an IBM
Personal Computer with one or two disk drives,
you should start up DOS in drive A. Enter the date
and time as requested. When the system responds:A>

you enter:
BASleA

When the system responds:

OK
remove the DOS diskette from drive A and insert
the Fact Track diskette into drive A and close thedoor.
Enter:
RUN "COLOR

Do this every time you want to run the Fact Trackprogram.

K-12

If you have DOS 2.00, but do not have DOS 1.10,
and an IBM Personal Computer with a fixed diskthat contains DOS or BASICA, you should start up
DOS from the fixed disk. Enter the date and time
as requested. When the system responds:C>
put the Fact Track program diskette in drive A andclose the door.
You enter:
A:

When the system responds:A>
you enter:
C: BASICA COLOR

Do this every time you want to r~n the Fact Trackprogram.

K-13

PFS:File
To use PFS:File with DOS 2.00 you need aminimum of 128K bytes of memory.
Follow the instructions in Part 1 of theIntroduction "Getting Ready to Use File." Useyour DOS 2.00 diskette whenever the instructions
ask for the DOS diskette.

Using PFS:File with the IBM Fixed Disk
You can use PFS: File with the IBM fixed disk in
two different ways. First, you can store your files
on the fixed disk, thus allowing larger files to be
stored, and faster access to forms in the stored
files. Second, you can copy the PFS:File program
to the fixed disk and then load it from there. This
allows you to load the program faster, without
using the program diskette.

Storing a PFS:File on the Fixed Disk
You can store a PFS: File on the fixed disk
provided you include the drive identifier for the
fixed disk as part of the file name. If you specify
the fixed disk drive as the default drive, then it is
not necessary to include the drive identifier as partof the file name.

K-14

Copying PFS:File to the Fixed Disk
Follow these steps to copy the PFS:File program
to the fixed disk:
1.

Insert the DOS 2.00 diskette into drive A andturn on your IBM Personal Computer. Enterthe date and time when the computer asks
you to do so.

2.

When the DOS prompt appears, remove the
DOS 2.00 diskette and replace it with the
PFS:File program diskette.

3.

Follow the instructions in Appendix D of the
PFS:File manual called "Setting Up a Serial
Printer and the Work Drive" to run the setup
program. Change the work drive name to thedrive name of your fixed disk. For example, if
your fixed drive is drive C, then the work
drive item on the setup menu should be
drive C.

4.

If you have a serial printer, enter the correct
values for the other items on the setup menu.

5.

Press the FI0 key to complete the setup
program. Then enter FTRANS in response to
the DOS prompt.

The in use lights will come on alternately as the
program is copied from the diskette to the fixed
disk. The copy is placed in the current directory.
The DOS prompt reappears when the copy iscomplete.
If you have more than one fixed disk, the copy will
be made to the drive whose name is last in thealphabet. For example, if two drives are named C
and D, the copy will automatically be made todrive D.

K-15

Error Conditions
The following error conditions might occur during
the copy procedure.
Message

Explanation

Corrective Action

CAN'T COpy
PROG RAM FILE

Your program
diskette has beendamaged.

Try the copy
procedure withthe backup copyof the program
diskette.

Your fixed disk is
il!lproperly
formatted.

Copy to diskette
any files on the
fixed disk. Then
reformat the fixed
disk, and try the
copy procedureagain.

CAN'T CREATEPROGRAM FILE

Your root level
directory is full.

If you haveunnecessary files
in the root level
directory, deletethem and start the
copy procedureagain.

NAME ERROR

Possible DOS
error.

Reload DOS 2.00
and start the copy
procedure again.

WRONG
VERSION

Cannot find thefixed disk.

Make sure thatyour fixed disk isproperlyconnected, andthat you are using
DOS 2.00.

K-16

Running the PFS:File Program from aFixed Disk
To run the PFS:File program from a fixed disk,
make sure that you have followed the instructions
under "Copying PFS:File to the Fixed Disk." Thenin response to the DOS prompt, type and enter
the drive identifier for the fixed disk followed by
the name of the program. For example, to run theFile program from drive C, enter C: FILE. If thedefault drive is C, you need only enter FILE in
response to the DOS prompt.

Changing Settings When Using the Fixed Disk
To change the work drive or the information
stored for your serial printer after copying the
PFS:File program to the fixed disk, you need toinsert the PFS: File program diskette into drive A
and run the setup program from that diskette. Use
the COpy command to copy the file named
IBMSETUP. PFS from the diskette in drive A tothe fixed disk.

K-17

PFS: Rep,ort
To use PFS: Report with DOS 2.00 you must havea minimum of 128K bytes of memory, and you
should do the following:1.

Copy the sample file called STAFF, which ison the Report program diskette, to a blankformatted diskette or to a fixed disk. See"Formatting Diskettes" and "Copying a File"in Appendix C of the PFS: Report manual.

2.

Erase the STAFF file from the Reportprogram diskette using the ERASE commandof DOS 2.00.

3.

Now follow the instructions in Part 1 of theIntroduction in the PFS: Report manual"Getting Ready to Use Report." Use yourDOS 2.00 diskette when the instructions ask
for the DOS diskette.

Using PFS:Report with the IBM Fixed Disk
You can use PFS:Report with the IBM fixed disk
in two different ways. First, you can store yourfiles on the fixed disk, thus allowing larger files tobe stored, and faster access to forms in the stored
files. Second, you can copy the PFS: Reportprogram to the fixed disk and then load it fromthere. This allows you to load the program faster,
without using the program diskette.

Storing a PFS:File on the Fixed Disk
You can store a PFS:File on the fixed disk
provided you include the drive identifier for the
fixed disk as part of the file name. If you specify
the fixed disk drive as the default drive, then it is
not necessary to include the drive identifier as partof the file name.
K-18

Copying PFS:Report to the Fixed Disk
Follow these steps to copy the PFS:Reportprogram to the fixed disk:
1.

Insert the DOS 2.00 diskette into drive A andturn on your IBM Personal Computer. Enterthe date and time when the computer asks
you to do so.

2.

When the DOS prompt appears, remove the
DOS 2.00 diskette and replace it with the
PFS:Report program diskette.

3.

Follow the instructions in Appendix D of the
PFS:Report manual called "Setting Up a
Serial Printer and the Work Drive" to run the
setup program. Change the work drive nameto the drive name of your fixed disk. For
example, if your fixed drive is drive C, then
the work drive item on the setup menu should
be drive C.

4.

If you have a serial printer, enter the correct
values for the other items on the setup menu.

5.

Press the FlO key to complete the setup
program. Then enter RTRANS in response to
the DOS prompt.
The in use lights will come on alternately as
the program is copied from the diskette to the
fixed disk. The copy is placed in the current
directory. The DOS prompt reappears when
the copy is complete.
If you have more than one fixed disk, thecopy will be made to drive whose name is lastin the alphabet. For example, if two drives are
named C and D, the copy will automaticallybe made to drive D.

K-19

Error Conditions
The following error conditions might occur during
the copy procedure.
Message

Explanation

Corrective Action

CAN'T COpy
PROGRAM FILE

Your program
diskette has beendamaged.

Try the copy
procedure withthe backup copyof the program
diskette.

Your fixed disk isimproperly
formatted. (alsoapplies to the
CREATEmessage)

Copy to diskette
any files on the
fixed disk. Then
reformat the fixed
disk, and try the
copy procedureagain.

CAN'T CREATEPROGRAM FILE

Your current
directory is full.

If you haveunnecessary files
in the current
directory, deletethem and start the
copy procedureagain.

l'JAME ERROR

Possible DOS
error.

Reload DOS 2.00
and start the copy
procedure again.

WRONG
VERSION

Cannot find thefixed disk.

Make sure thatyour fixed disk isproperlyconnected, andthat you are using
DOS 2.00.

K-20

Running the PFS:Report Program from aFixed Disk
To run the PFS:Report program from a fixed disk,
make sure that you have followed the instructions
under "Copying PFS:Report to the Fixed Disk"(make sure the current directory contains PFS).
Then in response to the DOS prompt, enter thedrive identifier for the fixed disk followed by thename of the program. For example, to run theReport program from drive C, enter: C:REPORT.
If the default drive is C, you need only type andenter REPORT in response to the DOS prompt.

Changing Settings When Using
the Fixed Disk
To change the work drive or the information
stored for your serial printer after copying the
PFS:Report program to the fixed disk, you need toinsert the PFS:Report program diskette into
drive A and run the setup program from thatdiskette. Use the COpy command to copy the file
named IBMSETUP.PFS from the diskette in drive
A to the fixed disk.

K-21

The Dow Jones Reporter Version 1.00
The Dow Jones Reporter Version 1.00 directs data
to be saved only on diskette drive A. In addition,
the program diskette is copy protected, and you
cannot install the program on a fixed disk.
Dow Jones is a registered trademark of the Dow
J ones Company, Inc.

K-22

SNA 3270 Emulation and RJE Support
Version 1.00
To use SNA 3270 Emulation and RJE Support
Version 1.00 with DOS 2.00 you need a minimumof128K bytes memory.
To install this application in a subdirectory, SNA,
on a fixed disk, use the procedure described
below, which assumes the following:•

The fixed disk is drive C.

•

The fixed disk drive is the default drive.

•

The root directory in the fixed disk contains
DOS 2.00.

The Procedure1.

Insert the SNA program diskette into diskette
drive A.

2.

Edit the files 3270COPY.BAT and
SRJECOPY.BAT to change all drive B
references to drive C.

K-23

3.

Enter the following commands to create thesubdirectory, SNA, and to copy the needed
files from drive A to drive C.
MD \SNA
Create the subdirectory
CS \SNA
Operate from it
A:3270COPY
Copy required files
A:SRJECOPY
Copy required files
COpy C\BASIC.COM C:\SNA
Copy a needed file4.

You may now run the SNA program byentering the following commands:
CD \SNA
Operate from the SNA subdirectory
programnameEnter the correct program name as
specified in the SNA manual in responseto the DOS prompt
CD \Return to the root directory
Notes:

K-24

1.

The use of the subdirectory name
SNA is as an example only. You may
use any name you wish.

2.

All file transfers for SRJE are to andfrom files in the SNA subdirectory.

3.

The SNA program does not accept
subdirectory names as part of afilespec.

Typing Tutor
To use Typing Tutor with DOS 2.00 it isrecommended that your IBM Personal Computer
have at least a minimum of 64K bytes memory. If
you have a single diskette drive system, you should
use the single drive setup procedure.

K-25

VisiCalc Version 1.10 by VisiCorp.
To use VisiCalc Version 1.10 with DOS 2.00 it isrecommended that your IBM Personal Computer
have a minimum of 128K bytes of memory. The
following are procedures to put DOS 2.00 on your
VisiCalc program diskette, and to make yourprogram diskette self starting for fixed disk. These
procedures assume the following:•

You have at least one diskette drive and one
fixed disk.

•

You are familiar with loading DOS 2.00 fromyour fixed disk.

•

You are aware that VisiCalc supports a
maximum of two secondary storage devices.
Only one of these two devices may beaccessible during operations.

Putting DOS 2.00 on Your Program Diskette
Follow these steps to put DOS 2.00 on your
VisiCalc program diskette and to make thatdiskette self starting:

K-26

1.

Start DOS 2.00. You should see the DOS
promptC>.

2.

Remove the write protect tab from the
VisiCalc program diskette.

3.

Place the program diskette into drive A.

4.

Enter COpy COMMAND. COM A:

5.

Enter SYS A:

6.

Enter COpy ASSIGN. COM A:

7.

Enter COpy CON A:AUTOEXEC.BATs.

Enter DATE

9.

Enter TIME

10. Enter ASSIGN B=C (or any other drive

designator)
11. Type VCSO (space) (press F6) (enter)
12. ASSIGN

13. Remove the program diskette and replace thewrite protect tab on your program diskette.

The fixed disk can now be used to store andretrieve your VisiCalc data files. Every time you
load your VisiCalc program the fixed disk will beassigned as drive B.

K-27

3101 Emulator Version 1.00
To use the 3101 Emulator Version 1.00 with DOS
2.00 requires a minimum of 96K bytes memory.
Use the procedure described below to install the3101 Emulator in a subdirectory, EM3101, on the
fixed disk. The procedure assumes the following:•

The fixed disk is drive C.

•

The fixed disk is the default drive.

The Procedure1.

Insert the 3101 Emulator program diskette
into drive A.

2.

Enter the following commands to create thesubdirectory, EM31 01, and to copy theneeded files from drive A to drive C:
MD \EM3101
Create the subdirectory
CD \EM3101
Operate from it
COpy A:*.* C:\EM3101
Copy all files on the 3101 Emulator
program diskette
ERASE COPYFILS.BAT
Not needed
ERASE AUTOEXEC.BAT
Not needed
CD \Return to root directory

K-28

3.

You may now run the 3101 Emulator byentering the following commands:
CD \EM3101
Operate from the EM3101 subdirectory
IBM3101
Run the 3101 Emulator program
CD \Return to the root directory4.

You may run the file conversion program,
FILECONV, by entering the following
commands:
CD \EM3101
Operate from the EM3101 subdirectory
FILECONV
Run the file conversion program
CD \Return to the root directory
Notes:
1.

The use of the subdirectory name
EM3101 is as an example only. You may
use any name you wish.

2.

All file transfers will be to and from files
in the EM3101 subdirectory.

3.

The 3101 Emulator does not accept
subdirectory names as part of a filespec.

K-29

Notes:K-30

IndexSpecial Characters. - period 7-8,7-18.COM file format 10-13\ backslash 2-30, 2-39
~ backspace key 2- 34+ (plus sign)in automatic response
file 11-23
in response to linker
prompt 11-23$ $ $ - filename
extension 7-4* - asterisk 2-41
* - EDLIN prompt 2-41,
7-5, 7-10* - global filename
character 6-14

* character, using 2-18
- (DEBUG prompt) 12-15~key

2-33,2-40/P parameter 6-83

/S option C-5/V parameter 6-43
/W parameter 6-83
/1 parameter 6-94
/1 parameter,
DISKCOMP 6-91
/8 parameter,
DISKCOMP 6-91
% (percent sign) 6- 33? - global filename
character 6-14

? character 2-18, 6-14

# - pound sign 7-7@ character 2-48
@ symbol (linker)= equal sign 6-8

A
A> prompt 6-1 7
abort program B-5
abort read/write
operation 8-4
about diskettes 1-7
absolute disk read D-9
absolute disk write D-10
absolute diskettesectors B-2
absolute sector 12-63
absolute segment
address E-7
how to determine 11-28
absolute track/sector,
calcula te C-5
AC flag set
condition 12-50
access, random B-5
accessing a file 9-9
adding hexadecimalvalues 12-34
address - DEBUG
parameter 12-7

X-1

address terminate
interrupt D-2
address, disk transfer 12-5
AH register D-16
allocating disk space B-5
allocating space B-5
allocating diskettespace C-6
allocation table
information D-26
allocation, diskette C-1
allocation C-1, C-2
analyzediskettes 6-100
status report 6-54
the directory 6-54the File Allocation
Table 6-54
Append Lines
Command 7-12, 7-46
applications,random/sequential 9-6
architecture, 8088 B-1
ASCII characters 12-22
ASCII codes,
extended D-17
ASCII representation 12-6
ASCII values 12-12
Assemble Command 12-16
assembler 11-4
ASSIGN (Drive)
Command 6-21
ASSIGN command 6-147
ASSIGN drivecommand 6-21
asterisk
EDLIN prompt 2-41,
7-5,7-10

X-2

global filename
character 6-14
Asynchronous
Communications Adapter
6-109, 6-113, 6-114
attribute byte E-11
attribute field 14-6
attribute, file C-4
AUTO EXEC file B-4
AUTOEXEC.BA T
file 6-31,6-81
automatic program
execution 1-16
automatic response file
linker 11-23
A UX - reserved devicename 6-13
Auxiliary Asynchronous
Communications
Adapter D-18
auxiliary carry flag 12-50
auxiliary input D-18
auxiliary output D-18
available functions,
DOS B-5
AX register 12-5, D-10,
D-16

B
backslash (\) 2-33, 2-43
backing up a diskette 3-10
backing up DOS 1-6
backing-up one file 3-18
backspace key ( 4---) 2- 34

BACKUP (Fixed Disk)
Command 6-24
BACKUP command 6-24,
6-147
backup diskette 6-92
back up 6-92
backup file, edit 7-6
backup more than one
file 3-29
BAK filename
extension 7-6, 7-21, 7-34
.BAK 7-6,7-21,7-34
BASIC Program
Editor 2-35
BAT filename
extension 6-28
Batch Commands 6-28
batch file 6-28, 6-48,
6-49, 6-136, 6-146.BAT 6-28
change 6-48
enter 6-136
batch file processor B-4
batch processing 6-28
BIOS D-9
BIOS interface
module B-1
BIOS Parameter
Block 14-16
block devices 14-4
block number,current E-ll
block read, random D-29
block write, random D-29
size D-27
blocking/deblocking,data B-1
boot record program B-1,
B-2

boundary, paragraph 11-6
boundary,8-byte 12-22
boundary, 16-byte 12-22
BP register 12-5, D-6
BPB, what is 14-16
brackets, square 6-8
BREAK (Control Break)Command 6-50
Break command 6-50,
6-147
Break key 2-25
breakpoint 12- 30
buffer, input 2-35
buffer, what is a 9-5
buffered standard
input D-19
BUFFERS command 9-4
buffers, file D-lbuilt-in functions B-1
BX register 12-5,12-39,
D-7
byte - DEBUG
parameter 12-8
byte contents
display 12-25
fill 12-29
replace 12-25
byte, attribute E-ll
byte, flag E-ll
bytes, about 1-11ccalculate absolutecluster C-9
calculate absolute
track/ sector C-5
calls, function D-13

X-3

carry flag 12-50
chaining file sectors B-5
change a filename 3- 37
change console,
CTTY 10-11
change date 6-80
change diskettes 6-48
change filenames 6-127
change time 6-136
changing active
partition 4-19
changing the current
directory 5-12
character devices 14-4
CHDIR (Change Directory)
Command 6-52
CHDIR command 6-37,
6-147
check for control
break 6-50
check keyboard
status D-19
checksum
methodology B- 3
CHKDSK (Check Disk)
Command 6-54
CHKDSK command 6-54,
6-147
CL register D-16
class 11-7
clear condition 12-50
clear screen 6-58
close file D-20
close D-20
CLS (Clear Screen)
Command 6-42
CLS command 6-147
cluster number,
relative C-6
cluster, calculate C-9

X-4

cluster, locate next C-8,
C-9
cluster, starting C-6
clusters B-6, C-2
directory C- 3
codes, error D-5
codes, 8088
instruction 12-32
colon 6-8
Color/Graphics Monitor
Adapter 6-109
COM filename
extension 6-4, B- 3
.COM B-3.EXE B-4
COM programs E-5
comma 6-8
command line
linker 11-20
command parameters
DEBUG 12-7
DOS 6-9
EDLIN 7-7
command processor B- 3
command processor,
resident portion of B-3
command prompt,
DEBUG 12-14
command prompts,
linker 11-8
COMMAND.COM 6-100,
12-4, B-3, C-5, E-3
commands
DEBUG 12-15
DOS 6-17
EDLIN 7-9commands for
directories 5-11
commands, end 6-19
commands, enhanced A-9

commands, new A-5
commands, summary of
DEBUG 12-67
DOS 6-146, 10-28
EDLIN 6-36
Communications
Adapter 6-113
Communications Adapter,
Auxiliary
Asynchronous D-18
COMP (Compare Files)
Command 6-59
COMP command 6-59,
6-66,6-147
Compare Command 12-21
comparing diskettes 6-68
comparing 6-90
comparing files 6-59
comparing memory 12-21
compilers, using fixed
disk I-I
computer, size of your 9-7
CO M 1 - reserved devicename 6-13
CO N - reserved name forconsole/keyboard 6-13
concatenation 6-65,6-74
console I/O, direct D-19
console/keyboard 6-13
console/keyboard
routines B- 3
control blocks E-lcontrol keys 2-29,6-19,
7-10, 12-15
control screen cursor 13-4
copying your DOS
diskettes 1-6
copy a file to anotherdiskette 3-22

copy a file to samediskette 3-20
copy and combine
files 6-74
COpy command 6-28,
6-65, 6-92, 6-96, 6-148
Copy Lines
Command 7-13,7-46
copy more than one
file 3-29
copy with different
filename 6-71
copy with same
filename 6-69
copying diskettes 6-94
copying 6-94
copying files 6-65
correcting input lines 2- 35
create DOS partition 4-15
create file D-21
create D-23
creating a .BAT file 6-28
creating a batch file 6- 32
creating a device
driver 14-8
creating a new file 7-21
creating a
sub-directory 5 -11
critical error handler B- 3
critical error handler
vector D-4
critical error handling B- 3
CS register 12-5, 12-30,
12-32,12-37,12-58,
12-63, D-2, D-5, E-3, E-6
Ctrl key 2- 30
Ctrl-Break 11-9
CTRL-BREAK exit
address B-3, D-3

X-5

CTRL-BREAK
handler B-3
Ctrl-Break keys 2-25,
2-30,6-19,6-29,6-47,
7-10, 7-18, 7-23, 12-14
Ctrl-Enter keys 2- 30
Ctrl-Num Lock keys 2-27,
6-15,7-10,12-15
Ctrl-PrtSc keys 2-28,
6-107
Ctrl-Z character 6-75
Ctrl-Z keys 6-29
CTTY command 10-11,
10-29
CTTY (Change Console)
Command 10-11
current blocknumber E-11
current directory, changing
or displaying 5-12
current directory, whatis 5-6current disk D-26
current relative record
number E-12
cursor control 1 3-4
CX register 12-5, 12-6,
12-39, D-7
CY flag set
condition 12-50

Dd:default 6-9
parameter 6-9
data blocking/deblocking B-1

X-6

DATE Command 6-80,
6-148change 6-80
enter 6-80
date file created or
updated E-12
deblocking/blocking,data B-1
DEBUG commands
Assemble 12-16
Compare 12-21
Dump 12-22
Enter 12-25
Fill 12-29
Go 12-30
Hexarithmetic 12-34
Input 12-35
Load 12-36
Move 12-40
Name 12-42
Output 12-44
Quit 12-45
Register 12-46
Search 12-5 3Trace 12-55
Unassemble 12-57
Write 12-62
DEBUG programcommandparameters 12-7
commands 12-14
common information
12-14
ending 12-45
how to start 12-4
prompt 12-15
summary ofcommands 12-67
what it does 12-3

default disk transfer
address 12-5
default drive
linker 11-9
parameter 6-9
default drive, specifying
the 2-12
default segment 12-7
defective tracks 6-100
DEL Command 6-82
Del key 2-36, 2-38
delete DOS partition 4-12
delete file D- 2 2
delete D-23
Delete Lines
Command 7-14,6-46
deleting a directory 5-12
deleting a file 6-62
deleting DOS
partition 4-20
deleting files 6-98
delimiters -6-18, 7-9, 12-14
destination area 12-40
device driver,creating 14-8
device drivers 14- 3
device drivers,
installation 14-9
device error messages 8- 3
device field, next 14-5
device header 14-5
device names,
reserved 6-13, 6-18, 6-71
device redirection 10-4
devices, types of 14- 3
DGROUP 11-16
D I flag clear
condition 12-50
DI register 12-5, D- 5

DIR (Directory)
Command 6-83
DIR command 6-12, 6-83,
6-102, 6-148
direct console I/O D-19
direction flag 12-50
director, analyze 6-54
directory entries,
listing 6-83
directory path format 6-10
filenames 6-11
directory search,
PATH 6-117
directory searches C- 3
indirectory C-4
directory structure,displaying 5-12
directory types, how theywork 5-5
directory, display 6-138
directory, make 6-107
directory, remove 6-134
disk
current D-26
reset D-20
select D-20
disk error handling B-2
disk errors D-7
disk read, absolute D-9
disk transfer address 12-5,
E-5
disk transfer address,
set D-26
Disk Transfer Area
(DTA) B-6
disk write, absolute D-10
DISKCOMP (Compare
Diskette) Command 6-90

X-7

DISKCOMP
command 6-90, 6-96,
6-148
DISKCOPY (Copy
Diskette) Command 6-94
DISKCOPY command
6-90, 6-94, 6-148
diskette and drive
compatibility 1-14
diskette compatibility 1-14
diskette write-protect
notch 1-12
diskette, about your 1-7
diskette, copy a file toanother 3-22
diskette, copy a file tosame 3-20
diskette, finding what's
on a 3-30
diskette, getting ready 3-4
diskette, protecting youroriginal 3-11
diskette, remove a file 3-41
diskettes, backing up
DOS 1-6display
byte contents 12-26
flags 12-48
lines 7-27
registers 12-48
remarks 6-49
display contents ofdirectory 6-138
Display DOS version
number 6-143
display instructions 12-57
display output D-18
display partition data 4-22
display screen,shifting 3-44

X-8

display what's in a file 3- 34
displaying directory
structure 5-12
displaying memory 12-22
displaying the current
directory 5-12
divide-by-zero B-1
DN flag set
condition 12-50
DOSavailable functions B-5
commandparameters 6-9
control blocks E-l
disk allocation C-ldiskette directory C- 3
editing keys 2-35
how to start 2- 3
Initialization B-2
memory map E-l
program segment E- 3
structure B-1
technical
information B-1
work areas E-l
DOS commands
ASSIGN 6-21
BACKUP 6-24
Ba tch processing 6-28
BREAK 6-50
CHDIR 6-52
CHKDSK 6-54
CLS 6-58
commoninformation 6-17
COMP 6-59
COpy 6-65
CTTY command 10-11
DATE 6-80
DEL 6-82

DIR 6-83
DISKCOMP 6-90
DISKCOPY 6-94
ERASE 6-98
EXE2BIN
command 10-13
external 6-6
FIND Filter
command 10-16
FORMAT 6-108
GRAPHICS 6-106
internal 6-6
MKDIR command 6-107
MODE 6-109
MORE Filter 10-18
PATH 6-117
PAUSE 6-47
PRINT Command 6-120
PROMPT 10-19
RECOVER
Command 6-126
REM 6-49
RENAME(or REN) 6-129
RESTORE 6-131
RMDIR 6-134
SET command 10-12
SORT Filter 10-26
summary of 6-146,
10-27
SYS 6-135
TIME 6-136
TYPE 6-147
types of 6-6
VER Command 6-143
VERIFY
Command 6-143
VOL COp:1mand 6-145

DOS commands, advanced
CTTY command 10-11
EXE2BIN
command 10-13
FIND Filter .
command 10-16
MORE Filter
command 10-18
SET command 10-22
SORT Filter
command 10-26
DOS diskette, about
your iii
DOS editing keys
entering DOS
commands 6-1 7
examples using 2-40
using DEBUG 12-14
using EDLIN 7-9
DOS enhancements A-I
DOS environment E-4
DOS features A-I
DOS filters 10-7
DOS partitionchanging active 4-19
creating 4-15
deleting 4-20
display data 4-22
DOS version number,display 6-143
DOS, backing up yourdiskettes 1-6
DOS, giving acommand 3-3
DOS, how to start 2- 3
DOS, setting up thepartition 4-8
DOS, when it starts 4-5

X-9

drive 6-9
directory path 6-10
drive - DEBUG
parameter 12-8
drive compatibility 1-14
drive letters, fixed disk 4-4
drive specifier, whatis 2-17drive, assign new 6-21
drive, default 2-12
DS register 12-5, 12-6,
12-24, 12-29, 12-40, D-5,
E-6
/DSALLOCA TION linker
parameter 11-16
DTA (Disk Transfer
Area) B-5
dual-sided diskettes 1-8
dummy device 6-13
dummy parameters 6-32,
6-34
ECHO 6-35
Dump command 12-22,
12-67
DX register 12-5, D-5

E
ECHO
Subcommand 6-35,6-146
editbackup file 7-4
existing file 7-4
partial file 7-12
Edit Line Command 7-18,
7-46
editing a new file 7-5

X-to

editing keys 2-35, 6-19,
7-9, 12-15
editing template 2-35
EDLIN
Append Lines 7-12
commandparameters 7-7
commands 7-9
commoninformation 7-9
compared to DOS
editing keys 2-35
Copy Lines 7-1 3
crea ting a batch
file 6-22
Delete Lines 7-14
Edit Line 7-18
End Edit 7-21
how to start 7-4
Insert Lines 7-23
List Lines 7-27
Move Lines 7- 32
Page command 7-33
program 7-3
prompt 7-4
Quit Edit 7-34
Replace Text 6- 35
Search Text 6-39
Transfer Lines 6-44
used with DOS editingkeys 2-35
W rite Lines 6-45
EDLIN commands,summary of 7-46
EDLIN prompt 2-41
EDLIN, how to start 2-41
EDLIN, how to stop 2-52
EI flag set condition 12-50

ellipsis 6-8
emptying thetemplate 2-49
End Edit command 7-5,
7-21,7-46
end-of-file 6- 7 5
end-of-file mark C-7
ending commands 6-19
enhanced commands A-8
enhancements, DOS A-I
Enter command 12-25,
12-67
enter date 6-80
Enter key 2-27,2-32,6-13,
7-9
enter time 6-136
entries, search for D-22
environment, DOS E-4
environment, set 10-21
equal sign (=) 6-8
ERASE Command 6-98,
6-149
erasing files 6-98
erasing 6-98
error codes D-4
error handler B-7
error handling
critical B- 3
disk B-3
error message, device 8- 3
error messages 8- 3
error return table D-14
error trapping B-5
error, recover from 8-6
error, syntax 12-15
ES register 12-5, 12-6,
D-5, E-6
Esc key 2-33,2-36,2-39,
7-18
EXE file structure H-l

EXE filename
extension 6-7, 11-12,
12-6,12-39,12-66, B-4.EXE 12-6,12-39, E-3
EXE files, load H-l
EXE programs E-6
execute instructions 12-55
execute program 12-30
executing a .BAT file 6- 34
executing commands
within an application F-l
EXE2BIN
command 10-13, 10-28
existing file, edit 7-4$$$ 7-22
ext 6-12extended file control
block E-14
extensions 6-12
characters, valid 6-12
external commands 6-6,
B-4
.COM 6-7.EXE 6-7

F
FAT (see File Allocation
Table)
allocating space C-6
FCB E-ll
FCB (see File Control
Block)FDISK command 4-6,
4-13
features and differences of
DOS A-I
field name 14-8
field, attribute 14-6

X-It

File Allocation Table(FAT) B-5, C-6
file allocation table, how to
use C-8
file buffers D-1
File Control Block(FCB) 12-42, B-4, E-11
in file control
block E-11
file control block,extended E-14
File Management B-5
file sectors
chaining B-5
mapping B-5
file size E-9
file specifications 2-16
file structure, .EXE H··1
file, backing-up one 3-18
file, copy more than
one 3-29
file, display what's in 3-34
file, editing a new 7-5
filename characters,
global 6-14
filename, change a 3-37
filename, parse D- 30
filenamescharacters, valid 6-11
indirectory C-4
in file control
block E-11
length of 6-11
renaming 6-129
files/filenames,
what are 2-12
files, list all 6-84
files, list selected 6-86
files, number opened 9-10
filespec 6-12

X-12

filespec - DEBUG
parameter 12-8
Fill command 12-29,
12-67
Filter commands filtering
data 10-7
FIND Filter
command 10-16
First Asynchronous
Communications Adapter
port 6-13
fixed disk drive letters 4-5
fixed disk
partitioning 4-8
Fixed Disk Setup
Program 4-12
fixed disk, backup 6-19
fixed disk, preparing
your 4-3, 4-5
fixed disk, restore 6-131
fixed disk, select next
drive 4-23
fixed disk, start 4-12
fixed disk, using compilers
and macro assembler 1-1
fixups, segment 10-13
flag byte E-11
flag values 12-47
flags 12-5
flags, display 12-48
FOR Subcommand 6-37,
6-146
FOR 6-37
FORMAT Command 6-100
6-149, C-3
hidden C-3
format notation 6-5
FORMAT status
report 6-103

format, device drivers 14- 3
FORMAT, how to use 3-4
formatting yourdiskettes 1-7
fragmented diskettes 6-96
fragmented files 6-70
fragmented 6-70
function callparameters 14-16
function calls D-12
functions, available
DOS B-3functions, built-in B-1
F1 key 2-37,2-45,2-49
F2 key 2-37,2-45,2-46,
2-50,7-19
F3 key 2-38, 2-43, 2-44,
2-46,12-47,2-49,
7-19, 12-36
F4 key 2-38, 2-47
F5 key 2-38,2-47,
2-49,7-20
F6 key 6-10,6-24,6-52,
6-29

G
generating line
numbers 7-3
getdate D-31
time D-31
getting a disketteready 3-4
giving DOS acommand 3-3

global filename characters* 6-15? 6-14
examples using 6-15
in command name 6-19
in COPY 6-68
in DIR 6-84
in ERASE 6-98
in RENAME 6-129
global filename characters,
using 2-18, 3-43
Go command 12-30, 12-67
GOTO
Subcommand 6- 38, 6-146
GOTO 6-38
GRAPHICS (Screen Print)
Command 6-106
GRAPHICS
command 6-106,6-149
group 11-7

H
header H-1
helps and hints 3-46
HEX filename
extension 12-6, 12-39,
12-65.EXE 12-65.HEX 12-6, 12-39,
12-65
Hexari thmetic
command 12- 34, 12-67
hidden files 6-55,6-102,
C-4, D-25, E-14
attribute C-4
hidden D-25

X-13

HIGH 11-17
HIGH linker
parameter 11-7
high memory 11-16, 12-6,
B-3
how directories work 5-3
how to use tree-structured
directories 5 -3

I
IBMBIO.COM 6-83, 6-99,
6-102, B-1, B-2, C-5
IBMDOS.COM 6-83,6-99,
6-102, B-1, B-2, C-5
id=bat.Batch commands
IF Subcommand 6-40,
6-146
IF 6-31
initialization, DOS B-2
initialize
analyze 6-100
diskettes 6-100
initialize 6-100
initializing theasynchronous
adapter 6-113
input buffer 2-35
Input command 12- 35,
12-68
input files
linker 11-4
input, auxiliary D-18
Ins key 2- 39, 2-50, 12-51
Insert Lines
Command 7-23,7-46
insert mode 2-50,2-57,
7-23

X-14

inserting characters 2-50
inserting lines 7-4
installation of device
drivers 14-9
instruction codes,
8088 12-32
Instruction Pointer(IP) 12-5
instruction set, 8088 B-1
instructions
display 12-57
execute 12-55
unassemble 12-57
INT hex 24 B-7
INT 21 B-5
random B-5
sectors B-5
sequential B-5
interface module,
BIOS B-1
in ternal commandprocessors B- 3
internal commands 6-6
interrupt codes 12- 31
interrupt flag 12-50
interrupt hex 20 D-1
interrupt hex 22 B- 3, D-2
interrupt hex 23 B-3, D-3
interrupt hex 24 D-4interrupt hex 25 D-9interrupt hex 26 D-10
interrupt hex 27 D-I0
interrupt mechanism,
8088 B-1
interrupt routines 14-7
interrupt vectors B- 3
interrupt, set D-28
interrupts D-1

invoking one batch filefrom another 6-29
IP (Instruction
Pointer) 12-5
IP register 12- 30 , 12-47 ,D-5, E-6
IRET D-3

K
keyboard 6-1 3
keyboard input D-17
keyboard input,
buffered D-19
keys, control 2-27 , 6-9 ,
7-10,12-15
keys, DOS editing 2-35,
6-15,7-9,12-15
keys, reassign 1 3-11
keywords 6-8

LLINE 11-17
line - EDLIN
parameter 7 -7Line Editor Program 2- 35,
2-40, 7-3
line numbers 7-4lines, renumber 7-19, 7-23
LINK
See linker (LINK)
programlinker (LINK) programcommand line 11-20
command prompts 11-8
example session 11-25
messages 11- 30
starting 11-19
linker files

automatic response 11-4,
11-22
input 11-4
library 11-4, 11-13
listing 11-5, 11-12
object 11-4, 11-10
output 11-5
run 11-5, 11-12
linker parameters 11-15/DSALLOCATION
11-16/HIGH 11-17/LINE 11-17/MAP 11-17/PAUSE 11-18/STACK 11-18
linker prompts 11-10
list - DEBUG
parameter 12-9
list all files 6-84
list diskette files 3- 30
List Lines Command 7-27,
7-46
list one file 3- 32
list selected files 6-86
listing data lines 7-33
listing directory
entries 6-14,6-83
Load command 12- 36,
12-68
load module 11-28
loading . EXE files H-lloading DOS 2-3
loading programs 10-9loading standard device
drivers 9-8
locate next cluster C-7, C-8
logical record size E-12
logical sector
numbers D-9
LPTI - reserved name forprinter 6-13
X-15

M

N

macro assembler, using
fixed disk I-I
make directory,
MKDIR 6-80
/MAP linker
parameter 11-1 7
MAP extension 11-12.MAP 11-12
mapping file sectors B-4
memoryhigh 11-16, 12-6, B-3
low 11-16
memory management
routine B-4
memory status report 6- 39
memory, loading files
into 7-4
EDLIN 7-4
messages 8- 3
messages, linker 11- 30
MKDIR (Make Directory)
Command 6-80
MKDIR command 6-80,
6-114
MODE Command 6-82,
6-114
MORE Filter
command 10-18
MOV instruction C-8
Move command 12-40,
12-68
Move Lines
Command 7-32,7-46

n - EDLIN parameter 7-8
NA flag clear
condition 12-50
Name command 12-42,
12-68
name field 14-8
NC flag set
condition 12-50
new commands A-5
next device field 14-5
NG flag set
condition 12-50
notation, format 6-8
notch, write protect 1-10
NUL: - reserved devicename 6-13
numbers, line 7-3,7-15
NV flag clear
condition 12-50
NZ flag clear
condition 12-50

X-16oOB] extension 11-10.OB] 11-10
object files 12- 3
object 12-3
object modules 11-10
object program files 6-142
object program 6-142
text 6-142

open file D-21
operating systems, morethan one· 4-12
opera tion, suspend
system 2-28,6-47
optional remarks, PAUSE
command 6-47
Output command 12-44,
12-68
output files,
linker 11-5
output, auxiliary D-18
output, display D-18
OV flag set
condition 12-50
overflow flag 12-50

p
Page Command 7-33,7-46
paragraph boundary 11-6
parallel printer to
Asynchronous
Communications
Adapter 6-116
parameters
DEBUG 12-7
DOS 6-9dummy 6-33
EDLIN 7-6
testing withdifferent 12-30
parameters, function
call 14-16
parameters, Linker 11-15

parity flag 12-43
parse filename D- 30
partial file, edit 7-12
partition setup 4-8
partition, display data 4-22
partitioning your fixed
disk 4-12
Pascal hex patch J-l
PASKEY, see Pascal hex
patch J-l
PAS 1, update yourdiskette J-l
PATH (Set
Search Directory)
Command 6-11 7
PAUSE 8-7,11-18
PAUSE subcommand 6-47
PC register 12-47
PE flag set condition 12-50
percent sign (%) 6- 33
period (.) 7-8, 7-18
physical append 6-77
Piping standard I/O 10-6
piping, what is 10-6
PL flag clear
condition 12-50
plus signin automatic response
file 11-23
in response to linker
prompt 11-10
PO flag clear
condition 12-50
pointer to next
device 14-8
portaddress - DEBUG
parameter 12-9

X-17

pound sign (#) 7-9
prepare diskettes 6-100
preparing 6-100
preparing fixed disk 4-6
preparing your fixed
disk 4-6
PRINT Command 6-120
6-150'
print displayed output 2-28
print screen output 2-27
print string D-19
printer 2-27,6-13,6-109
printer output D-18
printing graphics 6-106
PRN - reserved name forprinter 6-13
program execution,
automatic 1-16
program execution,
stop 12-30
program segment
create new D-28
DOS E-3
Program Segment Prefix
12-6, B-2, B-5, E-5, E-7
program terminate D-17
PROMPT Command
10-19, 10-29
protect notch 1-12
protecting your original
diskette 3-11
protocol parameters 6-114
public symbols 11-25
punctuation 6-8

X-IS

Q
question mark 6-8
Quit command 12-45,
12-68
Quit Edit Command 7-34
7-46'
quotation marks 12-12R
random access B-5
random block read B-5,
D-29
random block write B-5,
D-29
random read D-27
random record field ,set D-28
random write D-27
random/sequential
applications 9-6
range - DEBUG
parameter 12-9, 12-10
Read-Only Memory(ROM) B-1
read/write requests 9-5
read, random D-27
read, random block D-29
read, sequential D-24
reassign keys 13-11
record number ,relative E-13

record size, logical E-12
recording format,. diskette 6-100
defective tracks 6-100
RECOVER Command
6-115
recover from error 8-6
redirection of I/O
devices 10-4
Register command 12-46,
12-68
registername - DEBUG
parameter 12-10
registernames, valid 12-47
registers, display 12-48
relative cluster number C-6
relative record
number E-13
relative sector
number 12-11
relative zero 11-26
relocatable loader 11-5
relocation H -3
remarks, display 6-49
remarks, PAUSE
subcommand 6-47
remove a file fromdiskette 3-41
remove directory,
RMDIR 6-134
removing a file 3-41
REN command 6-129
RENAME (or REN)
Command 6-129
RENAME command 6-129,
6-151

rename file D-25
renumber lines 7-19,7-23
replace byte
contents 12-25
replace standard
device 9-8
Replace Text Command
7-35,7-46
replacing characters 2-23,
2-50
reserved device names
6-1 3, 6-18, 6-72
reset, disk D-20
reset, system B-2
resident portion ofcommand processor B- 3
responses to the system 8-6
RESTORE (Fixed Disk)
Command 6-131
RESTORE command
6-1 3 1, 6-15 1
retry read/write
operation 8-6
RMDIR (Remove Directory)
Command 6-134
RMDIR command 6-134,
6-151
ROM (Read-Only
Memory) B-1
ROM BIOS routine D-18
root directory,
what is 5·-5
routines
device B-1
diskette handling B- 3
keyboard input B- 3

X-19

memory
management B-4
output B-3
printer output B- 3
ROM BIOS D-18
routines,
strategy/interrupt 14-7
run file 11-12ssaving diskettespace 10-13
screen 6-13
screen cursor control. 13-4
screen display
restart 2-27
suspend 2-27
screen output, print 2-27
screen print,
graphics 6-106
screen shifting 3-44
screen, clear CLS 6-58
Search Command 12-53,
12-68
search directory,
PATH 6~117
search for entries D-22
Search Text
Command 6-40,6-50
sector - DEBUG
parameter 12-11
sector number,
relative 12-11
sector numbers,
logical D-9
sector, absolute 12-63

X-20

sectors 6-95, 12-11
sectors, about 1-8
sectors, file B-4
segment 11-6
segment address E-7
SEGMENT
command 11-8
segment fixups 10-9
segment registers 12-5,
12-60
segment, create newprogram D-28
segment, default 12-7
segment, start H-3
segments, class 11-8
select disk D-20
selecting fixed disk drive,
next 4-23
semicolon delimiter 6-18
separators, filename D- 30
separators D- 30
terminators D-30
sequential read D-24
sequential write D-24
set
date D-31
interrupt D-28
random record
field D-28
time D-31
verify switch D- 32
SET (Set Environment)
Command 10-22
SET Command 10-22,
10-28
set condition 12-50
set system prompt
command 10-22

setting up the DOS
partition 4-8
Shift PrtSc keys 2- 30
SHIFT Subcommand 6-45,
6-146
SHIFT 6-45
shifting display
screen 3-39
SI register 12-5, D-5
sign flag 12-50
single diskette-drive
systems 1-14
single-drive system 6-92,
6-95
fragmented 6-95
single-sided diskettes 1-8
slashes 6-8
SORT Filter
Command 10-26
source area 12-40
source drive 6-1 7
source files 7-3
source 7-3
SP (Stack Pointer) 12-5
SP register E-5, E-6
space allocation B-6, C-lspace delimiter 6-8
special characters 6-14
specifying a drive 6-9
specifying the default
drive 2-12
specifying the path to a
file 5-7
square brackets 6-8
SS register 12-5, E-6
stack allocation
statement 11-18/STACK linker
parameter 11-18

Stack Pointer (SP) 12-5
stack, user D-5
standard I/O device
redirection 10-4
standard I/O, piping 10-6
start segment H -3
starting cluster C-5
starting DEBUG 12-4
starting DOS 2-3
computer power off 2-4
methods 2-3
starting EDLIN 7-4
starting the linker 11-19
static environment E-4
status report 6-54
stop program
execution 12-30
strategy routines 14-7
string - DEBUG
parameter 12-12
string - EDLIN
parameter 7-8
structure, DOS B-1
sub-directory, creatinga 5-11
sub-directory, what is 5-5
summing files 6-78
suspend screen
output 2-27
suspend system
operation 2-25, 2-28,
6-47
switch, high/low
loader H-3
symbols, global andpublic 11-17
syntax error 12-15
SYS (System)
Command 6-135

X-21

SYS command 6-135,
6-151
system configurationcommands 9- 3
system devices 6-1 3
system file E-ll
system files, transfer 6-135
system prompt 6-17, B- 3
system prompt command,set 10-19
system prompt, commandis complete 6-17
system reset B-2

Ttarget drive 6-19
technical information,
DOS B-1
template 2- 3 5
temporary file,
VM.TMP 11-5
terminate addressinterrupt D-2
terminate but stayresident B- 3
terminate commands 6-19
terminate program D-17
terminate programinterrupt D- 3
terminators, filename D- 30
text files 6-141,7-3
text 7- 3
TIME Command 6-136,
6-151
time, change 6-136
Trace command 12-55,
12-68
track/sector, calculate
absolute C-5

X-22

tracks, about 1-10
tracks, defective 6-100,
C-5
recording format 6-100transfer address, disk E-5
Transfer Lines
Command 7-44,7-46transfer system files 6-135transient portion ofcommand processor B- 3
TREE (Display Directory)
Command 6-138
TREE 6-138
TREE command 6-138,
6-151
tree-structured directories,
how to use 5-3
TYPE Command 6-141,
6-151
displaying contentsof 6-141
types of DOS
commands 6-4

uUnassemble
command 12-57, 12-68
unassemble
instructions 12-57
unprintablecharacters 12-2 2
UP flag clear
condition 12-50
user stack D-5
using fixed disk 4-12
using global filename
characters 2-18, 3-43

vw

value, DEBUG
parameter 12-1 3
variable length
instructions 12-58
VER (Version)Command 6-143
VER Command 6-143,
6-152
VERIFY Command 6-143,
6-152
verify switch D-28
VM.TMP temporary
file 11-5
VOL (Volume)
Command 6-145
VOL command 6-152
VOLUME Command 6-145

where DOS looks forcommands and batch
files 5-7
work areas E-1
DOS E-1
Write command 12-62,
12-68, 15-22
Write Lines
Command 7-45,7-46
write-protect notch 1-12
write, random D-27
write, random block D-29
write, sequential D-24

zzero flag 12-50
ZR flag set
condition 12-50

X-23

Notes:X-24

- -- --------- ---------_.-----The Personal Computer

Reader's Comment Form

DOS

6936752

Your comments assist us in improving the usefulness of
our publication; they are an important part of the input
used for revisions.
IBM may use and distribute any of the information you
supply in any way it believes appropriate without
incurring any obligation whatever. You may, of course,
continue to use the information you supply.
Please do not use this form for technical questions
regarding the IBM Personal Computer or programs for
the IBM Personal Computer, or for requests for
additional publications; this only delays the response.
Instead, direct your inquiries or request to your
Authorized IBM Personal Computer Dealer.
Comments:

111111

NO POSTAGE
NECESSARY

IF MAILEDIN THEUNITED STATESBUSINESS REPLY MAIL
FIRST CLASSPERMIT NO. 321

BOCA RATON, FLORIDA 33432

POSTAGE WILL BE PAID BY ADDRESSEEIBM PERSONAL COMPUTER
SALES & SERVICE
P.O. BOX 1328-C
BOCA RATON, FLORIDA 33432

aJalj PIO.:!

aldelS lOU op asealdadelContinued from inside front cover
SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU (AND NOT IBM OR
AN AUTHORIZED PERSONALCOMPUTER DEALER) ASSUME THE
ENTIRE COST OF ALL NECESSARYSERVICING, REPAIR OR
CORRECTION.
SOME STATES DO NOT ALLOW THE
EXCLUSION OF IMPLIEDWARRANTIES, SO THE ABOVE
EXCLUSION MAY NOT APPLY TO
YOu. THIS WARRANTY GIVES YOU
SPECIFIC LEGAL RIGHTS AND YOU
MAY ALSO HAVE OTHER RIGHTS
WHICH VARY FROM STATE TOSTATE.
IBM does not warrant that the functions
contained in the program will meet yourrequirements or that the operation of the
program will be uninterrupted or error
free.
However, IBM warrants the diskette( s) or
cassette(s) on which the program is furnished, to be free from defects in materials
and workmanship under normal use for aperiod of ninety (90) days from the date ofdelivery to you as evidenced by a copy ofyour receipt.
LIMITATIONS OF REMEDIES
IBM's entire liability and your exclusive
remedy shall be:
1. the replacement of any diskette( s) or

cassette(s) not meeting IBM's "Limited
Warranty" and which is returned to IBM
or an authorized IBM PERSONALCOMPUTER dealer with a copy of yourreceipt, or

IN NO EVENT WILL IBM BE LIABLE
TO YOU FOR ANY DAMAGES,INCLUDING ANY LOST PROFITS,
LOST SAVINGS OR OTHERINCIDENTAL OR CONSEQUENTIAL
DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE SUCHPROGRAM EVEN IF IBM OR AN
AUTHORIZED IBM PERSONALCOMPUTER DEALER HAS BEEN
ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES, OR FOR ANY
CLAIM BY ANY OTHER PARTY.
SOME STATES DO NOT ALLOW THE
LIMITATION OR EXCLUSION OF
LIABILITY FOR INCIDENTAL OR
CONSEQUENTIAL DAMAGES SO
THE ABOVE LIMITATION OR
EXCLUSION MAY NOT APPLY TO
YOU.
GENERAL
You may not sublicense, assign ortransfer the license or the program
except as expressly provided in thisAgreement. Any attempt otherwise to
sublicense, assign or transfer any of therights, duties or obligations hereunder is
void.
This Agreement will be governed by thelaws of the State of Florida.
Should you have any questions
concerning this Agreement, you may
contact IBM by writing to IBM Personal
Computer, Sales and Service, P. O. Box
1328-W, Boca Raton, Florida 33432.

YOU ACKNOWLEDGE THAT YOU
HAVE READ THIS AGREEMENT,UNDERSTAND IT AND AGREE TO
BE BOUND BY ITS TERMS AND
CONDITIONS. YOU FURTHER
2. if IBM or the dealer is unable to deliver a AGREE THAT IT IS THE COMPLETE
replacement diskette( s) or cassette( s)AND EXCLUSIVE STATEMENT OF
which is free of defects in materials or
THE AGREEMENT BETWEEN US
workmanship, you may terminate this
WHICH SUPERSEDES ANYAgreement by returning the program
PROPOSAL OR PRIOR AGREEMENT,and your money will be refunded.
ORAL OR WRITTEN, AND ANY
OTHER COMMUNICATIONSBETWEEN US RELATING TO THE
SUBJECT MATTER OF THISAGREEMENT.

-- ----- - ----------_
.-

--

®

International Business Machines Corporation
P.O. Box 1328-W
Boca Raton, Florida 33432

6936752
Printed in United States of America