TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: DANIEL TROY
from: PETER LOUWEN
date: 1997-10-11 20:23:00
subject: Re: extended memory

 -=> Quoting Daniel Troy to All <=-
 DT> is there a way to use extended memory for programs without using
 DT> protected mode ? 
Sure: use the eXtended Memory Specification (XMS).
Here's what you can do using XMS:
    XMS (Int 2F/43; Multiplex)
 INT 2F - INSTALLATION CHECK
     AX = 4300h
 Return: AL = 80h XMS driver installed
     AL  80h no driver
 Notes:  XMS gives access to extended memory and noncontiguous/nonEMS
       memory above 640K
     this installation check DOES NOT follow the format used by other
       software
 SeeAlso: AX=4310h
 --------
 INT 2F - XMS - GET DRIVER ADDRESS
     AX = 4310h
 Return: ES:BX -> driver entry point
 SeeAlso: AX=4300h
 Perform a FAR call to the driver entry point with AH set to the function
        code
     AH  function
     00h  Get XMS version number
          Return: AX = XMS version (in BCD)
              BX = internal revision number
              DX = 0001h if HMA (1M to 1M + 64K) exists
               0000h if HMA does not exist
     01h  Request High Memory Area (1M to 1M + 64K)
          DX = memory in bytes (for TSR or device drivers)
           FFFFh if application program
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below [ omitted for sake of brevity - PL 
])
     02h  Release High Memory Area
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
     03h  Global enable A20, for using the HMA
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
     04h  Global disable A20
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
     05h  Local enable A20, for direct access to extended memory
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
     06h  Local disable A20
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
     07h  Query A20 state
          Return: AX = 0001h enabled
             = 0000h disabled
              BL = error code (0 = successful)
     08h  Query free extended memory, not counting HMA
          Return: AX = size of largest extended memory block in K
              DX = total extended memory in K
              BL = error code (see below)
     09h  Allocate extended memory block
          DX = Kbytes needed
          Return: AX = 0001h success
                DX = handle for memory block
             = 0000h failure
                BL = error code (see below)
     0Ah  Free extended memory block
          DX = handle of block to free
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
     0Bh  Move extended memory block
          DS:SI -> EMM structure (see below)
          Note: if either handle is 0000h, the corresponding offset is
            considered to be an absolute segment:offset address in
            directly addressable memory
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
     0Ch  Lock extended memory block
          DX = handle of block to lock
          Return: AX = 0001h success
                DX:BX = 32-bit linear address of locked block
             = 0000h failure
                BL = error code (see below)
     0Dh  Unlock extended memory block
          DX = handle of block to unlock
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
     0Eh  Get handle information
          DX = handle for which to get info
          Return: AX = 0001h success
                BH = block's lock count
                BL = number of free handles left
                DX = block size in K
             = 0000h failure
                BL = error code (see below)
     0Fh  Reallocate extended memory block
          DX = handle of block
          BX = new size of block in K
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
     10h  Request upper memory block (nonEMS memory above 640K)
          DX = size of block in paragraphs
          Return: AX = 0001h success
                BX = segment address of UMB
                DX = actual size of block
             = 0000h failure
                BL = error code (see below)
                DX = largest available block
     11h  Release upper memory block
          DX = segment address of UMB to release
          Return: AX = 0001h success
             = 0000h failure
                BL = error code (see below)
There are other ways of allocating extended memory (Int 15h, the VDISK 
cheme)
but these are old, kludgy, obsolete, ugly, and to be discouraged.
 DT> also how is it some programs that are bigger than 640k are able to
 DT> load? i mean sure they might switch into protected mode but doesnt dos
 DT> first try to load the whole thing into memory? 
No: when COMMAND.COM, or a substitute, wants to load an EXE file, it reads 
he
first 28 bytes of that file, the so called EXE header. From this header, it
calculates the number of bytes to be loaded; this amount can be a lot smaller
than the DOS file size.
The small part is read into memory, which then takes care of the rest.
Peter
... You may as well take a person's money as his time.  
--- EBO-BBS Diemen - NL
---------------
* Origin: EBO-BBS Diemen (http://www.worldonline.nl/~biginski) (2:280/901)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.