Jan 082018
 
Adjustable RAM Disk Program v4.1 includes C and ASM source.
File ADJRAM41.ZIP from The Programmer’s Corner in
Category Utilities for DOS and Windows Machines
Adjustable RAM Disk Program v4.1 includes C and ASM source.
File Name File Size Zip Size Zip Type
ADJRAM.C 53191 13351 deflated
ADJRAM.DOC 61339 16701 deflated
ADJRAM.EXE 12288 6372 deflated
ADJRAMEM.EXE 14848 7203 deflated
AMDISK.ASM 33243 9049 deflated
AMDISK.DVD 1510 1099 deflated

Download File ADJRAM41.ZIP Here

Contents of the ADJRAM.DOC file





ADJRAM -- Adjustable RAM Disk

by Gary Cramblitt

Version 4.1

(c) Copyright 1986,1987,1988 by Gary Cramblitt. All rights
reserved. Permission is granted to copy and use this
software for non-commercial purposes only. Permission is
granted to distribute copies of this software provided no
profit is obtained by doing so and that the entire package
is distributed.

NOTICE: This program is provided on an "as is" basis
without warranty of any kind, expressed or implied,
including but not limited to the implied warranties of
mercantability and fitness for a particular purpose. The
entire risk as to quality and performance of this program is
with you, the user. Should the program prove defective, you
assume the entire cost of all necessary repair, servicing,
or correction. In no event will the author be liable to you
for any damages, including any lost profits, lost savings,
or other incidental or consequential damages arising out of
the use or inability to use this program.


This program, although copyrighted, may be freely copied and
used, so long as it is not used for commercial purposes. It is
NOT shareware or user-supported software. You are not expected
to make a donation to the author for using this program. Enjoy
-- and try to do the same for others some day.

If you distribute copies of this software to others, you are
REQUIRED to distribute the ENTIRE package consisting of the
following files:

AMDISK.DVD
ADJRAM.EXE
ADJRAMEM.EXE
ADJRAM.DOC
AMDISK.ASM
ADJRAM.C

If you leave any of the above files out, you will be in
violation of copyright. You may charge a distribution fee for
ADJRAM so long as the recipient is not charged more than a total
of $6.00 (including tax and postage) to receive ADJRAM. If you
charge more than that, you are in violation of copyright.


READ THIS DOCUMENTATION
-----------------------
Using this program without first reading all of this document
can be hazardous to your data. While the program has been
reasonably tested for defects, the nature of its algorithm is
such that under certain conditions it will fail and this could
in turn cause loss of valuable data. The section on
Compatibility and Memory Usage and the section on Errors are
particularly important.


What Is ADJRAM?
---------------
ADJRAM is a RAM disk program. Sometimes, RAM disks are called
"virtual disks" like the VDISK supplied with PC-DOS. Sometimes
they are called "memory disks" like MEMBRAIN. Whatever you call
it, a RAM disk is a program that makes a section of the Random
Access Memory (RAM) of your computer look like a floppy disk
drive to DOS. The advantage is that RAM is many hundreds of
times faster than a floppy disk -- even faster than a hard disk.

Why use ADJRAM, when you already have VDISK or MEMBRAIN or some
other RAM disk? Because ADJRAM allows you to vary the size of
the RAM disk without rebooting, and without loss of existing
data stored in the RAM disk. For example, you can start out
with 64K of your memory allocated for the RAM disk, expand it
later to 320K, copy a document file of 60K to the RAM disk, and
still later reduce the RAM disk capacity back down to 128K --
without losing your document file.

ADJRAM is ideal for those who do not have a hard disk. It also
supports LOTUS/INTEL/Microsoft Expanded Memory and Reserved
Memory (explained later). It does not support Extended Memory.

Requirements
------------
ADJRAM is designed to run under MS-DOS version 2 or greater. It
has been tested on the following machines:

1. Zenith Z100 under MS-DOS version 2.21
2. Zenith Z171 (an IBM PC compatible) under MS-DOS version
2.11
3. KayPro 16 also under MS-DOS 2.11
4. Tandy 1000 under MS-DOS 2.11
5. Sperry Personal Computer with 2 Mbyte JRAM 3 card under
MS-DOS 3.1
6. EPSON Equity I under MS-DOS 2.11
7. COMPAQ DeskPro (80186) under IBM DOS 3.10
8. IBM PC Portable.
9. Sharp PC-5000.
10. Zenith Z160 under DOS 3.1.
11. XEROX 6060 under MS-DOS 3.1.
12. Epson Equity I under MS-DOS 2.11.

It requires approximately 14K bytes of disk space. Memory usage
is, of course, a function of the RAM disk's size, but it
requires a minimum of 50K free RAM.


Installation
------------
Note: If you have a computer with LOTUS/INTEL/Microsoft Expanded
Memory and you want ADJRAM to use the Expanded Memory,
please read the section below entitled "Expanded Memory
Support" before you install ADJRAM.

Copy the following files to your boot disk:

AMDISK.DVD
ADJRAM.EXE

Edit your CONFIG.SYS file and place the following line in it:

device = amdisk.dvd

Reboot your computer. If all goes well, you should see the
following message appear near the beginning of your boot
sequence:

AMDISK v4.1 (c) Copyright 1986,1987,1988 by Gary Cramblitt
-- Initialized as disk C:

The disk drive letter will vary according to your system
configuration. Remember that drive letter, since it is that
disk which is your RAM disk.

If you use any memory resident programs, such as Sidekick (a
trademark of Borland International), load them before attempting
to change the size of the RAM disk (as explained in the next
section).

