Category : Recently Uploaded Files
Archive   : ASILIB12.ZIP
Filename : EMSXMS.DOC

 
Output of file : EMSXMS.DOC contained in archive : ASILIB12.ZIP

******************** EXPANDED AND EXTENDED MEMORY **************************

ASILIB's EMS subroutines detect and manipulate Expanded Memory hardware
and software. Expanded memory, when installed in any PC, can help solve
many memory limitation problems. Call IsEMS before using any other
ASILIB EMS subroutines. EMS memory is allocated in blocks of 16k increments.


Error codes returned by EMS functions are:

&hex0 = no error
&hex8000 = error in memory manager software
&hex8100 = error in expanded memory hardware
&hex8400 = bad function code passed to memory manager
&hex8500 = no EMM handles available
&hex8900 = you tried to allocate zero EMS memory



ASILIB also supports XMS memory. XMS memory is available on most 286 or
better computers with a suitable driver. On 286 computers, XMS memory will
be much slower than EMS memory. XMS memory is not available on XT
(or compatible) computers. Call IsXMS before using any ASILIB XMS
subroutines. XMS memory is allocated in 1k increments.

XMS error codes include:

&hex0000 = no error
&hexA000 = all extended memory is allocated
&hexA100 = no handles available
&hexA200, &hexA300, &hexA500 = handle is invalid
&hexA400, &hexA600 = offset is invalid
&hexA700 = length is invalid


ASILIB includes disk-based Virtual Memory subroutines (VMS) which make
possible the use of disk space as though it were RAM. Error codes returned
by VMS subroutines are DOS error codes.

ASILIB's EMS, VMS and XMS subroutines were written with identical calling
parameters and identical returned information for comparable subroutines.
For example, AllocEMS and AllocXMS are both called with the number of bytes
requested and return a handle and error code.


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

ALLOCEMS: Allocate a block of EMS Expanded memory.

Parameters: bytes&, emshandle, emserror

Bytes& = number of bytes of Expanded memory requested.
EMShandle = handle for addressing the EMS memory block
EMSError = EMS error code; EMSHandle is no good if EMSError <> 0.
See also FreeEMS.

Restrictions: Call IsEMS before calling AllocEMS to determine if EMS memory
is installed; requires ASIC's Extended Math option.

Example:

REM I want to allocate a block of EMS memory for my program

call sub "isems", emsflag
if emsflag = -1 then keepgoing:
end

keepgoing:
emsbytes& = 100000&
call sub "allocems", (emsbytes&, emshandle, emserror)



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

ALLOCXMS: Allocate a block of XMS Extended memory.

Parameters: bytes&, xmshandle, xmserror

Bytes& = number of bytes of Extended memory requested.
XMShandle = handle for addressing the XMS memory block
XMSError = XMS error code; xmshandle is no good if xmserror <> 0.
See also FreeXMS.

Restrictions: IsXMS MUST BE CALLED BEFORE CALLING AllocXMS.
Requires ASIC's Extended Math option. XMS memory may not
be reliable if EMS memory is emulated by EMM386, QEMM or
other similar memory managers.

Example:

REM I want to allocate a block of XMS memory for my program

call sub "isXMS", XMSflag
if XMSflag = -1 then keepgoing:
end

keepgoing:
XMSbytes& = 100000&
call sub "allocXMS", (XMSbytes&, XMShandle, XMSerror)



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

EMGET: copy data from EMS memory to system RAM

Parameters: EMSHandle, BytesToCopy&, Segment, Offset, EMSOffset&, EMSError

This subroutine copies BytesToCopy& bytes of data from
EMSOffset& in the EMS block associated with EMSHandle to
DOS memory at Segment:offset. Note that BytesToCopy and
EMSOffset are both long integers; ASIC's extended math
option is required. If something went wrong, an EMS error
code is returned in EMSError. The segment address of data
initilaized by ASIC can be found with ASICDS.

Restrictions: Must call IsEMS and AllocEMS before using this subroutine;
also helpful to have useful data in the EMS block before
retrieving it (see EMPUT). ASIC's Extended math option is
required.

Example:

REM I want to copy page 1 of the Hercules memory buffer to
REM EMS memory and retrieve it at a later time

call sub "isems", emsflag
if emsflag = 0 then drat:
hercbytes& = 32768&
call sub "allocems", (hercbytes&, handle, error)
if emserror = 0 then GotSomeEMS:
goto drat:

