A Quick DOS Tutorial

logo
    This is a quick tutorial for using DOS commands. It's primarily intended for Windows users who have limited experience with the conventions most long-time Dos users take for granted. Doskey and Batch files are briefly mentioned.

    The command line interpreter conventions used by ASHC11, DHC11, BINCVT, GMCKS, and other Tech Edge commands are also described here.

Getting to DOS from Windows

There are two basic ways to get to DOS from the Windows Desktop. Most of the time you will use the first (Dos BOX) options, as this is fastest and allows multiple Dos "sessions" to be active at the same time. The second method will not be described here as it has a quite different effect, and will close all active Windows programs (something you probably didn't want). To expand on this, to start up a Dos BOX, find the "Start Button" and click, then select the "Programs" option (either click or move the mouse), then find the "MS-DOS Prompt" item and click on it.

You should then get a window that has "MS-DOS Prompt" in the title bar, and the window will show text something like:

Microsoft(R) Windows 95
   (C)Copyright Microsoft Corp 1981-1996.

D:\xxx>
The "D:\xxx>" is called the Dos Prompt, and you will often hear people saying "at the Dos prompt, type ..". This means that you start up a Dos BOX, as shown above, and then start typing whatever is requested. The Dos prompt shows the current path name - D:\xxx in this case. The current path is made up of the Drive letter, in this case D, and the current directory name \xxx in this case. The colon (:) and the left triangle brackets (>) are just separators between the drive letter, directory name, and the prompt (which is the ">" symbol).

There is a third way to execute a Dos command without actually "going to Dos" (or starting a Dos box, as described above). This is done by:

This method will not be described here as it requires a lot of knowledge about the defaults Windows assigns to commands it runs. Using a Dos Box will, for someone with just rudimentary Dos knowledge, usually be quicker and easier than using the "Run" dialogue box.

DOS Commands

The most basic DOS command is dir to list the files in the current directory. At the DOS prompt you should type dir and then the [enter] key - Here's what I get when I do it:

D:\>dir

 Volume in drive D is D-SECOND
 Volume Serial Number is 0276-1809
 Directory of D:\

INFO           <DIR>        01-28-98  5:23p INFO
DOCS           <DIR>        01-28-98  5:22p DOCS
X        BIN        16,384  05-16-00  6:51a X.BIN
UNTITLED TXT         1,430  05-29-98  4:46p untitled.txt

         . . . . . . .

DEFAULT  HTM         2,036  06-11-98  2:20p default.htm
        17 file(s)        264,665 bytes
        12 dir(s)     389,242,880 bytes free

D:\>
There are other Dos commands you should know, including CD to change directory, TYPE to show the contents of ASCII (ie. human readable) files, and many others. Depending on how your windows has been set up, you may be able to type HELP and get a display of all available DOS commands. If not, then you may need to copy some of the files from your Windows installation disk.

On-line information about DOS commands can be found at places like http://ajclark.eng.umd.edu/~nsw/ench250/dostutor.htm but try your favorite search engine.

DOS Commands and Switches

The Tech Edge's Dos command, including DHC11, ASHC11, DHC11, etc. all use the same command line interpreter, and similar switch conventions. A switch is an optional addition to the information supplied when a command is invoked. For example, the Dos DIR command has a number of optional switches that can be seen if you issue the DIR /? command at a DOS prompt, as is shown here:

C:\>dir /?
Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/P] [/W] [/A[[:]attributes]]
  [/O[[:]sortorder]] [/S] [/B] [/L] [/V]

  [drive:][path][filename]
              Specifies drive, directory, and/or files to list.
              (Could be enhanced file specification or multiple filespecs.)
  /P          Pauses after each screenful of information.
  /W          Uses wide list format.
  ...         ...       ...       ...
Our point is that most DOS commands come with built in switches that can often be discovered by typing the command and adding a /?. Unix commands often use a similar convention, but with a minus (-) symbol to delimit successive switches.

Tech Edge Commands and Switches

Tech Edge's S19 is good program to study command line switches on. Help for BINCVT is obtained if BINCVT is typed at the Dos prompt with no parameters or switches; the output is shown below:

C:\BINS>BINCVT
BINCVT - Hex to Binary V0.00A (c) Copyright 2000 Tech Edge Pty. Ltd.