MS-DOS 3.x users may need to add a LASTDRIVE= clause to their
CONFIG.SYS file. Consult your DOS manual.


Using the RAM Disk
------------------
The RAM disk is used just like any floppy disk drive. You can
copy files to or from it, create directories on it, erase files,
etc. You may NOT do the following things with the RAM disk:

1. You may not FORMAT the RAM disk.
2. You may not DISKCOPY from or to the RAM disk.
3. You may not run SYS against the RAM disk.
4. You may not boot from the RAM disk.
5. You may not use any program on the RAM disk that
accesses the disk controller circuitry directly. Some
anti-copy protection programs fall into this category.
6. You may not use any program that depends upon IBM
standard disk media codes.

Restrictions 1 through 5 are generally true of any RAM disk.
Restriction 6 is unique to the Adjustable RAM Disk because it
uses a non-standard media descriptor byte. This shouldn't cause
great hardship though.

Also, keep in mind that anything stored in the RAM disk can
potentially be lost. For example, should your power fail and
you don't have an Uninterruptible Power Source (UPS), then
everything in the RAM disk will be lost. If you reboot (by
pressing CTRL-ALT-DEL for example), the contents of the RAM disk
are lost. It is a good idea to periodically copy important
files to a more permanent medium, such as floppy disk.


Using ADJRAM
------------
The RAM disk defaults to a size of 64K bytes when you first boot
the system. The ADJRAM program is used to change this size.
For example, to increase the size of the RAM disk by 64K bytes,
enter the following command to the DOS prompt:

ADJRAM C: +64

The spaces after "ADJRAM" and after "C:" are required. The
drive letter (C:) will vary according to your system's
configuration. Use whatever letter was displayed by AMDISK when
you booted the system.

In case you missed it, I'll repeat: The spaces after "ADJRAM"
and after the drive are required.

When ADJRAM is run, you should see something like this displayed
on your screen:

Adjustable RAM Disk v4.1 (c) Copyright 1986,1987 by Gary Cramblitt
Drive C: Total Size: 64K Free Space: 61K
Max Possible Size: 618K Max Expansion: 554K
Final Size: 128K Amount Change: 64K
ADJRAM Exiting (code 0)

The drive letter displayed will vary, as I've already explained.

ADJRAM always increments its size in 32K junks, called "memory
blocks". The change you specify is always rounded up to the
next closest multiple of 32. In the example above, two new 32K
memory blocks are created for the additional 64K of space.

To see where the memory blocks are located and what their size
is, use the following command:

ADJRAM C: /t

The "/t" option tells ADJRAM to display the Memory Block Table.

You must have sufficient free memory to allocate the additional
size. ADJRAM will automatically determine the maximum size
possible and display it for you. If you request too large a
size, ADJRAM will round down the request to the nearest 32K
increment.

You can also shrink the RAM disk. For example, the following
command would decrease the size of the RAM disk by 32K:

ADJRAM C: -32

You must have sufficient free space in the RAM disk in order to
shrink it. To find out how much free space you have in the RAM
disk, enter the following command:

ADJRAM C:

Notice how there is no size parameter. The program will display
the current size and free space of the RAM disk. If you have
insufficient space, you must erase enough files to get
sufficient space. Then enter your ADJRAM command again.

You can not shrink the RAM disk to less than 64K. (See the
section later entitled "Specifying an Initial Size" for a way
around this restriction.)

Instead of giving the size of the RAM disk as a plus or minus
figure, you can specify the desired size of the RAM disk like
this:

ADJRAM C: 320

This command will set the RAM disk to 320K. If it is currently
larger than 320K, it will shrink it down to 320K (provided there
is sufficient free space to do so). If it is currently smaller
than 320K, it will expand the size to 320K by allocating new
memory blocks. Remember that ADJRAM will round the figure you
specify to the next higher multiple of 32.

If you want to adjust the size of the RAM disk so that it has
200K of free space, enter a command like this:

ADJRAM C: f200

Notice the letter "f" in front of the size. This command will
expand or shrink the RAM disk so as to ensure there is about
200K of free space IN THE RAM DISK.

If you want to ensure there is AT LEAST 128K of free space in
the RAM disk, enter a command like this:

ADJRAM C: m128

Notice the letter "m" in front of the size. This command will
never shrink the RAM disk, but it may expand it to make sure
there is a minimum of 128K of free space. This form of the
command is particularly handy within batch files to make sure
the RAM disk is large enough to hold a file before it is copied
into the RAM disk.


Online Help
-----------
If you can't remember the format for all these commands, fear
not. Simply enter

ADJRAM

and it will display a help message showing the formats described
above.


Hint for Floppy Disk Systems
----------------------------
If you do not have a hard disk, soon after booting your
computer, copy file ADJRAM.EXE to the RAM disk, for example:

COPY A:ADJRAM.EXE C:

You can then modify the size of the RAM disk at any time
thereafter without needing the boot disk. Just put the RAM disk
drive letter in front of any ADJRAM commands. For example:

C:ADJRAM C: -32

You can put the COPY command into your AUTOEXEC.BAT file.


Specifying an Initial Size
--------------------------
By default, AMDISK sizes itself to 64K when it is initially
loaded at boot time. If you wish, you can alter this initial
size by placing a "MINSIZE=" clause in CONFIG.SYS. For example,
to set the initial size to 32K, you would put the following line
into CONFIG.SYS:

DEVICE = AMDISK.DVD MINSIZE=32

The size may be a minimum of 15 and a maximum of 512. Large
initial sizes are definitely not recommended however, because
you can never shrink the RAM disk to less than its initial size.
For example, if you put a "MINSIZE=256" into CONFIG.SYS, you can
never make the RAM disk any smaller than 256K.

