ID: Q75682
WextMem.exe is a file that contains source code for a Windows-based application that reports the amount of extended memory installed in the machine on which the program is run.
For a Windows-based application to determine the amount of extended memory installed in the machine on which it is running, the extended memory word can be retrieved from the machine's AT Real Time Clock/CMOS RAM. Typically, 80286, 80386 SX, 80386 DX, and i486 based computers store setup information in CMOS. This article details how to access this data.
The following file is available for download from the Microsoft Software Library:
~ WextMem.exe (size: 20613 bytes)
For more information about downloading files from the Microsoft Software
Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591
TITLE : How to Obtain Microsoft Support Files from Online Services
The AT Real Time Clock/CMOS RAM is accessed via port 70h, and read from and
written to via port 71h. The extended memory word is stored low-order byte
first in the CMOS. The first (low order) byte is stored at address 17h, and
the second (high order) byte is stored at address 18h.
To read a particular address in the CMOS, write the address to read to port 70h, then retrieve the information from port 71h. Figure 1 contains a code fragment, written in Microsoft C version 6.0 with inline assembly, which shows how to check the CMOS for extended memory size. For compatibility with future versions of Windows, the following code should NOT be placed directly into a Windows-based application. Instead, this code should be placed in a dynamic-link library (DLL), which can be called by applications.
int MemorySize = 0;
_asm
{
xor ax, ax
mov al, 17h
out 70h, al
; jmp $+3 ; delay not needed in most cases
in al, 71h
mov MemorySize, ax
mov al, 18h
out 70h, al
; jmp $+3 ; delay not needed in most cases
in al, 71h
xchg al, ah
or MemorySize, ax
}
printf("\nExtended Memory size = %u KB\n", MemorySize);
The AT Real Time Clock/CMOS RAM configuration is documented in its entirety
in the IBM PC technical reference, on pages 1-56 to 1-68. The information
contained in the article was obtained from "The Programmer's PC Source
Book," by Thom Hogan, published by Microsoft Press (1988).
Please note that although the BIOS on most machines automatically configures the CMOS entry for extended memory size with the amount of memory the BIOS power-on self-test (POST) routines find in the machine, some BIOS setup programs allow the user to configure the extended memory setting themselves. If the user has not filled in the correct number for the amount of extended memory installed in the machine, the check described in this article will be useless.
Additional query words: Keywords : kbfile kbsample kb16bitonly kbKernBase kbMemory
Last Reviewed: December 11, 1998