Usage:  infile -[option[=parameter] ...]

  options:
    -Output=     Name of binary file produced, default .BIN.
    -OVerwrite   Overwrite output file if it already exists.
    -Fill=       Hex fill character for uninitialised data, default $00.
    -Startaddr=  Start address for output data, default from hex input file.
    -Length=     Length of output data, default from hex input file.
    -Convert=    Conversion type (NO OPTIONS YET), default S19 -> BIN.
    ?            Show this help page.

C:\BINS>
taking each of these lines in turn:
BINCVT - Hex to Binary V0.00A (c) Copyright 2000 Tech Edge Pty. Ltd.
This is the program's title line showing the program's name, the version and the copyright owner and date.
Usage:  infile -[option[=parameter] ...]
This is the syntax for using the program. It says you must supply something called an infile, and optionally, you supply option(s) with (or without) an optional parameter (separated with an equals symbol, but no spaces). This is a fairly standard way of representing a command's syntax. The [syntax within square brackets] is optional, so brackets within brackets are optional parts of options. The ellipse marks (...) indicates that the previous part can be repeated, allowing a selection of options.

The options (also called switches) that can be used are detailed in the last part of the above message, reproduced below:

    -Output=     Name of binary file produced, default .BIN.
    -OVerwrite   Overwrite output file if it already exists.
    -Fill=       Hex fill character for uninitialised data, default $00.
    -Startaddr=  Start address for output data, default from hex input file.
    -Length=     Length of output data, default from hex input file.
    -Convert=    Conversion type (NO OPTIONS YET), default S19 -> BIN.
    ?            Show this help page.
Note that many options have defaults actions that occur, or parameters that are used, when no switch is supplied. Combining the above pieces of information, we arrive at some valid command lines:
D:\>BINCVT asbx.s19
This will automatically take ASBX.S19 and convert it to the binary ASBX.BIN, with the start and end addresses being defined by the S19 file. If we want to change the name of the file produced, to say X.BIN then we can use the -Output option that takes the desired output name as the parameter referred to above:
D:\>BINCVT amxy.s19 -o=x.bin
BINCVT - Hex to Binary V0.00 (c) Copyright 2000 Tech Edge Pty. Ltd.
513 lines read from amxy.s19, range from $C000 to $FFFF
output file x.bin has 16384 bytes ($4000).
Note that we only need to supply the O of output, and that we have not added any spaces between the O= and the file name X.BIN. Note also that we could have used lower case letters, or equally, we could have used upper case letters. In fact, all of the following command will have the same effect:

D:\>BINCVT amxy.s19 -Output=x.bin
D:\>BINCVT amxy.s19 -Out=x.bin
D:\>BINCVT AMXY.S19 -o=X.BIN
If the output file (AMXY.BIN) already exists, then the program will produce an error message as follows:
Output file "x.bin" already exists (use -OV option).
The OVerwrite switch tells the BINCVT command to overwrite the existing output file (we could also use a Dos command to delete or rename the existing file). Note that we must specify, as a minimum, the two characters OV, as just the O character means Output. The overwrite switch does not require any parameter. Here's the command and the output:

D:\>BINCVT amxy.s19 -o=x.bin ov
BINCVT - Hex to Binary V0.00 (c) Copyright 2000 Tech Edge Pty. Ltd.
513 lines read from amxy.s19, range from $C000 to $FFFF
output file x.bin has 16384 bytes ($4000).
Note that we have not used a hyphen (-) in front of the ov switch. The syntax tells us that we only need to use the first hyphen, however it is quite acceptable to use a hyphen as a prefix for all switches - this can improve the readability of the command line.

Some Notes About Tech Edge Command Lines

The following quick points are applicable to Tech Edge Dos Commands:

Other Dos Tips to Make Your Task Easier

The great advantage of most Dos commands is that they can usually be executed quickly. In contrast, most Windows programs use a file dialogue box that must be used to find the file you want to work on - this can be tedious and a great time waster. Dos programs work on the basis of finding files in the current directory, although they can be told to look in other locations.

Doskey

The argument against Dos is that you have to type a lot of characters to get anything done. In fact, using the doskey program, you can retrieve any of the previous Dos commands you have entered (try doing that under Windows). Here's the help text for doskey, although the most important switch for beginners is probably /insert

D:\>doskey/?
Edits command lines, recalls command lines, and creates macros