ADJRAM always expands and shrinks the RAM disk in 32K
increments. If you specify an initial size that is not an even
multiple of 32, then ADJRAM will round your sizes to some
strange numbers. For example, if you specify "MINSIZE=15" in
CONFIG.SYS, and then give the following command:

ADJRAM C: 128

ADJRAM will actually size the RAM disk to 143K (15 + 4*32). For
this reason, I recommend that you always specify an even
multiple of 32 in your "MINSIZE=" clause.


Expanded Memory Support
-----------------------
ADJRAM provides full support for LOTUS/INTEL/Microsoft Expanded
Memory (EMS version 3.2 compatible).

If you have a computer with LOTUS/INTEL/Microsoft Expanded
Memory and you want ADJRAM to use that memory, the installation
is a little different. Instead of copying ADJRAM.EXE to your
boot disk, copy file ADJRAMEM.EXE and then rename it to
ADJRAM.EXE.

Depending upon how much expanded memory you have and how large
you expect to make the RAM disk, you may also need to add a
"CLUSTER=" clause to CONFIG.SYS. For example, if you have 8MB
of expanded memory (the maximum possible) your CONFIG.SYS file
would have the following statement:

DEVICE = AMDISK.DVD CLUSTER=4

The following table shows the cluster sizes you should use for
corresponding maximum RAM disk sizes:

Maximum
RAM Disk
Size (K) CLUSTER=
-------- --------
2043 1 (default)
4083 2
8166 4
16332 8

The rest of the installation is the same as for the non-expanded
memory version.

If you want ADJRAM to create new memory blocks in
LOTUS/INTEL/Microsoft Expanded Memory, add a "/E" option, like
this:

ADJRAM C: +256 /E

This command will expand the RAM disk by 256K. The additional
256K memory block will be created within LOTUS/INTEL/Microsoft
Expanded Memory. If ADJRAM ends up shrinking the RAM disk, the
"/E" switch is meaningless. Remember that ADJRAM will always
shrink the RAM disk by freeing memory blocks in reverse of the
order in which they were created.

The version of ADJRAM that supports Expanded Memory can not be
used in conjunction with the version that does not support it.
Don't get them mixed up. Use ADJRAMEM.EXE (renamed to
ADJRAM.EXE) or use ADJRAM.EXE -- but not both.

Instead of allocating memory blocks in 32K increments, ADJRAM
allocates expanded memory blocks in 256K increments.
Consequently, it will shrink in 256K increments as well. If you
mix conventional memory blocks with expanded memory blocks, the
shrinkage boundaries will vary. Just remember that ADJRAM
always deallocates memory blocks in reverse of the order they
were created, and that it must always deallocate entire memory
blocks. Playing with the combinations and using the "/t" option
will help you to understand what is going on.

One EMM handle is used for each new 256K memory block. Hence, a
2MB expanded memory RAM disk will use 8 handles.

The Expanded Memory support in this version of ADJRAM was coded
based on information from the book "Advanced MS-DOS" by Ray
Duncan. The code was tested on a Sperry PC with a 2 Mbyte JRAM
3 memory board installed (JBOOT and JPAGER loaded). I don't own
a computer with Expanded Memory, so this part of the program is
the least tested. Please be cautious until you've had time to
thoroughly check out the program -- and let me know if you
encounter difficulty.


Using Reserved Memory
---------------------
Beginning with verson 4.0, ADJRAM now supports Reserved
Memory. This capability should only be used by those who
understand 8086 addressing and have sufficient technical
background. Others should skip this section entirely.

Support for Reserved Memory was added because many computers
have banks of memory not otherwise usable. For example, in the
IBM Portable, banks A, C, D, and E are not normally used for
anything. Some portable clones have a megabyte of memory, but
only 640K is usable.

To understand what Reserved Memory is, here are a few
definitions:

1. CONVENTIONAL Memory is directly addressable by the 8088
or 8086 CPU and is controlled by DOS. On the IBM PC, it
is the memory from 0 to 640K.

2. RESERVED Memory is also directly addressable by the 8088
or 8086 CPU but it is not controlled by DOS. On the IBM
PC, it would be memory from 640K to 1MB. This memory is
normally reserved for use by the BIOS. For example, the
memory from B0000 to BFFFF is reserved for monochrome
and graphics video memory.

3. EXTENDED Memory is only found in AT class machines. It
is memory above 1MB that is directly addressable by the
80286 (protected mode) or 80386 CPUs. Extended Memory
is not currently supported by ADJRAM. Some PC and XT
class machines have "extended" memory boards in them
that don't meet the definition of Extended Memory I've
given here. Such memory must be "bank switched" or
"paged" into the 8088 or 8086's address area (0 to 1MB).
The JRAM 3 memory card is one such type of memory. If
the vendor sells an Expanded Memory Manager (EMM) for
the board, then that memory can be used by ADJRAM.

4. EXPANDED Memory adheres to the LOTUS/INTEL/Microsoft
Expanded Memory Specification (v3.2). Note that
Expanded Memory is implemented through the Expanded
Memory Manager (EMM), and may actually reside anywhere.
For example, with appropriate software, it is possible
to convert Extended Memory into Expanded Memory.

Now back to Reserved Memory. IBM reserved the memory from A0000
to FFFFF. For example, they reserved memory from A0000 to AFFFF
for the Enhanced Graphics Adaptor (EGA). If your computer
doesn't have an EGA, you may be able to use those addresses for
ADJRAM.

