[comp.sys.ibm.pc] How do I determine how much EGA memory is installed?

tr@thumper.UUCP (03/30/87)

[]

The following question pertains to IBM PC's.  (I am using a PC/AT.)

I know it's possible to determine how much memory is installed on an
EGA board so that an application does not die from a false assumption
of the amount of EGA memory present.  I know this because some
applications print a message like "You need 256K to run this program."
Does someone have a program written in C or Assembler that does this
test?  I would like to see an example.

Thank you.

-- 
Tom Reingold
Internet: tr@bellcore.com
Uucp: ..!allegra!ulysses!faline!flash!tr

catone@dsl.cis.upenn.edu.UUCP (04/01/87)

In article <548@thumper.UUCP> tr@thumper.UUCP writes:
>
>I know it's possible to determine how much memory is installed on an
>EGA board so that an application does not die from a false assumption
>of the amount of EGA memory present.  I know this because some
>applications print a message like "You need 256K to run this program."
>Does someone have a program written in C or Assembler that does this
>test?  I would like to see an example.
>-- 
>Tom Reingold
>Internet: tr@bellcore.com
>Uucp: ..!allegra!ulysses!faline!flash!tr

Service request 12 hex of BIOS video interrupt 10 hex returns EGA
information.  Upon return: bh signals color mode (0) or mono mode (1)
in effect; bl contains the memory on the EGA in its two least
significant bits (0 0 = 64K, 0 1 = 128K, 1 0 = 192K, 1 1 = 256K); ch
contains the feature bits; cl contains the switch setting.

The above is from the Proceedings of the IBM Personal Computer Seminar
on the EGA, which also contains sample code, though with the above
information you shouldn't need it.

					- Tony
					  catone@dsl.cis.upenn.edu
					  catone@wharton.upenn.edu

tr@thumper.UUCP (04/06/87)

OK, I have had help and this is what I have learned.  I am enclosing
an example.  The function called egamem() will return an integer with
a value of 64, 128, 192, or 256.

This example works with Lattice C.  If it does not work with your
compiler, check the declarations for REGS in <dos.h> and make the proper
modification to the program.


#include <stdio.h>
#include <stdlib.h>
#include <dos.h>

main()
{
	printf("You have %d K bytes of video RAM installed.\n", egamem());
}


egamem()
{
	union REGS *in, *out;
	static int amount;

	in  = (union REGS *) malloc(sizeof(union REGS));
	out = (union REGS *) malloc(sizeof(union REGS));
	in->h.ah = 0x12;
	in->h.bl = 0x10;
	int86(0x10, in, out);
	amount = 64 * ((((int) out->h.bl) & 3) + 1);
	free((char *) in);
	free((char *) out);
	return(amount);
}
-- 
Tom Reingold
INTERNET:       tr@bellcore.com
UUCP: 		..!decvax!ucbvax!ulysses!bellcore!tr
		     ihnp4!mhuxt/