GotSomeEMS:
hercseg = &hexB000
hercoffset = &hex8000
call sub "emput",(handle, hercbytes&, hercseg, hercoffset, 0&, error)

.
.
.
REM later ...
REM restore the Hercules graph to page 0
call sub "emget",(handle, hercbytes&, hercseg, 0, 0&, error)
.
.

REM go here if no EMS
drat:
.
.

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

EMMOVE: move data within an EMS memory block

Parameters: EMSHandle, Bytes&, Source&, Destination&, EMSError

EMSHandle is a valid handle returned by AllocEMS. Bytes&
is the number of bytes you want to move. Source& is the
location in the EMS block where the data is, and Destination&
is the location in the same EMS block where you want the data
to be copied. EMMove works properly even when the source
and destination overlap.

Restrictions: Must call IsEMS and AllocEMS to produce valid EMSHandle. Also
copy valid data to the EMS memory block with EMPut before
using EMMove. ASIC's Extended math option is required.

Example:

call sub "emmove", (emshandle, bytes&, source&, destination&, oops)

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

EMPUT: copy data to EMS memory from system RAM

Parameters: EMSHandle, BytesToCopy&, Segment, Offset, EMSOffset&, EMSError

This subroutine copies BytesToCopy& bytes of data to
EMSOffset& in the EMS block associated with EMSHandle from
DOS memory at Segment:offset. Note that BytesToCopy and
EMSOffset are both long integers; ASIC's extended math
option is required. If something went wrong, an EMS error
code is returned in EMSError. The segment address of data
initilaized by ASIC can be found with ASICDS.

Restrictions: Must call IsEMS and AllocEMS before using this subroutine.
ASIC's Extended math option is required.

Example:

See example for EMGET.

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

EMSSPACE: determine total and available EMS memory

Parameters: no input parameters; returns total&, available&, emserror

EMSSPACE returns the total size of installed EMS memory in
bytes and the available unallocated EMS memory, also in
bytes. EMSError = 0 if there were no problems, otherwise
an EMS error is returned. ASIC's extended math option is
required.

Example:

call sub "emsspace", emstotal&. emsfree&, emserror



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

FLOADEMS: reads a disk file and copies to EMS memory

Parameters: File$, emshandle, bytes&, errcode

Loads file$ to EMS memory, returning ems handle, size of
file, and an error code. Note that errcode may either be
a DOS error or an EMS error. Errcode = 0 if there were
no problems. ASIC's Extended math option is required.

Restrictions: The program must call IsEMS before calling FLoadEMS to
determine if EMS memory is available.

Example:

file$ = "ASILIB.DOC"
call sub "floadems", file$, emshandle, bytes&, errcode



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

FLOADXMS: reads a disk file and copies to XMS memory

Parameters: File$, XMShandle, bytes&, errcode

Loads file$ to XMS memory, returning XMS handle, size of
file, and an error code. Note that errcode may either be
a DOS error or an XMS error. Errcode = 0 if there were
no problems. ASIC's Extended math option is required.

Restrictions: The program must call IsXMS before calling FLoadXMS to
determine if XMS memory is available.

Example:

file$ = "ASILIB.DOC"
call sub "floadxms", file$, xmshandle, bytes&, errcode



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

FREEEMS: release EMS memory allocated by other ASILIB subroutines

Parameters: ems handle, emserror

Releases EMS memory assicated with the EMS handle, allowing
that memory space to be used by other subroutines. Returns
emserror = 0 if no problem.

Example:

REM Allocate a block of 50000 bytes, then release the block later.

call sub "allocems", 50000&, emshandle
.
.
.
call sub "freeems", emshandle, emserror


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

FREEXMS: release XMS memory allocated by other ASILIB subroutines

Parameters: xms handle, emserror

Releases XMS memory assicated with the XMS handle, allowing
that memory space to be used by other subroutines. Returns
emserror = 0 if no problem.

Example:

REM Allocate a block of 50000 bytes, then release the block later.

call sub "allocxms", 50000&, xmshandle
.
.
.
call sub "freexms", xmshandle, xmserror


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

FSAVEEMS: Save EMS memory block as a disk file

Parameters: Filename$, emshandle, bytes&, errcode

FSaveEMS copies the first bytes& of EMS memory associated
with emshandle to a disk file. If a file by the same name
already exists, it will be overwritten by the new file.
Errcode = 0 if there were no problems; either EMS or DOS
errors are possible if something went wrong. Note that
bytes& is a long integer, requiring ASIC's extended math
option.