Suppose you wanted to put 64K at address A0000 to AFFFF. To do
this, you would have to install a memory board with 64K
"jumpered" or "strapped" so that its memory resides at addresses
A0000 to AFFFF. The memory must be directly addressable by the
CPU at addresses A0000 to AFFFF. No "bank switching", "paging",
or "enabling" is allowed.

Now specify a command of the following form to expand into this
Reserved Memory:

ADJRAM C: r:a000:64 /T

You must use the Expanded Memory version of ADJRAM
(ADJRAMEM.EXE renamed to ADJRAM.EXE). The format must be
exactly as shown, i.e., an "R" followed by a colon, followed by
a four digit hexadecimal paragraph address, followed by a colon,
followed by a decimal size. (You get a paragraph address by
dropping the last hexadecimal digit from a 5 hex digit address).
Notice that this "R" option replaces the normal "size" parameter
in an ADJRAM command. The maximum size permitted is 64. The
hexadecimal address must be in the range A000 to FFFF and it
must point to valid reserved memory.

ADJRAM doesn't do ANY error checking of this command, so use
with extreme caution. The "/T" option is used so that you can
verify that the memory block was properly added to the Memory
Block Table. In this example, a single 64K block is added
beginning at paragraph A000.

You may have additional Reserved Memory, or you may wish to
allocate the memory in smaller blocks so that shrinkage can be
fine-tuned. To do that, just specify additional ADJRAM commands
-- one for each new block. For example, to divide the 64K block
starting at A000 into four blocks of 16K, give the following
commands:

ADJRAM C: r:a000:16
ADJRAM C: r:a400:16
ADJRAM C: r:a800:16
ADJRAM c: r:AC00:16 /t

You will normally want to specify the Reserved Memory commands
in your AUTOEXEC.BAT.

If you find this capability useful, please let me know.



Error Messages
--------------
In general, error messages are prefaced by either the phrase
"Error --" or the phrase "Warning --". Warning messages are not
fatal. The program will automatically adjust for them. For
example, if you attempt to make the RAM disk larger than
available free memory, ADJRAM will automatically make it as
large as possible.

Most errors will stop the program immediately. However, once
the "Final Size" line appears, ADJRAM has begun to reorganize
the RAM disk. If it gets an error during this time, it will
attempt to keep going; and when it does exit, the following
message will appear:

*** Sorry, RAM disk has been corrupted. Recommend that you
check your files, save them if possible, and reboot.

If this message appears, you should immediately do just what it
says. If you don't need any of the data in the RAM disk, you
should reboot immediately. If you do need the data, first check
the files to see if they are OK. You can check ASCII text files
by TYPEing them. If the files you need appear to be OK, then
copy them to a more permanent medium, such as floppy disk, and
reboot.

Whenever ADJRAM exits, a message such as the following appears:

ADJRAM exiting (code 0)

The code number in parenthesis indicates the ERRORLEVEL code
being passed to DOS. A code of 0 means "no error". These codes
can be tested by DOS IF statements in batch commands. More on
this later.

There are also a large number of possible errors that MS-DOS
will display while you're working with the RAM disk. Consult
your DOS manual. One message I'd like to point out. If you see

Bad File Allocation Table

(or something similar) the RAM disk is probably corrupted.
Carefully check your files. If they are OK, copy them to a more
permanent medium, such as floppy disk, then reboot.

Here is a list of possible error messages you might see
displayed by the ADJRAM.EXE program and their probable cause
(the numbers in parenthesis are the ERRORLEVEL codes passed to
DOS). First time users will want to skip the rest of this
section. Keep this .DOC file handy though, in case you need
help understanding an error message:

Error -- could not read boot sector. Error code xx (15)

The program could not read the boot sector (logical sector 0) of
the RAM disk. An invalid drive letter was specified or the RAM
disk has become corrupted. In the latter case, reboot is

recommended.

Error -- that drive is not the adjustable RAM disk or
invalid version of AMDISK for this version of ADJRAM (15)

An invalid drive letter was specified. Use the letter that was
reported by AMDISK when you booted the computer. Make sure you
used the correct command syntax. A space must follow "ADJRAM".
It could also occur if you've mixed version 4.0 of ADJRAM with
an older version of AMDISK. In this case, you need to update
AMDISK.DVD.

Error -- could not free environment block. Error code xx
(10)

This error would indicate you have an incompatible version of
MS-DOS. The error codes are those returned by DOS function 49H.

Error -- Bad reserved memory parameter (1)

You gave an "R" option but in the wrong format. Format is
R:hhhh:dd. For example, a reserved memory block starting at
paragraph D000 and 32K long would be specified as r:d000:32
A common error is to forget one of the colons. Also, the
starting address is exactly 4 hexadecimal digits long. Correct
and try again.

Error -- Unable to locate reserved memory block from
xxxx:xxxx to xxxx:xxxx (8)

You gave an "R" option but specified memory that ADJRAM could
not find. For example, a reserved memory block starting at
paragraph D000 and 32K long would be specified as r:d000:32. A
common error is to overlap with read-only memory or to overlap
with video memory. ADJRAM tests the specified block by writing
a test byte at the beginning and end of the block. If it can
not read the same byte back, you get this error. Check your
technical documentation and try again.

Error -- Invalid drive letter or RAM disk is not loaded
(15)

ADJRAM reports this error if DOS returns an error code from
function 36H (get free disk space). Check your drive letter and
command syntax.

Warning - Insufficient free space in disk to shrink that much
(8)

