home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / SNIP9404.ZIP / MEMAVAIL.C < prev    next >
C/C++ Source or Header  |  1994-04-03  |  511b  |  33 lines

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