Restrictions: Requires a valid EMS handle; bytes& must not be greater than
the size of the memory block associated with emshandle.

Example:

file$="emsblock.dat"
call sub "fsaveems", file$, emshandle, bytes&, errcode


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

FSAVEXMS: Save XMS memory block as a disk file

Parameters: Filename$, xmshandle, bytes&, errcode

FSaveXMS copies the first bytes& of XMS memory associated
with xmshandle to a disk file. If a file by the same name
already exists, it will be overwritten by the new file.
Errcode = 0 if there were no problems; either XMS or DOS
errors are possible if something went wrong. Note that
bytes& is a long integer, requiring ASIC's extended math
option.

Restrictions: Requires a valid XMS handle; bytes& must not be greater than
the size of the memory block associated with xmshandle.

Example:

file$="xmsblock.dat"
call sub "fsavexms", file$, xmshandle, bytes&, errcode


°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

ISEMS: Determies if Expanded memory is installed

Parameters: No input parameters; returns EMSStatus = 0 if no EMS or
if EMS is having problems. EMSStatus = -1 if all OK.

Example:

REM determine if EMS memory is installed and ready.

call sub "IsEMS", EMSStatus



°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

ISXMS: Determines if Extended memory and XMS driver are installed.


Parameters: No input parameters; returns XMSStatus = 0 if no XMS or
if XMS driver is having problems. XMSStatus = -1 if all OK.

Example:

REM determine if XMS memory is installed and ready.

call sub "IsXMS", XMSStatus

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

XMGET: copy data from XMS memory to system RAM

Parameters: XMSHandle, BytesToCopy&, Segment, Offset, XMSOffset&, XMSError

This subroutine copies BytesToCopy& bytes of data from
XMSOffset& in the XMS block associated with XMSHandle to
DOS memory at Segment:offset. Note that BytesToCopy and
XMSOffset are both long integers; ASIC's extended math
option is required. If something went wrong, an XMS error
code is returned in XMSError. The segment address of data
initiliazed by ASIC can be found with ASICDS

Restrictions: Must call IsXMS and AllocXMS before using this subroutine;
also helpful to have useful data in the XMS block before
retrieving it (see XMPUT). ASIC's Extended math option is
required.

Example:

REM I want to copy page 1 of the Hercules memory buffer to
REM XMS memory and retrieve it at a later time

call sub "isxms", xmsflag
if xmsflag = 0 then drat:
hercbytes& = 32768&
call sub "allocxms", (hercbytes&, handle, error)
if xmserror = 0 then GotSomeXMS:
goto drat:

GotSomeXMS:
hercseg = &hexB000
hercoffset = &hex8000
call sub "XMput",(handle, hercbytes&, hercseg, hercoffset, 0&, error)

.
.
.
REM later ...
REM restore the Hercules graph to page 0
call sub "XMget",(handle, hercbytes&, hercseg, 0, 0&, error)
.
.

REM go here if no XMS
drat:
.
.

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

XMMOVE: move data within an XMS memory block

Parameters: XMSHandle, Bytes&, Source&, Destination&, XMSError

XMSHandle is a valid handle returned by AllocXMS. Bytes&
is the number of bytes you want to move. Source& is the
location in the XMS block where the data is, and Destination&
is the location in the same XMS block where you want the data
to be copied. XMMove works properly even when the source
and destination overlap.

Restrictions: Must call IsXMS and AllocXMS to produce valid XMSHandle. Also
copy valid data to the XMS memory block with XMPut before
using XMMove. ASIC's Extended math option is required.

Example:

call sub "XMmove", xmshandle, bytes&, source&, destination&, oops

°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

XMPUT: copy data to XMS memory from system RAM

Parameters: XMSHandle, BytesToCopy&, Segment, Offset, XMSOffset&, XMSError

This subroutine copies BytesToCopy& bytes of data to
XMSOffset& in the XMS block associated with XMSHandle from
DOS memory at Segment:offset. Note that BytesToCopy and
XMSOffset are both long integers; ASIC's extended math
option is required. If something went wrong, an XMS error
code is returned in XMSError. The segment address of data
initiliazed by ASIC can be found with ASICDS

Restrictions: Must call IsXMS and AllocXMS before using this subroutine.
ASIC's Extended math option is required.

Example:

See example for XMGET.