home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / MEMAVAIL.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  595b  |  37 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  MEMAVAIL.C - Report available DOS memory
  5. **
  6. **  public domain by Thor Johnson
  7. */
  8.  
  9. #include <dos.h>
  10. #include "snpdosys.h"
  11.  
  12. long memavail(void)
  13. {
  14.       union REGS regs;
  15.  
  16.       /* Request impossibly large number of 16-byte paragraphs from DOS */
  17.  
  18.       regs.h.ah = 0x48;
  19.       regs.x.bx = 0xFFFF;
  20.  
  21.       int86(0x21,®s,®s);
  22.  
  23.       return((long)regs.x.bx * 16L);
  24. }
  25.  
  26. #ifdef TEST
  27.  
  28. #include <stdio.h>
  29.  
  30. main()
  31. {
  32.       printf("Available DOS memory = %ld bytes\n", memavail());
  33.       return 0;
  34. }
  35.  
  36. #endif /* TEST */
  37.