You do not have enough free space in the RAM disk to shrink it
by the requested amount. ADJRAM will attempt to shrink the disk
as much as possible. First erase some files from the RAM disk,
then reenter you command.

Warning -- Rounding your requested change of xxK to xxK

ADJRAM is showing you how it has adjusted your expansion or
shrinkage request to fall within allowable boundaries. Does not
alter the ERRORLEVEL code.

Error -- could not modify memory block size. Error code xx
(8)

This error occurs when expanding the RAM disk. The program
received an error code from DOS function 4AH (modify memory
allocation) on the first new 32K memory block to be created. It
could be caused by corrupted memory allocation, possibly
caused by incompatibility with other memory resident programs.
Reboot is recommended.

Error -- could not allocate new memory block. Error code
xx (8)

This error is similar to the one above except that it occurs on
the second and subsequent new 32K memory blocks when the program
invokes DOS function 48H (allocate memory). Since the program
supposedly made sure there was sufficient memory before
attempting the expansion, getting this message would indicate an
internal bug.

Error -- could not allocate new memory block from EMM.
Error code xx (8)

This error is similar to the one above except that it occurs in
conjunction with creating new 256K memory blocks in
LOTUS/INTEL/Microsoft Expanded Memory. The program will attempt
to keep going without expanding the disk any further. This
condition is not well tested though, so to be safe, reboot is
recommended.

Error -- could not write boot sector back. Code: xx (15)

This is most likely an internal program error. The program got
an error code from DOS interrupt 26H (write absolute disk
sector). Reboot is required.

Error -- could not free allocated memory block #xx. Error
code xx

This error occurs when shrinking the RAM disk. The program got
an error code from DOS function 49H (release memory). Could be
caused by an internal program bug, incompatible memory resident
program, or incompatible version of DOS. The program attempts
to exit gracefully so that you can recover data files from the
RAM disk, but you should reboot as soon as possible.

Error -- could not free EM pages for memory block #xx.
Error code xx

This error occurs when shrinking the RAM disk. The program got
an error condition from the LOTUS/INTEL/Microsoft Expanded
Memory Manager. Could be caused by an internal program bug,
incompatible memory resident program, or incompatible version of
DOS. The program attempts to exit gracefully so that you can
recover data files from the RAM disk, but you should reboot as
soon as possible.

Error -- Insufficient stack space to pack subdirectory
xxxxxxxx. Too many subdirectories. Shrink abandoned. (4)

This error occurs when shrinking the RAM disk. The DeSmet C
stack space was insufficient to handle the depth of
subdirectories you have on your RAM disk. The program attempts
to exit gracefully without completing the shrink. This
condition has not been fully tested, so caution, your files may
have been corrupted. In the future, don't use so many
subdirectories.

Error -- Error while packing file xxxxxxxx

This error occurs when shrinking the RAM disk. It will usually
be displayed after the previous message. It may also appear if
an internal error occurs, such as inability to read or write
sectors of the file. The program attempts to exit gracefully
without completing the shrink.

Error -- Expanded Memory Manager is not avaiable. Error
code: xx (15)

You specified the "/E" option, but the LOTUS/INTEL/Microsoft
Expanded Memory Manager (EMM) is not loaded. Load the EMM and
try again.

Error -- Expanded Memory Manager could not report page
frame. Error code: xx (8)

The EMM was detected by ADJRAM, but the EMM reported an error
when ADJRAM asked for the page frame segment address (EMM
function 41H). This could be caused by a corrupted EMM, or an
incompatible version of the EMM (ADJRAM requires version 3.2
compatibility), or possibly ADJRAM encountered a "busy"
condition from the EMM. Try again. If it still fails, you'll
have to stick with normal memory.

There are two other conditions which do not display an error
message. In these cases, the program simply displays the help
message and exits:

1. Invalid drive letter specified. Must be in range A
through L. (15)

2. Invalid size specified. For Conventional Memory, must
be in range 64 to 2016. (1).



Using ADJRAM in Batch Files
---------------------------
If an error occurs while running ADJRAM, it will return a DOS
error code when it exits back to DOS. The error codes returned
are shown in parenthesis in the error message section above.
They are also displayed in the "ADJRAM exiting" message. These
error codes can be used in a batch file via the DOS IF
command. See your DOS manual for details. For example, I use
the following batch command file to load PROCOMM into the RAM
disk. Procomm's files require about 175K of space:

c:adjram c: m175
if not error level 0 goto noram
copy a:procomm.* c:
c:
rem Type PROCOMM /B
goto xit
noram:
rem Not enough room in ram disk.
xit:

Some versions of MS-DOS (Z100 v2.21 for example) have a command
which will cause error codes to be displayed. It is:

XYZZY ON


Compatibility and Memory Usage
------------------------------
The Adjustable RAM Disk falls into a class of programs known as
Memory Resident programs. Sidekick is one such program. These
programs are sometimes incompatible with one another. It is
impossible for me to test the Adjustable RAM disk in combination
with every available memory resident program, so I'll apologize
ahead of time -- some incompatibilities are almost certain to
crop up.

Sometimes, changing the order inwhich the programs are loaded
makes a difference.

Generally, you should load all of your memory resident programs
BEFORE you run ADJRAM. (I know, every memory resident program
wants to be loaded last, but please bear with me!) You should
do this to make the most efficient use of memory. Here's why.
When you expand the RAM disk, ADJRAM allocates 32K memory blocks
using the DOS memory allocation functions. Once that is done,
any subsequent memory resident programs you load will generally
get loaded above these new memory blocks. When you later shrink
the RAM disk, ADJRAM deallocates the memory blocks. If you have
loaded a memory resident program after expanding the RAM disk
with ADJRAM, then "holes" in the memory allocation will be
created when you later shrink the RAM disk. These holes will
generally not be usable for transient programs until you unload
the memory resident program (which might not even have that
capability).

