home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
info
/
dostips5.arc
/
DOSMISC
< prev
next >
Wrap
Text File
|
1986-12-17
|
49KB
|
1,092 lines
Switch Hitter
(PC Magazine Vol 5 No 13 July 1986 User-to-User)
Some people prefer the UNIX standard of "/" for a directory
separator and a "-" for a command switch. Making the change is simple
using the undocumented DOS Function Call 37. All you have to do is
change the switch character from "/" to "-". To create SWITCHAR.COM,
extract and name the file below SWITCHAR.SCR. Use DEBUG and issue the
command: DEBUG < SWITCHAR.SCR
To use SWITCHAR.COM, type SWITCHAR X where X is the new switch
character. Or just type SWITCHAR to reset the switch to the normal /.
For instance, if you type SWITCHAR - you can then get a paused
directory listing by typing DIR -P instead of DIR/P.
Editor's Note: Using nondocumented calls can create problems.
IBM removed its own SWITCHAR config function from DOS; if you feel the
need to reconfigure your switch character, you'll be experimenting at
your own risk.
SWITCHAR.SCR:
N SWITCHAR.COM
A
JMP 0120
DB 'Switch character is now "/"',0D,0A,'$'
MOV DL,[0080]
CMP DL,00 ; did get command argument?
JZ 012F
MOV DL,[0082] ; yes, use it as switchar
JMP 0130
MOV DL,2F ; no, use / (2F) as switchar
MOV AX,3701 ; AL=1 for setchar from DL
INT 21 ; set the switchar
MOV DI,0102
MOV [DI+19],DL ; modify the message
MOV DX,DI
MOV AH,09
INT 21 ; tell user what we did
INT 20 ; and exit
RCX
45
W
Q
-----------------------------------------------------------------
COPYing File to Themselves
(PC Magazine Vol 5 No 13 July 1986 PC Tutor)
A user invoked the command: ASSIGN A=C. Later he tried to copy
a hard disk file to a floppy using the command: COPY C:filename A:
COPY went ahead and tried to copy the file on top of itself. This
wouldn't have been so bad, except that the file was originally about
120K, and after the message "File allocation table error" was
displayed, the file ended up 64K long.
ASSIGN and COPY collided in this case. The ASSIGN command is bad
news. ASSIGN is a memory-resident program that intercepts most DOS
file calls and simply swaps disk drive letters. It was included with
DOS 2.0 and later to deal with those dumb pre-XT programs that assumed
every PC has only drives A: and B: and nothing more. All of the DOS
commands include warnings about using ASSIGN.
If you must use ASSIGN with certain programs, then don't issue
the ASSIGN commands indiscriminately. Put them in a batch file:
ASSIGN A=C B=C
{program that can't use drive C:}
ASSIGN
The last ASSIGN undoes all the ASSIGNments so you won't accidentally
do something like your fatal attempt to use the COPY command.
COPY will usually detect when you are trying to copy a file to
itself. For instance, if you have a file called MYFILE and you use:
COPY MYFILE MYFILE
it will tell you it can't do it. But COPY can be fooled. If MYFILE
is located in the root directory and you enter:
COPY MYFILE \MYFILE
COPY doesn't realize these are the same file. Obviously, COPY is only
doint a simple string compare to determine if you're trying to copy a
file to itself. This will always be a problem whenever your file is
larger than 64K.
Here's what happens in that case. COPY will open the first file
for reading. It will read 64K of the file into memory (less if 64K is
not available). It then tells DOS to create a second file. If the
second file already exists (as it does in this case), the file gets
truncated to 0 bytes and the space in the file allocation table is
freed up. Then COPY writes the 64K buffer to the second file. At
this point, COPY goes back to read the next chunk of the first file.
However, when DOS now takes a look at the file allocation table for
the first file, it finds that all the clusters have been unassigned.
-----------------------------------------------------------------
At Your Command
(PC World July 1986 Star-Dot-Star)
More and more programs can execute DOS commands while running,
but most are limited to just one command at a time. WordStar 3.3,
dBASE III Plus, KnowledgeMan/2, and Microsoft Word are a few. This
single-command limitation can be a nuisance. For example, if the
DOS command you want to execute is not in the current subdirectory,
or if you wish to perform several commands in sequence, completing
your task can take several steps.
If COMMAND.COM is executed, DOS will load a copy of itself into
memory, and you can then execute as many other commands as you like.
When you have finished, simply enter the EXIT command at the DOS
prompt, and the application program is returned.
Before issuing the EXIT command, be careful to return to the
subdirectory and logged disk drive that were originally in effect.
If you don't, the application program might not be able to find its
overlay files or other information that it needs to continue. Even
so, this may not work for all programs, all versions of DOS, or on
some "compatible" machines.
-----------------------------------------------------------------
Custom 3.2 DOS
(PC Magazine August 1986 User-to-User)
A prior article (PC Mag Vol 4 No 24 User-to-User) showed how to
default COMMAND.COM to ECHO OFF (rather than the annoying ECHO ON,
which forces users to brute-force it off in every batch file) and
allowed an ECHO with two spaces after it to generate a blank line.
It also explained why COMMAND.COM's CLS command cleared an extra line
and showed how to fix this.
DOS 3.2 has to be patched differently. For the ECHO+space+space
fix, type the following:
A>DEBUG COMMAND.COM
-E 3A88 83
-E 3A89 F9
-E 3A8A 02
-E 3A8B 72
-W
-Q
For ECHO OFF defaults for batch files, type:
A>DEBUG COMMAND.COM
-E 115E 02
-E 1B2C 00
-W
-Q
The CLS patch is not required in DOS 3.2.
-----------------------------------------------------------------
Sorting the Directory by Date
(PC Magazine August 1986 PC Tutor)
The most useful way to display a directory is chronologically by
date, with the most recently created or modified files at the bottom.
The SORT filter can be used with a month-day-year format. The normal
DIR listing is displayed in month-day-year format. Including the time
field would be useful, too, but that's complicated by the use of an
A.M. and P.M. identifier instead of a 24-hour clock.
DOS 3.0 or 3.1 (and presumably 3.2) can do this. These versions
contain internal tables that embody foreign-country information,
including date formats, time formats, currency symbols, decimal
separators, etc. This information is available for programs to use
through DOS calls. Although most programs don't take advantage of this
facility (it's not available in DOS 2.x), the programs and commands
included with DOS 3.x -- such as DIR -- alter their date and time
displays to those of the country currently set.
You can make DOS believe it's in a different country simply by
including a line in your CONFIG.SYS file. Of the support countries,
only Sweden uses the year-month-day format. So your CONFIG.SYS file
could have the line:
COUNTRY=046
The 046 is the code for Sweden. The numbers DOS uses are the
international telephone system country codes.
Reboot with the CONFIG.SYS file in the root directory of your
boot drive and do a DIR; it will look a little different, but the date
and time will be exacltly the way you need to have them run a sort by
year, then by months and days. Now you can set up a batch file with
the line:
DIR | SORT /+24
and you'll get a true date sort.
One problem with this procedure is that you may someday encounter
an applications program that insists on using the Swedish kroner symbol
instead of a dollar sign since DOS continues to use country information
you set with CONFIG.SYS and so believes it's in Sweden. If you'd rather
not spend all your DOS days in Sweden, you can remove the COUNTRY line
from your CONFIG.SYS file and use a couple of short programs to change
the country as you wish. These programs will let you fly to Sweden and
back again real quick. Use DEBUG to create the SWEDEN.COM file:
DEBUG
-N SWEDEN.COM
-A
2C7A:0100 MOV DX,FFFF
2C7A:0103 MOV AL,2E
2C7A:0105 MOV AH,38
2C7A:0107 INT 21
2C7A:0109 INT 20
2C7A:010B
-R CX
CX 0000
:B
-W
Writing 000B bytes
-Q
Also use DEBUG to create USA.COM:
DEBUG
-N USA.COM
-A
2C7A:0100 MOV DX,FFFF
2C7A:0103 MOV AL,01
2C7A:0105 MOV AH,38
2C7A:0107 INT 21
2C7A:0109 INT 20
2C7A:010B
-R CX
CX 0000
:B
-W
Writing 000B bytes
-Q
Your batch file would not look like:
SWEDEN
DIR | SORT /+24
USA
The value of the AL register in these programs is the same as the
country code used in the CONFIG.SYS COUNTRY statement but expressed in
hexadecimal rather than decimal numbers.
-----------------------------------------------------------------
Merging Two Files into One with DOS
(Personal Computing August 1986)
There is a section of the DOS COPY command that lets you join any
number of files into one file. At the A> or C> prompt, you simply type
COPY and the names of the files you want to join, with a plus sign
between each file name. Files from different drives can be joined by
specifying the drive before the file name. Here is an example of the
command used for combining three files:
COPY MEMOSMAY + MEMOSJUN + B:MEMOSJUL MEMOS.
In this example, the three memo files for May, June and July (in
drive B:) are combined into a new file, called MEMOS. If you don't
include a name for the new combined file, and separate it from the
end of the other file names by a space, this command will combine the
files in the first file named.
If you have a long string of files you want to combine and they
all have the same extension or previx to their names, you can use the
* symbol to indicate them. So, if we had three files with the prefix
memos, we could have typed:
COPY MEMOS* MEMOS
You have to be careful that this broad combine command doesn't pull in
files you don't want, but nonetheless start off with the letters
"memos." In like fashion, you can use the ? symbol in the command to
stand for any character. For example, if you have a group of files
that all end in a year number, such as MEMOS83, MEMOS84, and MEMOS85,
you could combine them into a new file by typing:
COPY MEMOS8? MEMOS86
-----------------------------------------------------------------
Alternate Configurations
(PC World August 1986 Star-Dot-Star)
If you happen to have any programs that don't run if ANSI.SYS is
present (there are some), you can use a batch file that renames
ANSI.SYS to ANSI.OFF, thereby preventing it from loading when the
computer is restarted. Instead, an innocuous error message appears
when the CONFIG.SYS file executes. Put the line:
IF EXIST ANSI.OFF REN ANSI.OFF *.SYS
which tests for ANSI.OFF. If ANSI.OFF is found, the line renames it
ANSI.SYS, enabling it to load normally the next time the computer
starts.
You can use a similar technique to temporarily eliminate any
device driver from the CONFIG.SYS file. This capability is useful if
hardware compatibility is an issue or if you want to reclaim memory
otherwise occupied by a device driver that you need only sporadically.
-----------------------------------------------------------------
Circumventing a DOS 3.10 Bug
(PC World August 1986 The Help Screen)
When assembling a master floppy disk for a new product, a bug in
DOS 3.10 was discovered that apparently hasn't been reported. The disk
was formatted with the command FORMAT/B to reserve space at the
beginning of the disk so users could add the DOS system files. Next
the relevant program files were copied to the disk. This is identical
to the procedure previously used to create master disks under DOS 2.10.
In attempting to make a bootable copy of the master disk, the DOS
commands SYS and COPY were used to place the hidden system files
(IBMBIO.COM and IBMDOS.COM) and COMMAND.COM onto the disk. The disk
was put in drive A: and the PC was rebooted. The screen cleared, the
cursor appeared, and drive A: started to whir. Just when it seemed the
drive should have stopped, the screen displayed roughly half a line of
binary code and several lines of greater-than (>) characters. DOS
refused to load.
The procedure was repeated several times with various blanks disks
and other copies of DOS 3.10 and on other PCs. The results didn't
change. IBM confirmed that a problem did indeed exist with the /B
option of the FORMAT command in DOS 3.10 and that no fix was available.
DOS 3.10 does not allocate enough space for the IBMBIO.COM system
module on the target disk. As a result, the SYS command, which
normally would make the disk bootable, does not work because the system
module becomes fragmented after the transfer.
It's possible to use FORMAT/S to put the system files on the disk,
add the product files, and finally use a utility to "zero out" the
IBMBIO.COM and IBMDOS.COM files. While DOS 3.10's SYS command will
work on such a disk, DOS 2.xx's SYS command fails to produce a bootable
disk. It's also feasible to instruct buyers to use FORMAT/S on a blank
disk and then COPY the product files. The rub, however, is that the
license agreement prohibits copying the product disk. In any event,
the DOS 3.10 manual is explicit about how disks should be prepared for
publication.
The problem at hand is to produce a master product disk whose
duplicates will work with the SYS commands of DOS 2.00 through 3.10.
Format a disk using the FORMAT/B command. Next, copy a dummy file
that consists of, for example, the company's name. Follow that by
copying the product files to the disk. Finally, erase the dummy file
using the DEL command. The disk space allocated by FORMAT/B plus the
contiguous sectors freed by erasing the dummy file will accommodate
the hidden system files transferred by the SYS command -- for IBM's
DOS, that is.
Owners of PC and AT compatibles generally use a version of MS-DOS
in which hidden system files are called MSDOS.SYS and IO.SYS.
Accordingly, when users of the program invoke the SYS command of such
a DOS version, they'll bump up against the file names IBMDOS.COM and
IBMBIO.COM, which occupy the first two directory entries. Because
compatible versions of the SYS command expect the names MSDOS.SYS and
IO.SYS, the error message "No room for system files on target disk"
will be returned; this will occur instead of the system files
overwriting the "unknown" files -- and possibly corrupting files on
the disk. To enable MS-DOS, as well as PC-DOS, users to place their
operating systems on the product disk, use a utility program to change
the first letters of the directory entries IBMDOS.COM and IBMBIO.COM
to ASCII nulls (00). From then on, all compatible versions of DOS
will be able to "SYS" the disk.
-----------------------------------------------------------------
Ctrl-Z Bypass
(PC Magazine Vol 5 No 15 Sept 16, 1986 User-to-User)
The DOS TYPE command stops as soon as it sees the first CHR$(26)
or Ctrl-Z end-of-file marker. If you need to find particular text
strings in binary files, TYPE doesn't always work. However, COPYing
file to the screen (CON) works the same way as TYPEing them, but with
one advantage -- the COPY command has a /B option that will ignore
each Ctrl-Z character. So to put the contents of COMMAND.COM on-screen
type:
COPY COMMAND.COM CON /B
While this will display the whole binary file, you'll probably see all
sorts of strange-looking characters on-scree, especially if you have
ANSI.SYS loaded.
Editor's Note: Adding a /B at the end tells the COPY command to
copy the actual length of the file as reported in the directory listing.
While this trick will display the whole file, it will still trip over
CHR$(7) beeps and other low-ASCII control characters. A better way to
hunt for text strings in binary files is to use a public domain utility
like BROWSE.COM (PC Mag Vol 5 No 6) or Norton's TS.COM text search
program.
-----------------------------------------------------------------
Quick COPY
(PC World September 1986 Star-Dot-Star)
The syntax for the COPY command given in the DOS manual implies
that everything except the word COPY and the first filename is
optional. In fact, the COPY command, like the ERASE and DEL commands,
assumes a source filename of *.* if a path alone is given. Thus, the
command COPY path is the equivalent of COPY path/*.*, just as the
command ERASE path is identical to ERASE path/*.*. The command COPY
path path is equivalent to COPY path/*.* path/*.*. This also works
for concatenation, thus the command COPY path filename is the same as
COPY path/*.* filename.
This tip may save only a few keystrokes, but if you frequently
copy files between subdirectories, you'll save a lot of time.
Editor's Note: This feature makes it possible to copy all of the
files from a subdirectory by simply "copying" the subdirectory name.
Notice that because this syntax also applies to the ERASE and DEL
commands, you could inadvertently delete an entire group of files with
a single command. For this reason, DOS always asks "Are you sure
(Y/N)?" before deleting all the files in a directory. That's your
signal to stop and reconsider. Be sure you really want to delete
every file before answering Y(es).
-----------------------------------------------------------------
Pipeline Execution
(PC Magazine Vol 5 No 16 Sept 30, 1986 User-to-User)
The DOS manual defines piping (which is invoked with the | symbol)
as the "chaining of programs" but shows only how to redirect the output
of DIR through SORT and FIND. You can also use piping to execute
several programs or commands in sequence. For instance, if you had a
GAMES subdirectory and a program called CHESS.COM, you could first
change directories and then run CHESS by typing:
CD GAMES | CHESS
If you had another game called CHECKERS.COM in the same subdirectory,
you could do the above and then run CHECKERS immediately after CHESS
by typing:
CD GAMES | CHESS | CHECKERS
Editor's Note: While this doesn't work with all DOS commands, it
does let you string certain operations together into one line. For
instance, if you wanted to create a subdirectory called TEST, copy all
the files from your current subdirectory into it, log into it, and
then, to see a directory listing, type:
md \test | copy *.* \test | cd \test | dir
-----------------------------------------------------------------
Backup Dater
(PC Magazine Vol 5 No 16 Sept 30, 1986 User-to-User)
When you're shuffling floppies in and out of a PC all day, you
can lose track of which disks you've backed up and which you haven't.
To get around this problem, create a tiny file on your disk called
BACKD_UP.ON. One way to do this is to get into BASIC and type
(directly, without line numbers):
OPEN "O",#1,"BACKD_UP.ON":CLOSE
and then hit Enter. Copy this file to your disks and correct the time
and date of the directory listing with the command:
TYPE BACKD_UP.ON > BACKD_UP.ON
This assumes you set your system date and time correctly, of course.
Then perform the actual backup process. Later, by looking at the date
in the directory listing for BACKD_UP.ON, you'll be able to tell at
which point during the day you backed up the disk.
Editor's Note: You don't need BASIC to creaet the BACKD_UP.ON
file; you can do it handily by using COPY CON:BACKD_UP.ON. And while
the:
TYPE BACKD_UP.ON > BACKD_UP.ON
file update method is a clever way to change the date, since if you try
running the command:
COPY BACKD_UP.ON BACKD_UP.ON
all you'll get is a "File cannot be copied onto itself" error message,
an easier way is with the little-used directory updating command:
COPY BACKD_UP.ON+,,
A completely different approach would be to use the DOS LABEL
command as a place for a date. To do so, patch COMMAND.COM so that
instead of saying "Volume in drive B: is ..." it would say, "Backed
up drive B: on ..." Then use LABEL to add the date. DIR would then
report "Backed up drive B: on 9-10-86". If you backed up additional
files later, you could use LABEL to change the date.
To patch COMMAND.COM, use the DEBUG Search command to find the
"Volume in drive" message by typing, at the DEBUG prompt:
S 100 6000 "Volume in drive"
In DOS 3.1, the address is 4A66. Use the Enter command to change both
the "Volume ..." message and the "is" that follows. In DOS 3.1, you'd
type:
E 4A66 "Backed up"
E 4A82 "on"
Then Write the changes and Quit.
-----------------------------------------------------------------
Disappearing Files
(PC Magazine Vol 5 No 16 Sept 30, 1986 User-to-User)
By modifying the PERM.COM and UNPERM.COM programs (PC Magazine
Vol 4 No 25 December 10, 1985 User-to-User) you can create HIDE.COM
and UNHIDE.COM to hide and unhide any program. A word of warning --
even though you can mass-hide files by creating a HIDEM.BAT batch file
with the single line:
FOR %%F IN (*.*) DO HIDE %%F
you won't be able to unhide all your files the same way, since global
file characters work only on what is actually produce by a directory
listing. Also, note that COMMAND.COM will execute a hidden AUTOEXEC.BAT
file when booting up. You can hide such system files as CONFIG.SYS,
VDISK.SYS, and even COMMAND.COM itself, which can give your disks a
bare root directory and a small measure of security. If you do try
the mass-hide, remember to keep UNHIDE.COM on a separate disk or
subdirectory.
Type the following with an ASCII word processor and name it
SCRIPT. Make sure you leave a space before the RCX and before the
W, and hit the Enter key after each line, especially the last one.
Put DEBUG.COM on your disk, go to DOS and at the DOS prompt type:
DEBUG < SCRIPT
to create HIDE.COM and UNHIDE.COM.
N UNHIDE.COM
A
MOV BX,80
INC BX
CMP BYTE PTR [BX],20
JZ 103
MOV DX,BX
INC BX
CMP BYTE PTR [BX],D
JZ 116
CMP BYTE PTR [BX],0
JNZ 10B
MOV BYTE PTR [BX],0
MOV CX,20
MOV AL,1
MOV AH,43
INT 21
INT 20
RCX
24
W
N HIDE.COM
A 119
MOV CX,27
W
Q
-----------------------------------------------------------------
DOS COPY Bug
(PC Magazine Vol 5 No 17 Oct 14, 1986 User-to-User)
PC Mag Vol 5 No 13 PC Tutor discussed the dangers of inadvertently
copying a file to itself when using DOS's ASSIGN command. The problem
is even more serious in DOS 3.1. This article pointed out that if a
file (here called MYFILE) resides in the root directory and you issue
the command:
COPY MYFILE \MYFILE
DOS will attempt to copy the file onto itself rather than issuing a
"File cannot be copied onto itself" message and stopping. If MYFILE
is larger than 64K, DOS will copy the first chunk of 64K and then
print a "File allocation table error" message.
Try this in DOS 3.1 with a file larger than 64K, and DOS will
print a normal "1 file(s) copied" message -- but will truncate the
file to 64K without warning you. This could be disastrous for those
unaware of the problem.
Editor's Note: While it's bad enough that DOS doesn't prevent
you from copying any file onto itself, it's more insidious that under
3.1 it doesn't even print out an error message that would alert you to
look at the directory listing and see what happened. And this problem
isn't just confined to the root directory. If you're logged into a
subdirectory called \DOS\UTILITY and you type COPY MYFILE MYFILE, DOS
will indeed issue a warning and stop before it makes a copy. But if
you type COPY MYFILE \DOS\UTILITY\MYFILE you're in trouble.
-----------------------------------------------------------------
Messages from CHKDSK
(PC Magazine Vol 5 No 17 Oct 14, 1986 PC Tutor)
Among other things, CHKDSK checks for consistency between the
disk's directory entries and its file allocation table (FAT). The FAT
is a map of the disk that shows how the disk's clusters are chained
to link the data in each file.
When you get a "lost clusters" message from CHKDSK, there's
usually not too much to worry about. What it means is that an area
on the disk has been allocated for a file but that the file was never
properly closed. The lost clusters are orphaned; the FAT says they've
been allocated, but they don't belong to any file. This sometimes
happens if the program creating the file terminates abnormally or runs
out of disk space and doesn't clean up afterward.
If you run CHKDSK with the /F parameter, it converts lost clusters
to files in the root directory and gives them the extension .CHK. If
your normal files are missing something, that data could be in one of
the .CHK files. You can take a look at the .CHK files with the TYPE
command, but unless they're in ASCII format and came from a word
processing document, you probably won't be able to do much with them.
If you're missing entire files from your directory, these .CHK files
may correspond to the missing files. This might be the result of
having a damaged directory. In such a case, the FAT still allocates
chained clusters as if they belonged to a file, but the directory
doesn't indicate where the chains begin.
Messages from CHKDSK indicating "cross-linked files" are cause
for more concern. Cross-linking means that the FAT's cluster chain
for two or more files intersects at some point, so that some clusters
seem to belong to multiple files. In other words, your FAT or
directory has probably been badly mangled. Although cross-linking is
relatively rate, it can be caused by gremlins (i.e., a power surge or
line drop during a disk write operation). In theory, gremlins strike
randomly, but in practice they do their thing only to your most
important files.
Watch out for this easy-to-make mistake: You can easily create a
cross-linked FAT and a mangled directory by replacing a disk before
typing an answer to an "Abort, Retry, Ignore" message. Say you're in
a program and try to save something to a floppy disk that has a write-
protect tab. DOS tries to write to the disk and then displays a
"Write Protect Error" message followed by "Abort, Retry, Ignore."
Instead of taking the write-protect tab off the disk (maybe you've
just realized that the disk is the wrong one), you choose to put in
another disk and press R for Retry. You can now kiss that data goodbye.
The problem is that DOS has already read FAT and directory
information from the disk and modified that information before trying
to write it back to the disk. It displays the "Abort, Retry, Ignore"
message only after it fails the write operation. When you hit R to
indicate Retry, DOS doesn't know that the disk has been replaced and
thus writes the modified FAT and directory (or part of it) that it's
read into memory from the original disk onto the new disk.
-----------------------------------------------------------------
3.2 Speed Bug
(PC Magazine Vol 5 No 18 Oct 28, 1986 User-to-User)
DOS 3.2 boasts an indidious (but easily correctable) bug --
Internal Stack Error. Simply hitting the Pause key on the new IBM
keyboard rapidly 10 times will produce this error message and lock
your system, forcing a power-down restart.
The DOS manual states that this error is caused by a "rapid
succession of recursive hardware interrupts" and suggests adding the
command STACKS=N,S to your CONFIG.SYS file. N represents the number
of stack frames, where the default is 9 and the range is 8 to 64. S
is the size in bytes of each frame, where the default size of each
stack frame is 128 bytes and the range is 32 to 512. Using this
STACKS statement reduces available memory.
While most users don't pound the Pause key, a fast typist
inputting data into a 123 spreadsheet can easily trigger the error.
The problem can be pretty much eliminated by adding:
STACKS=32,256
to the CONFIG.SYS file, which lets you pound the Pause key about 25
times before causing an error.
-----------------------------------------------------------------
3.2 COMMAND.COM Patch
(PC Magazine Vol 5 No 18 Oct 28, 1986 User-to-User)
DOS 2.0 through 3.1 COMMAND.COM can be patched to set the CLS
colors. (See PC Mag Vol 4 No 25 dec 10, 1985.) The instructions for
customizing DOS 3.2 so that CLS produces bright yellow text with a blue
background follow. Create a file called CLSPATCH containing these
instructions, put CLSPATCH, DEBUG.COM, and COMMAND.COM on your disk,
then type:
DEBUG < CLSPATCH
Be sure to leave a blank line before the W, and hit the Enter key
after each line, especially the last one. Remember also that this is
for DOS 3.2 only.
N COMMAND.COM
L
E 282E 1E
M CS:281E 283A CS:2818
A 2835
MOV BL,01
MOV AH,0B
W
Q
-----------------------------------------------------------------
PC Restart Sans Diagnostics
(PC World October 1986 The Help Screen)
A short program that restarts the PC minus diagnostics is easy
to write in assembly language. Place a blank, formatted disk in drive
A: and a copy of DEBUG.COM in drive B:. (You can also use DEBUG from
a hard disk.) At the A> prompt, type B:DEBUG <Enter> (or C:DEBUG
<Enter> for a hard disk). DEBUG's hyphen prompt will appear. Type
A <Enter>. Type the following, pressing <Enter> at the end of each
line:
MOV DX,40
MOV DS,DX
MOV BX,72
MOV WORD PTR[BX],1234
JMP FFF:0
Press <Enter> again and the hyphen prompt reappears. Type R CX
<Enter>. Zeros will appear, followed by a colon prompt and the
cursor. Type 11 <Enter> to indicate the file's size, then N
WARMBOOT.COM <Enter> to name the file, and W <Enter> Q <Enter> to
write the file to disk and quit DEBUG. Test the newly created
program by typing WARMBOOT <Enter>.
This program ensures that the PC's "reset flag" is set to the
value 1234 hexadecimal. Any other value results in a cold boot. To
create a reboot program that does include the power-on diagnostics,
follow the instructions for WARMBOOT.COM but substitute a different
value for 1234 and name the file COLDBOOT.COM.
-----------------------------------------------------------------
DEBUGging with ProKEy
(PC Magazine Vol 5 No 20 Nov 25, 1986 Power User)
DEBUG.COM does not allow you to scroll back and look at some code
that was displayed on the screen a few seconds (or 10 minutes) earlier.
You could use Ctrl-PrtSc to echo everything to the printer, but that
is tediously slow. What you want is to capture an entire DEBUG session
to a disk file. That way one can later scroll through and study the
output or print selected portions to study or show to others.
DOS I/O redirection can capture to disk, of course, but working
inside DEBUG with a blank screen (while redirection is occurring) is
impractical. However, when redirection is teamed up with ProKey, it's
a different story.
The trick is to run DEBUG twice. The first session -- while
ProKey records keystrokes -- looks like this:
A>DEBUG XYZ.COM <Ret>
<alt=><F1>
DEBUG SESSION HERE
<alt->
The <alt=><F1> keystrokes being recording the macro as F1. The <alt->
stops recording the macro after exiting from DEBUG.
The second DEBUG session is:
A>DEBUG XYZ.COM > DUMP.FIL <Ret>
<F1>
The first line here routes the output to DUMP.FIL. The second starts
the macro playback. All video output is redirected to disk, with the
ProKey macro providing the needed keystrokes.
If you prefer, separate macros can be used for selected parts of
a session. Finally, this technique is not limited to DEBUG. It can
be used to capture the screen activity of any program that uses
standard DOS video calls.
Editor's Note: Keep in mind also that the macro itself documents
your work. If you run into a discrepancy when typing a complicated
patch, you can compare the macro to the printed instructions to see
where you went wrong. And if you're creating a patch, you can use the
macro for giving keystroke-by-keystroke instructions to others. This
use of the macro as documentation has even wider applicability than
the redirection technique. It will work with any program that ProKey
works with, not just those programs that use standard DOS video calls.
-----------------------------------------------------------------
Going Back to DOS 2.x
(PC Magazine Vol 5 No 20 Nov 25, 1986 PC Tutor)
The enhancements to DOS 3.x include an alternative organization
of the file allocation table (FAT) for hard disks greater than 10
megabytes. Briefly stated, DOS 3.x allows cluster sizes on a hard
disk to be represented by 16-bit values instead of 12-bit values.
This results in more efficient use of hard disk space. However, DOS
2.x can work only with the old 12-bit FAT.
It's a good thing that DOS 2.x doesn't recognize a 20-megabyte
(or greater) hard disk formatted under DOS 3.x. If the operating
system were to assume that the FAT contained 12-bit values, it could
easily scramble up the FAT beyond recognition. Since the FAT is the
most critical part of a disk, this would be a serious problem.
How does DOS 2.x know whether to leave the disk alone? The
answer is another table -- the partition table. A hard disk can be
divided into one to four partitions, each of which may use a different
operating system. (Most XT and AT users allocate the entire hard disk
for a single DOS partition, of course.) A table with the partition
information is stored on the first sector of the disk. Each partition
has a "system indicator," a 1-byte value that designates the operating
system for the partition. DOS 2.x uses 01 to indicate a DOS partition.
DOS 3.x uses a value of 01 for a DOS partition with a 12-bit FAT, but
04 for a DOS partition with a 16-bit FAT. So, when DOS 2.x looks at a
hard disk partition table and sees a 04 system indicator, it thinks the
partition is non-DOS, even though it really is a DOS partition.
You'll experience this DOS 2.x incompatibility only with hard
disks greater than 10 megabytes formatted under DOS 3.x. A normal
PC-XT 10-megabyte disk can be used by either DOS 2.x or DOS 3.x,
regardless of the formatting.
-----------------------------------------------------------------
Exiting Assembly Language Programs
(PC Magazine Vol 5 No 21, Dec 9, 1986 PC Tutor)
DOS provides several different ways to exit an assembly language
program, and they are all pretty much the same.
Under all versions of DOS, the most common method is the INT 20h
command. But you can also use:
MOV AH,0
INT 21h
The first 2 bytes of the Program Segment Prefix (PSP) that DOS
builds at the beginning of all programs loaded into memory contain the
machine code for an INT 20h (the bytes CD 20h). For a .COM program,
DOS pushes a word of zeros on the stack before it turns control over
to the program. Thus (assuming that the stack pointer is the same as
it was on entry to the program) a .COM program can terminate with a
simple RET instruction. This branches to the beginning of the PSP and
executes the INT 20h instruction.
Using this fact, you can create the shortest possible .COM program
(1 byte long) thus:
CSEG SEGMENT
ASSUME CS:CSEG
ORG 0100h
ENTRY: RET
CSEG ENDS
END ENTRY
You can also exit a .COM program by branching to the beginning of the
PSP directly. If the beginning of a program looks like this:
CSEG SEGMENT
ASSUME CS:CSEG
ZERO:
ORG 0100h
you can exit it with either
JMP ZERO
or
CALL ZERO
Prior to DOS 2.0, interrupt 20h presented some problems for .EXE
programs. Interrupt 20h requires teh value of the CS (Code Segment)
register to point to the beginning of the PSP. In the general case,
this is not true for .EXE programs. On entry, however, the value of
the DS (Data Segment) register points to the PSP. So, to use interrupt
20h, .EXE programs have to execute code that looks something like:
PUSH DS
MOV AX,0
PUSH AX
This code puts the far address (segment plus offset) of the beginning
of the PSP on the stack. The .EXE program can then exit with a:
RET
within a far procedure. This effectively branches to the INT 20h
instruction at the beginning of the PSP.
Beginning with DOS 2.0, interrupt 21h function call 4Ch was
added. This function call has two advantages over interrupt 20h.
First, it does not require that the CS register point to the PSP.
Second, a program can pass back a return call (in register AL) to DOS.
This return code can be used in a batch file IF ERRORLEVEL statement.
Or, if the program is executed through function call 4Bh as a child
process of another program, the parent program can retrieve the return
code through function call 4Dh.
Aside from these advantages over interrupt 20h, however, the two
termination methods are functionally about the same. In DOS 3.2, DOS
turns an interrupt 20h into an interrupt 21h function call 0. Function
calls 0 and 4Ch both execute a few lines of code on their own but then
share the bulk of the DOS code involved in terminating programs.
The story is similar for interrupt 27h. By setting register DX
to the end of the program and executing an INT 27h, a program can
terminate but remain resident. This works for all DOS versions.
Interrupt 27h is a problem with .EXE programs because CS must again
point to the beginning of the PSP.
Beginning with DOS 2.0, interrupt 21h function call 31h can also
be used to terminate and remain resident. Here register DX is the size
of the program in paragraphs. (A paragraph is 16 bytes.) By using a
paragraph size rather than a byte size, function call 31h allows a
program larger than 64K to remain resident in memory. Like function
call 4Ch, you can also pass back a return code with function call 31h.
But again, interrupt 27h and function call 31h share a lot of DOS code.
Function calls 4Ch and 31h are now the "preferred" methods for
exiting assembly language programs, but only because they are more
flexible than interrupts 20h and 27h. The only problem with these
methods is that these two function calls don't work under DOS 1.1.
Although DOS 1.1 is nearly extinct, if the rest of a program can run
under DOS 1,1, it would be silly to terminate with a function call not
supported by DOS 1.1.
Some people believe that interrupts 20h and 27h will be eliminated
in future versions of DOS. For instance, the Microsoft Press MS-DOS
Technical Reference Encyclopedia (which was recalled about a month
after it was released because of gross errors) describes interrupts
20h and 27h as "obsolete." It also says that programs that remain
resident in memory should use function call 31h to "ensure
compatibility with future versions of DOS."
If a future DOS version must eliminate interrupts 20h and 27h,
this will be the least troublesome of the changes you'll have to make
to assembly language programs. This is under the assumption that the
future 80286 protected-mode version of DOS (which is really the only
future DOS version that matters) will require you to make changes in
all assembly language programs, and that programs written in high-level
languages may only have to be recompiled and relinked.
-----------------------------------------------------------------
DOS 3.2 Incompatibility
(PC Magazine Vol 5 No 22 Dec 23, 1986 PC Advisor)
The only existing DOS incompatiblity we know of is between IBM
DOS 3.2 and some earlier DOSs not licensed by IBM.
The problem results from DOS 3.2's attempt to read the name of
the manufacturer and the format of a disk from the BIOS Parameter
Block, information which is contained in the boot sector of the disk
(sector 0, track 0). Both IBM and Microsoft have specified that the
name of the manufacturer appear within the first 8 bytes in this disk
sector. Most DOSs include the letters I B M along with the version of
DOS when formatting information is written to disk in this sector. In
earlier versions, DOS ignored this information; IBM's DOS 3.2 insists
on finding it. When it doesn't DOS will refust to read the disk.
Because IBM sells DOS under license from Microsoft, IBM can decide
not to support non-IBM DOSs. There are no products now available to
solve this.
There are two solutions. You can boot an earlier version of DOS
and then copy all your files onto disks that were formatted under 3.2.
Or, if you feel comfortable using DEBUG, you can write the
information DOS 3.2 wants to find onto the disks. Load DEBUG from a
DOS prior to 3.2:
DEBUG
Put a nonbootable disk that DOS 3.2 can read into drive A:. Type:
L 100 00 1
Now replace the disk with the problem disk. Type:
W 100 0 0 1
Quit DEBUG:
Q
-----------------------------------------------------------------
Security Leak
(PC World December 1986 Star-Dot-Star)
When you use an encryption program to secure a data file, it's
important to make sure that you encrypt or destroy all copies of the
file as well. Many spreadsheet programs, word processors, and data
base managers automatically make backup files, usually with the .BAK
extension. Simply deleting those file does not make your data secure.
Anyone can use a file recovery program (such as PC Tools or The Norton
Utilities) to gain access to the contents of "deleted" files.
A more insidious danger: Many programs create temporary files
and only later delete them. (You may notice these files if a program
is halted by an error.) Because you don't see these files listed in
the directory, you might not think to destroy them.
The best solution is to copy the encrypted file onto another disk,
then format the original disk to eliminate any sensitive data.
Editor's Note: If you use a hard disk, you'll find destroying
such latent data virtually impossible. At least one encryption
program, Datasafe from Trigram Systems, sports a command that erases
data from unused disk sectors. Another solution is to use a RAM disk
to hold sensitive data files during program execution, then encrypt
the result and copy it back to a floppy or hard disk.
-----------------------------------------------------------------
2K Hard Disk Clusters
(PC World December 1986 The Help Screen)
Several readers have asked for step-by-step instructions after
failing to implement "Hard Disk Elbowroom" (PC World April 1986 Star-
Dot-Star). That item showed readers how to reduce a 10MB hard disk's
cluster size from 4K to 2K. But it contained the phrase "place the
DOS Supplemental Programs disk into the floppy drive and enter the
commands listed in DISKSIZE," which led many readers to believe that
DISKSIZE was a file on the Supplemental Programs disk. DISKSIZE is
actually the name of the figure on the following page of that issue.
It lists the DEBUG commands used to patch the boot (first) sector of
the hard disk. Other readers figured that out but where thrown a
curve because of the instruction "Run the FDISK program to create a
DOS partition ..." That sentence should have read "Run the FDISK
program to delete and then recreate a DOS partition ..."
The following procedure is for those with 10MB hard disks, and
it requires DOS 3.10 -- not 3.00 or 3.20. If your hard disk is 20MB
or larger, simply formatting it with DOS 3.00 or a later version will
give your hard disk 2K clusters; therefore, this procedure does not
pertain to your system. (Note, too, that if your hard disk is smaller
than 10MB, this procedure cannot be followed.)
Assuming you have a 10MB hard disk, your first step is to check
the current cluster size. Log onto the hard disk's DOS directory or
insert a copy of the DOS disk in drive A:. Make the drive containing
the DOS files the default drive, and at the DOS prompt type:
CHKDSK C:
and press Enter. (If your PC's hard disk is not drive C:, substitute
the appropriate drive designator wherever C: is specified.) Write down
the number preceding "bytes available on disk." Next, make the hard
disk the default drive, type
COPY CON:DUMMY
and press Enter. Then type:
DUMMY
followed by Ctrl-Z (or press the F6 key), and press Enter. Run
CHKDSK C: again, and subtract the number of "bytes available on disk"
given by the second CHKDSK from the value given by the first CHKDSK.
This value is the current cluster size of your PC's hard disk; if it
is 2048, your hard disk already has 2K clusters. In any case, issue
the command:
ERASE C:DUMMY
and press Enter to remove the dummy file.
If the cluster size is larger than 2048, back up the hard disk
file by file. (If you use certain copy-protected programs, you may
have to uninstall them before backing up the hard disk.) If you are
backing up to floppies, you'll need about 28 blank 360K floppies. Be
sure to format and number the disks before you begin the backup
procedure.
Once the backup is complete, place an unmodified copy of DOS 3.10
in drive A: and restart the PC. Set the date and time. Type:
FDISK
and press Enter. Type:
3
and press Enter to delete the existing DOS partition. Type:
Y
and press Enter to verify your intention. Then press:
ESC
type:
1
and press Enter to create a DOS partition. If you are going to use
the entire disk for DOS (in other words, if you're not planning to
install an additional operating system), simply press Enter two more
times. Otherwise, type:
N
and press Enter, enter the desired size and starting cylinder, and
press:
ESC
three times. Reset the date and time, type:
FORMAT C:
and press Enter. (Do not use the /V or /S options.) Type:
Y
and press Enter.
Next, replace the DOS disk with one containing a copy of DEBUG.COM
from the DOS Supplemental Programs disk. Following the procedure below
by typing the missing characters from those displayed on the screen,
and press Enter at the end of each line. Also, substitute the
appropriate hard disk number for n -- 1 if drive B:, 2 if drive C:, 3
if drive D:, and so on. Don't omit any spaces, and note that the 0 is
a zero, and not the letter O.
A>DEBUG
-l 0 n 0 1
-E D
xxxx:000D 08.4
-E 16
xxxx:0016 08.15
-W 0 n 0 1
-Q
Now place the DOS 3.10 disk in drive A: and reboot the PC.
Although the DOS prompt is present and DOS 3.10 is already loaded,
you must restart the system. Set the date and time, type:
FORMAT C:/S/V
and press Enter. Type:
Y
and press Enter to proceed with formatting the hard disk. When
prompted, enter a volume label.
If you would like to verify that the disk now has 2K clusters,
follow the procedure discussed above to create the DUMMY file. Do
not reload the files IBMBIO.COM and IBMDOS.COM (called IO.SYS and
MSDOS.SYS by some compatible versions of DOS); doing so renders what
you've done so far useless, forcing you to reformat the hard disk and
start over. If your backup contains a version of COMMAND.COM other
than from DOS 3.10, do not reload it either. If you are using DOS's
RESTORE command, you can use the /P option, which asks if you want
system files restored to the disk. Finally, remove any disk in
drive A: and restart the PC from the hard disk. That's it.