DOSKEY [/switch ...] [macroname=[text]]

  /BUFSIZE:size Sets size of macro and command buffer            (default:512
  /ECHO:on|off  Enables/disables echo of macro expansions        (default:on)
  /FILE:file    Specifies file containing a list of macros
  /HISTORY      Displays all commands stored in memory
  /INSERT       Inserts new characters into line when typing
  /KEYSIZE:size Sets size of keyboard type-ahead buffer          (default:15)
  /LINE:size    Sets maximum size of line edit buffer            (default:128
  /MACROS       Displays all DOSKey macros
  /OVERSTRIKE   Overwrites new characters onto line when typing  (default)
  /REINSTALL    Installs a new copy of DOSKey
  macroname     Specifies a name for a macro you create
  text          Specifies commands you want to assign to the macro

  UP,DOWN arrows recall commands
      Esc clears current command
       F7 displays command history
   Alt+F7 clears command history
[chars]F8 searches for command beginning with [chars]
       F9 selects a command by number
  Alt+F10 clears macro definitions

The following are special codes you can use in DOSKey macro definitions:
  $T     Command separator: allows multiple commands in a macro
  $1-$9  Batch parameters: equivalent to %1-%9 in batch programs
  $*     Symbol replaced by everything following macro name on the command line
So, if we have doskey running we can simply hit the UP arrow key to recall the last entered command. In the case of running BINCVT, say we get a message as follows:
D:\>BINCVT amxy.S19VT -o=x.bin
BINCVT - Hex to Binary V0.00 (c) Copyright 2000 Tech Edge Pty. Ltd.
513 lines read from amxy.s19, range from $C000 to $FFFF
Output file "x.bin" already exists (use -OV option).
Rather than retype the whole command, you only need to press UP arrow and type in (space) -ov. This is shown below:
D:\>BINCVT amxy.s19 -o=x.bin
BINCVT - Hex to Binary V0.00 (c) Copyright 2000 Tech Edge Pty. Ltd.
513 lines read from amxy.s19, range from $C000 to $FFFF
Output file "x.bin" already exists (use -OV option).
--press UP arrow here--
D:\>BINCVT amxy.s19 -o=x.bin ov
BINCVT - Hex to Binary V0.00 (c) Copyright 2000 Tech Edge Pty. Ltd.
513 lines read from amxy.s19, range from $C000 to $FFFF
output file x.bin has 16384 bytes ($4000).

Multiple Customised DOS Windows (ie. Dos Boxes)

You can start multiple copies of a "DOS BOX". Each can be running different programs, and have different command histories. It is very easy to switch from one Dos Box to another, and between Windows applications.

By default, the Dos Box will display 25 lines of text. If you click on the MOS-DOS icon in the Dos Box's title bar, and select "Properties", you'll see under the "Screen" tab that you can set the initial screen to display up to 50 lines of text. You can also set the font so that those 50 lines will fit neatly on your particular screen size.

Under the "Misc." Properties tab you'll see there's a "Background" option that lets you suspend, or allow the Dos Box to process in the background. As most PCs are quite quick these days, this isn't so important, but if you un-check the "Suspend" option then you can have Dos programs running "in the background".

Batch Files

If you execute a series of commands one after the other, and you may do this regularly, then you can use a batch file to automate your task. A batch file is simply a text file that has a number of Dos commands on successive lines. Say I want to disassemble a BINary file, check the disassembly by reassembling, then convert the disassembler's BINCVT file output to another binary file, then compare the original and new BINary files. The following batch files will do this:
D:\>type cmp.bat

dhc11 amxy -ov b # @                     <-- this disassembles
ashc11 amxy.dis                          <-- this re-assembles
BINCVT amxy.s19 -o=amxy.bim -ov          <-- convert S19 to binary
fc amxy.bin amxy.bim                     <-- compare original and new bonaries

D:\>
Dos has on-line help for batch files - type help batch for information.

Other Reasons

Microsoft would probably like DOS to go away because they make more money if they sell Windows-only programs. Hardware vendors also get to make more money selling the latest and most powerful PC/laptop.

There a millions of Dos programs, of various qualities, that will solve just about any problem you have. In addition, you don't have to buy the latest 800 Mhz Pentium V to run Dos, just a simple monochrome laptop will run most of these programs (people throw these laptops out because they think they need more processing power!).

If you're a Windows ONLY user, then taking the time to "learn Dos" will pay dividends in the long run.
















Text Last Updated 16th May 2000 (counter 29th Aug 2001)

Statistics by   www.digits.com
Shows approximate hits since 29th Aug 2001.


Copyright

This document is copyright © 2000, Tech Edge Pty. Ltd.
Author P. Gargano

Home | DOS Tutorial Feedback | Copyright