home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / BASIC / POWBASIC / LIBRARY1 / EMSINF.ZIP / EMSINFO.BAS
BASIC Source File  |  1990-05-12  |  5KB  |  118 lines

  1. 'EMS analysis program for PowerBASIC #2.00
  2.  
  3. 'This program determines whether Expanded Memory (EMS) is available on
  4. 'your system.  If so, it displays the segment of the "page frame".  The
  5. 'page frame is the 64K of real mode memory through which EMS is accessed.
  6. 'If your EMS driver locates the page frame below segment A000 (hex), the
  7. 'total memory available to PowerBASIC is actually reduced due to memory
  8. 'fragmentation.  It is best not to use such an EMS driver with PowerBASIC.
  9.  
  10.  
  11. 'Please note that I have modified the original version of EMSFRM and
  12. 'shown how to get some more EMS information.  I "lifted" the code from
  13. 'some assembly programs I has lying around.  -Rober Barrett
  14.  
  15. %AX = 1: %BX = 2: CX = 3: %DX = 4: %SI = 5: %DI = 6
  16. %BP = 7: %DS = 8: %ES = 9% 'register equates for REG
  17.  
  18. memlimit& = 640 * 1024 / 16
  19. def fndigs$(h%) = right$("000"+hex$(h%),4)
  20.  
  21. cls
  22. print "EMSFRM: EMS Page Frame Analyzer for PowerBASIC #2.00": print
  23.  
  24. reg %AX, &h3567
  25. call interrupt &h21        'check for EMS presence
  26. def seg = reg(%ES)
  27. if peek$(10,8)<>"EMMXXXX0" then goto NoEMS
  28.  
  29. reg %AX, &h4100
  30. call interrupt &h67        'get EMS page frame in BX, status in AH
  31. if (reg(%AX) AND &h0FF00) <> 0 then goto NoEMS
  32.  
  33. print "Your system contains EMS memory.  The page frame is located at"
  34. print "segment ";fndigs$(reg(%BX));" (hex).  PowerBASIC will use this 64K ";
  35. print "frame to store"
  36. print "the source file that is being compiled."
  37.                 'here if we have EMS -- now check page frame
  38. pframe& = cvl(mki$(reg(%BX))+chr$(0,0))
  39. if pframe& < memlimit& then    'page frame in low memory -- useless
  40.   print "Since the page frame is located in the main 640K of memory (below"
  41.   print "segment A000 hex), using the EMS driver that is currently present in"
  42.   print "your system will actually reduce the memory available to PowerBASIC"
  43.   print "during compilation, due to memory fragmentation.  In order to make"
  44.   print "better use of your resources, you should install an EMS driver which"
  45.   print "places its page frame at or above segment A000."
  46. else                'page frame in high memory -- okay
  47.   print "You may wish to run DOS' CHKDSK program before and after loading"
  48.   print "your EMS driver, in order to determine how much of your main 640K"
  49.   print "memory the driver uses.  If your driver requires a large portion"
  50.   print "of memory (48-64K for example), you may not gain much additional"
  51.   print "compilation space by using your EMS with PowerBASIC."
  52. end if
  53. '***************************************************************************
  54. '                             NEW CODE ADDED HERE
  55. '***************************************************************************
  56.  
  57. reg %AX, &h4200                 'get available EMS pages
  58. call interrupt &h67
  59. NumberofPages = reg(%BX)        'available pages in BX
  60. TotalPages = reg(%DX)           'total pages in DX
  61.  
  62. print "Your system has a total of";TotalPages;"EMS pages with";NumberOfPages
  63. print "of them available at this moment"
  64. print
  65.  
  66. '---------------------------------------------------------------------------
  67.  
  68. reg %AX, &h4000     'Check to see if EMS OK, if AL=0 then OK
  69. call interrupt &h67
  70. if (reg(%AX) AND &h0FF00) = 0 then
  71.   print "EMS reports that it is OK"
  72. else
  73.   print "EMS does not report OK"
  74. end if
  75.  
  76. '---------------------------------------------------------------------------
  77.  
  78. reg %AX, &h4600     'Get EMS version (returned in AX)
  79. call interrupt &h67
  80. EMSVersion$ = hex$(reg(%AX))
  81. EMSVersion$ = left$(EmsVersion$,1) + "." + right$(EMSVersion$,1)
  82. print "EMS version number is ";EMSVersion$
  83.  
  84. '---------------------------------------------------------------------------
  85.  
  86. reg %AX, &h4B00     'Get number of handles in use (from BX)
  87. call interrupt &h67
  88. NumberofHandles = reg(%BX)
  89. print
  90. print "There are currrently";NumberofHandles;"handles in use:"
  91.  
  92. for x% = 1 to NumberofHandles
  93.   reg %AX, &h4C00
  94.   reg %DX, x%
  95.   call interrupt &h67
  96.   HandleSize = reg(%BX)
  97.   if x% = 1 then HandleSize = HandleSize + 1
  98.   print using "Handle:##     Pages in use:###";x%,HandleSize
  99. next x%
  100.  
  101. 'As to why I add 1 to the size of the first handle, I can only say that
  102. 'other programs of this type always reported the first handle as being one
  103. 'larger than my program did until I added the part to add 1 to its size.
  104. 'Also, this makes the numbers of pages in use per handle add up to the
  105. 'total number of pages in use as reported by the EMS manager.  Given that
  106. 'I know little/nothing about EMS, it could very well be that the EMS manager
  107. 'uses 1 page (the page frame?) for overhead. -Robert Barrett
  108.  
  109. '***************************************************************************
  110. '                           END OF ADDED CODE
  111. '***************************************************************************
  112. end
  113.  
  114. NoEMS:
  115.  
  116. print "Your system does not appear to contain any EMS memory."
  117. end
  118.