To help you understand what is happening, consider a system with
the following CONFIG.SYS file

device = amdisk.dvd
device = ansi.sys

and the following (incorrect) AUTOEXEC.BAT:

copy adjram.exe c:
c:adjram c: +64
sk

Notice that Sidekick is incorrectly loaded AFTER expanding the
RAM disk. At the completion of the boot, the following memory
layout exists:

+--------------------------------+ 640K
| |
| Transient Program Area |
| |
+--------------------------------+
| Sidekick |
+--------------------------------+
| Block #2 of RAM Disk (32K) |
+--------------------------------+
| Block #1 of RAM Disk (32K) |
+--------------------------------+
| ANSI.SYS |
+--------------------------------+
| Block #0 of RAM disk (64K) |
| |
+--------------------------------+
| AMDISK.DVD |
+--------------------------------+
| BIOS and DOS |
+--------------------------------+ 0K

If the user were to shrink the RAM disk now, say with the
following command

C:ADJRAM C: -32

then the memory layout would change to this:

+--------------------------------+ 640K
| |
| Transient Program Area |
| |
+--------------------------------+
| Sidekick |
+--------------------------------+
| 32K unusable "hole" |
+--------------------------------+
| Block #1 of RAM Disk (32K) |
+--------------------------------+
| ANSI.SYS |
+--------------------------------+
| Block #0 of RAM disk (64K) |
| |
+--------------------------------+
| AMDISK.DVD |
+--------------------------------+
| BIOS and DOS |
+--------------------------------+ 0K

Notice how, with Sidekick where it is, the Transient Program
Area could not grow in size. There is now a 32K hole of
unusable memory just below Sidekick. The correct
AUTOEXEC.BAT

sk
copy adjram.exe c:
c:adjram c: +64

would produce the following memory layout after booting:

+--------------------------------+ 640K
| |
| Transient Program Area |
| |
+--------------------------------+
| Block #2 of RAM Disk (32K) |
+--------------------------------+
| Block #1 of RAM Disk (32K) |
+--------------------------------+
| Sidekick |
+--------------------------------+
| ANSI.SYS |
+--------------------------------+
| Block #0 of RAM disk (64K) |
| |
+--------------------------------+
| AMDISK.DVD |
+--------------------------------+
| BIOS and DOS |
+--------------------------------+ 0K

