home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / MMFIRST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1009 b   |  47 lines

  1. /**
  2. *
  3. * Name        mmfirst -- Report address of first memory control block.
  4. *
  5. * Synopsis    firstblock = mmfirst();
  6. *
  7. *        unsigned firstblock
  8. *                  Segment address (i.e., paragraph
  9. *                  number) of the first DOS memory block,
  10. *                  or 0 if error.
  11. *
  12. * Description    This function reports the size of the first DOS memory
  13. *        block.
  14. *
  15. * Returns    firstblock      Segment address (i.e., paragraph
  16. *                  number) of the first DOS memory block,
  17. *                  or 0 if error.
  18. *
  19. * Version    6.00 (C)Copyright Blaise Computing Inc. 1989
  20. *
  21. **/
  22.  
  23. #include <dos.h>
  24.  
  25. #include <bmem.h>
  26. #include <butil.h>
  27.  
  28. unsigned mmfirst()
  29. {
  30.     union REGS     regs;
  31.     struct SREGS sregs;
  32.     unsigned     result;
  33.     MEMCTRL     ctlblock;
  34.     unsigned     nextblock;
  35.     int      ercode;
  36.  
  37.     regs.h.ah = 0x52;
  38.     intdosx(®s,®s,&sregs);
  39.     result = utpeekw(uttofaru(sregs.es,regs.x.bx - 2)) + 1;
  40.  
  41.     ercode = mmctrl(result,&ctlblock,&nextblock);
  42.     if (ercode != 0 && ercode != 18)
  43.     result = 0;
  44.  
  45.     return result;
  46. }
  47.