From: "Tony O'Bryan" Newsgroups: comp.os.msdos.djgpp Subject: Re: Physical Memory Date: Tue, 06 Jan 1998 14:05:41 -0600 Organization: Southwest Missouri State University Lines: 65 Message-ID: <34B28E95.2D92@nic.smsu.edu> References: <19980106192149 DOT 8027 DOT qmail AT hotmail DOT com> Reply-To: aho450s AT nic DOT smsu DOT edu NNTP-Posting-Host: marie.a30.smsu.edu Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1A5D54315340" To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk This is a multi-part message in MIME format. --------------1A5D54315340 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit John Patton wrote: > > Hi, > > I am trying to locate some code that gets the > amount of actual physical memory installed on > the machine. I am not concerned at this time > about virtual memory or available memory. If > the machine has 32MB of real memory, I want to > display this. I tried using the biosmemory() > function and the most I can get it to return is > 640k. My machine has 32MB installed, not 640k. > If anyone knows a way to do this, I would greatly > appreciate it. This polls the CMOS to determine how much memory your system has: -- Tony O'Bryan http://www.geocities.com/SiliconValley/Park/7201 --------------1A5D54315340 Content-Type: text/plain; charset=us-ascii; name="Test.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Test.c" #include #include int GetPhysicalMemory(void) { unsigned BaseMemory; unsigned ExtendedMemory; /* Gets the amount of base memory from CMOS up to 640K */ outportb(0x70,0x15); BaseMemory = inportb(0x71); outportb(0x70,0x16); BaseMemory += inportb(0x71) << 8; /* Gets the amount of extended memory from CMOS */ outportb(0x70,0x17); ExtendedMemory = inportb(0x71); outportb(0x70,0x18); ExtendedMemory += inportb(0x71) << 8; /* * Always leaves off the 384K between 640K and 1M, so add it in if there is * any extended memory present. */ ExtendedMemory += ExtendedMemory ? 384 : 0; return ExtendedMemory + BaseMemory; } --------------1A5D54315340--