Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
GetMem
◄Example► ◄Back► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
;* GetMem - Gets total size of memory and determines the largest amount of
;* unallocated memory available. GetMem invokes DOS Function 48h (Allocate
;* Memory) to request an impossibly large memory block. DOS denies the re-
;* quest, but returns instead the size of the largest block available. This
;* is the amount that GetMem returns to the calling program. See the WinOpen
;* procedure for an example of calling Function 48h to allocate unused memory.
;*
;* Shows: BIOS Interrupt - 12h (Get Conventional Memory Size)
;*
;* Params: None
;*
;* Return: Long integer, high word = total memory in kilobytes (KB)
;* low word = largest block of available memory (KB)
GetMem PROC
int 12h ; Get total memory in K
push ax ; Save size of memory
mov ah, 48h ; Request memory allocation
mov bx, 0FFFFh ; Ensure request is denied for
; impossibly large block
int 21h ; Get largest available block in BX
mov ax, bx ; Copy to AX
mov cl, 6 ; Convert paragraphs to kilobytes by
shr ax, cl ; dividing by 64
pop dx ; Recover total in DX
ret ; Return long integer DX:AX
GetMem ENDP
-♦-