Now, if the RAM disk is shrunk (up to 64K, i.e., blocks #2 and
#1), then the Transient Program Area will grow by that amount.

You generally shrink the RAM disk because you want to make more
memory available for other programs. But it defeats this
objective to load memory resident programs after expanding the
RAM disk. So...

First load the memory resident programs, then use ADJRAM to
expand your RAM disk.

The Adjustable RAM disk doesn't "steal" interrupts from the
system, so expanding the RAM disk after loading programs that
intercept interrupts, such as Sidekick, SHOULDN't cause any
problems.

If you encounter compatibility problems, please let me know at
the address I'll give at the end of this document. I'd like to
know about them so I can fix them if possible. Please be as
complete as possible when you explain the problem. What memory
resident programs did you have loaded and in what order? How
much memory do you have in your computer? What computer and
operating system were you running? Exactly what happened when
it didn't work? I won't guarantee that I can fix the problem,
but I'll try.


Known Compatibility Problems
----------------------------
When using ADJRAM with DoubleDOS, new memory blocks are created
within whichever partition is active at the time you run ADJRAM.
If you attempt to shrink the RAM disk to gain additional room in
the first partition, you may find that you didn't gain any room
in the first partition! Instead, the room gained was in the
second partition (because that's where the memory blocks were
created).

Also, DoubleDOS doesn't know about ADJRAM creating new memory
blocks. This causes DoubleDOS to tell you there is more room in
partitions than actually exists. Use CHKDSK to find out how big
your partitions really are. In general, you should try to run
ADJRAM before activating DoubleDOS, to avoid this problem.

ADJRAM is somewhat incompatible with MARK/RELEASE. You can't
expand the RAM disk after you've run MARK, because when you run
RELEASE, AMDISK won't know that some of its memory blocks have
been freed. As long as you expand before you run MARK for the
first time, you should be OK. I have not tried MARK/RELEASE in
conjunction with ADJRAM, so there may be other problems as well.
The Referee, being a program similar to MARK/RELEASE, will
problably also have these problems.

One user reported that Sidekick version 1.11c locked up when
used in conjunction with ADJRAM on his clone PC running MS-DOS
3.2. The same version of Sidekick checked out OK on a Sperry
running MS-DOS 3.1. I don't have easy access to a PC running
3.2, so if anyone can help me resolve this problem, it would be
appreciated.

Other Known Problems
--------------------
Some programs, such as PC-WRITE have a "shell" or "hotkey"
command that allows you to suspend the program, keeping it in
memory, and execute other DOS commands. You may be tempted to
use this capability to increase or decrease the size of the RAM
disk in the middle of running another program. But be careful
here. Consider the following sequence of events:

1. You're running (the fictitious) program RAZZLDOC,
editing file C:MYFILE.DOC on the RAM disk.

2. You use RAZZLDOC's "shell" command to get the DOS
prompt.

3. You use ADJRAM to expand the size of disk C, the RAM
disk.

4. You use the DOS EXIT command to go back into RAZZLDOC.

5. Upon exiting RAZZLDOC, you're horrified to learn that
it was unable to successfully save all your work in
C:MYFILE.DOC.

The problem here is that ADJRAM told DOS that the "media has
changed" on disk C. But RAZZLDOC had a file open on disk C!
DOS can't properly close the file. This sort of problem will
generally occur with any program that has a "shell" command but
fails to close all open files before executing the shell. [One
user reported to me that PC-WRITE does close its files before
executing the shell, so it should be safe to run ADJRAM from PC-
WRITE.]

This kind of problem can also occur with certain memory resident
programs that, in effect, give you a "shell" command from within
any program. POPDOS is one such program.

Remember that whenever you expand or shrink the RAM disk, you
have, conceptually, removed the current "floppy disk" in the RAM
drive, and replaced it with another "floppy disk" that just
happens to have the same files as the one removed. You wouldn't
change a real floppy disk in the middle of editing a Wordstar
file, so don't expand or shrink the RAM disk either.

I haven't actually tried it, but ADJRAM is likely to have
problems under windowing systems, like Microsoft Windows, as
well. Users who try it, please let me know how it turned out.


Future Versions of DOS
----------------------
It is unlikely that ADJRAM will be compatible with future
versions of MS-DOS. Starting with version 5, Microsoft plans on
adding multi-tasking capability. That will require much more
stringent memory management. That management is likely to
conflict with the way ADJRAM works. People running version 5
and above are likely to own hard disks and "virtual memory"
machines anyway, and the need for an adjustable RAM disk will
disappear.


History
-------
3.0 This was the first version of ADJRAM to be released. It
was released to the public in September 1986.
3.1 This version fixed a bug. 3.0 did not properly pack files
in subdirectories under certain conditions. This lead to
a "bad file allocation table" error. Release October 1986.
3.2 This version added support for the SIZE= clause in
CONFIG.SYS. Not publicly released.
4.0 This version included the following bug fixes and
enhancements:
* Full support for Expanded Memory
* Support for Reserved Memory
* Improved error reporting
* /T option to display Memory Block Table
* Max expansion and shrinkage automatically calculated.
Users's request automatically rounded.
* "Non IBM format" message from CHKDSK fixed by making
FAT ID masquerade as "double-sided 9-sector".
* "Bad FAT" message when disk full bug fixed.
* CLUSTER clause added to AMDISK.DVD
* Volume label added to AMDISK.DVD
Not publicly released
4.1 This version added the following enhancements:
* Verify that reserved memory is segment a000 or above
* Initialize reserved memory to zeroes.
Version 3.x and 4.x can not be mixed.


Internals
---------
This section is for anyone interested in the internal workings
of the Adjustable RAM Disk. It is not necessary to know this
information to use the Adjustable RAM Disk, but it may be
helpful for resolving compatibility problems. This section is
for advanced DOS programmers only.

AMDISK.DVD is a loadable device driver, just like VDISK or
ANSI.SYS. By itself, it is a complete 64K RAM disk (assuming no
"MINSIZE=" clause is given in CONFIG.SYS). A 64K "memory block"
is allocated immediately after the AMDISK code. A Memory Block
Table is maintained in logical sector 0 (the boot sector) of the
RAM disk beginning at offset 1EH. For each memory block, this
table contains a seven byte entry as follows:

1. A byte indicating the type of memory block. 0 means
the block is allocated in normal DOS memory. 1 means
the block is allocated in Expanded Memory. 2 means the
block is allocated in Reserved Memory.

2. A word giving the starting paragraph number of the
memory block. A paragraph of memory is simply 16
bytes, so this number is just the absolute memory
address shifted right by 4 bits. All memory blocks
begin on an even paragraph boundary. This word is zero
if there are no more memory blocks. It is meaningless
for Expanded Memory blocks.

3. A word giving the size of the memory block in 512-byte
sectors.

4. A word giving the Expanded Memory handle for the memory
block. Zero for normal memory blocks.

Immediately after booting, there is exactly one 64K (128 sector)
memory block in the Memory Block Table. If a "MINSIZE=" clause
was given in CONFIG.SYS, the size will vary from 64K.

Note: Don't confuse the memory blocks defined here with those
defined for DOS functions 48H thru 4AH. To avoid
confusion -- and though not strictly accurate -- I'll
refer to DOS's memory blocks as "program segments".

The number of memory blocks allocated is stored in the media
descriptor byte at offset 15H of the boot sector. Any time DOS
requests a media code from the AMDISK device driver, it returns
the number of memory blocks allocated. In this way, any time
that the RAM Disk has been shrunk or expanded, DOS will know
that the "media has changed" and will rebuild its internal Disk
Parameter Block (DPB) tables. This lets DOS know what the new
size of the RAM disk is.

The drive letter AMDISK.DVD uses is assigned by DOS. AMDISK.DVD
gets the letter from DOS via function 19H (Get default disk
drive).

Upon startup of the ADJRAM program, it moves its own stack down
so that the program's total run size is less than 32K. This
prevents corruption of future DOS memory arena blocks

Also, DOS function 49H (release memory) is used to deallocate
its own environment segment. This doesn't seem to hurt a
running program, and it is necessary to insure that this memory
can be used later when the RAM disk is shrunk.

At startup, the Expanded Memory version of ADJRAM tests whether
the Expanded Memory Manager (EMM) is loaded by opening device
"EMMXXXX0". If the open fails, the EMM is not loaded. If the
open succeeds, then the output status is requested from the
device using DOS function 44H (IOCTL). If IOCTL reports a
status of 0, then coincidentally a file named "EMMXXXX0" existed
on the default disk, and the EMM is still not available. If the
EMM is not available, ADJRAM reports an error and exits.

Also upon startup, ADJRAM checks that the specified drive letter
corresponds to the AMDISK device. The boot sector of the RAM
disk contains the string "AMDISK" at offset 03H. The boot
sector is read using DOS interrupt 25H (absolute disk read).

If the user has requested expansion of the RAM disk using
conventional memory, the program counts the number of available
32K memory blocks by allocating them using DOS function 48H
(allocate memory). When it gets an error, it knows there are no
more available. It then deallocates the blocks using DOS
function 49H (deallocate memory). ADJRAM always leaves at least
one 32K block of free memory. This is so that ADJRAM can be run
one more time in order to shrink the RAM disk.

If the user has requested shrinkage of the RAM disk, ADJRAM
examines the Memory Block Table to find out where the next
smaller size is. It also uses the table to round the requested
shrink down to the nearest memory block boundary.

When the ADJRAM program increases the size of the RAM disk, it
does so by allocating additional 32K (64 sector) memory blocks.
Normal memory blocks are allocated in two ways:

1. If it is the first memory block to be created (in this
run of ADJRAM), then the memory block is allocated
using DOS function 4AH (modify memory allocation).
ADJRAM's own program segment is the one modified.
Hence, the first memory block overwrites the ADJRAM
program itself.

2. Additional memory blocks are allocated using DOS
function 48H (allocate memory).

In either case, an appropriate entry is made in the Memory Block
Table, which is in the boot sector, for each new memory block.
At the end of the program, the boot sector is written back out
using DOS interrupt 26H (absolute disk write).

When ADJRAM exits normally, it uses DOS function 31H (terminate
and stay resident) to permanently allocate the new memory
blocks.

Expanded Memory blocks are allocated via EMM function 43H (Get
handle and allocate memory).

Reserved Memory blocks are not "allocated" at all. ADJRAM
simply enters the starting paragraph and size into the Memory
Block Table. It then zeroes the reserved memory. That is why
this option is so dangerous.

When ADJRAM shrinks the RAM disk, it does these steps:

1. It checks to insure there is sufficient free space in
the RAM disk to do the shrink.
2. The File Allocation Table (FAT) is read using DOS
interrupt 25H. The first available cluster number is
determined.
3. The first sector of the directory is read in using DOS
interrupt 25H.
4. For each file, any clusters located after the first
available cluster are moved down to the first available
cluster. Then the next available cluster is
determined. Clusters are moved in the RAM disk using
DOS interrupts 25H and 26H. As clusters are moved, the
directory and FAT in memory are updated. After all the
clusters of the file are packed down, and if the file
is a subdirectory, then the clusters of the directory
are read in and the file packing algorithm (steps 3 and
4) is recursively applied to each directory entry in
the file.
5. Step 4 is repeated for each additional directory
sector. Updated directory sectors are written back to
the disk using DOS interrupt 26H.
6. The necessary number of memory blocks are deallocated,
either using DOS function 49H (release memory) or EMM
function 45H (release handle and memory). The Memory
Block Table is updated accordingly. Blocks are
deallocated in reverse of the order inwhich they are
created.
7. The updated FAT and boot sector are written back to the
disk using DOS interrupt 26H.
8. ADJRAM exits normally via DOS function 4CH (exit with
return code).

An excellent book for understanding DOS memory allocation and
disk structure is the "MsDOS Developer's Guide", written by the
Waite Group and published by SAMS. Another excellent book,
which includes documentation on Expanded Memory, is "Advanced
MS-DOS" by Ray Duncan.

In the course of developing this program, I discovered a couple
of interesting things about the DOS version 2 memory allocation
functions (48H thru 4AH).

1. Transient programs are always loaded after the last
allocated memory block, even if there is sufficient
memory available in "holes" below the last allocated
memory block. Such holes could be created by loading a
memory resident program, such as Sidekick, and then
shrinking the RAM disk.

2. The allocate memory function (48H), on the otherhand,
will use holes if they exist and if they are large
enough to contain the requested block.

3. If a program modifies a DOS memory block (function
4AH), it becomes the "owner" of that block, even if it
didn't create the block in the first place. When such
a program exits, the block will be automatically
deallocated by DOS unless the program exits via
terminate and stay resident. This is why ADJRAM must
allocate memory blocks in fixed 32K increments.
Ideally, it should allocate exactly the requested size
and no more. The DOS quirk described here prevents
that though.

The source code for the Adjustable RAM Disk is included with the
program. AMDISK.DVD is coded in MASM version 1.27; ADJRAM.EXE
is coded in DeSmet C version 2.4. Even though I've included the
source code, I would nevertheless like to act as the
clearinghouse for all future versions and modifications. If you
make a change to the program, or fix a bug, PLEASE let me know
about it -- I may want to include the change in future versions.

If you modify the program, you agree to maintain my copyright.
You should indicate that you've modified the program by changing
the version number, for example "version 4.1A", or by putting
some other distinguishing message in the signon of the program,
for example "custom version by John Doe". The rational for this
is simple -- I don't won't to be blamed for your bug.

My address, as of May 1988 is:

GARY CRAMBLITT
105 TENNESSEE RD
STEVENSVILLE, MD 21666

Please do not telephone. I'd like to receive your letter.
Please note that my address is given above in order to support
users who encounter difficulty running ADJRAM. I can not afford
to distribute copies of ADJRAM so please do not publish this
address. I rely upon RBBSs and user groups to distribute
ADJRAM.

* * * * END OF ADJRAM.DOC * * * *



 January 8, 2018  Add comments

Leave a Reply