home *** CD-ROM | disk | FTP | other *** search
- 'EMS analysis program for PowerBASIC #2.00
-
- 'This program determines whether Expanded Memory (EMS) is available on
- 'your system. If so, it displays the segment of the "page frame". The
- 'page frame is the 64K of real mode memory through which EMS is accessed.
- 'If your EMS driver locates the page frame below segment A000 (hex), the
- 'total memory available to PowerBASIC is actually reduced due to memory
- 'fragmentation. It is best not to use such an EMS driver with PowerBASIC.
-
-
- 'Please note that I have modified the original version of EMSFRM and
- 'shown how to get some more EMS information. I "lifted" the code from
- 'some assembly programs I has lying around. -Rober Barrett
-
- %AX = 1: %BX = 2: CX = 3: %DX = 4: %SI = 5: %DI = 6
- %BP = 7: %DS = 8: %ES = 9% 'register equates for REG
-
- memlimit& = 640 * 1024 / 16
- def fndigs$(h%) = right$("000"+hex$(h%),4)
-
- cls
- print "EMSFRM: EMS Page Frame Analyzer for PowerBASIC #2.00": print
-
- reg %AX, &h3567
- call interrupt &h21 'check for EMS presence
- def seg = reg(%ES)
- if peek$(10,8)<>"EMMXXXX0" then goto NoEMS
-
- reg %AX, &h4100
- call interrupt &h67 'get EMS page frame in BX, status in AH
- if (reg(%AX) AND &h0FF00) <> 0 then goto NoEMS
-
- print "Your system contains EMS memory. The page frame is located at"
- print "segment ";fndigs$(reg(%BX));" (hex). PowerBASIC will use this 64K ";
- print "frame to store"
- print "the source file that is being compiled."
- 'here if we have EMS -- now check page frame
- pframe& = cvl(mki$(reg(%BX))+chr$(0,0))
- if pframe& < memlimit& then 'page frame in low memory -- useless
- print "Since the page frame is located in the main 640K of memory (below"
- print "segment A000 hex), using the EMS driver that is currently present in"
- print "your system will actually reduce the memory available to PowerBASIC"
- print "during compilation, due to memory fragmentation. In order to make"
- print "better use of your resources, you should install an EMS driver which"
- print "places its page frame at or above segment A000."
- else 'page frame in high memory -- okay
- print "You may wish to run DOS' CHKDSK program before and after loading"
- print "your EMS driver, in order to determine how much of your main 640K"
- print "memory the driver uses. If your driver requires a large portion"
- print "of memory (48-64K for example), you may not gain much additional"
- print "compilation space by using your EMS with PowerBASIC."
- end if
- '***************************************************************************
- ' NEW CODE ADDED HERE
- '***************************************************************************
-
- reg %AX, &h4200 'get available EMS pages
- call interrupt &h67
- NumberofPages = reg(%BX) 'available pages in BX
- TotalPages = reg(%DX) 'total pages in DX
-
- print "Your system has a total of";TotalPages;"EMS pages with";NumberOfPages
- print "of them available at this moment"
- print
-
- '---------------------------------------------------------------------------
-
- reg %AX, &h4000 'Check to see if EMS OK, if AL=0 then OK
- call interrupt &h67
- if (reg(%AX) AND &h0FF00) = 0 then
- print "EMS reports that it is OK"
- else
- print "EMS does not report OK"
- end if
-
- '---------------------------------------------------------------------------
-
- reg %AX, &h4600 'Get EMS version (returned in AX)
- call interrupt &h67
- EMSVersion$ = hex$(reg(%AX))
- EMSVersion$ = left$(EmsVersion$,1) + "." + right$(EMSVersion$,1)
- print "EMS version number is ";EMSVersion$
-
- '---------------------------------------------------------------------------
-
- reg %AX, &h4B00 'Get number of handles in use (from BX)
- call interrupt &h67
- NumberofHandles = reg(%BX)
- print
- print "There are currrently";NumberofHandles;"handles in use:"
-
- for x% = 1 to NumberofHandles
- reg %AX, &h4C00
- reg %DX, x%
- call interrupt &h67
- HandleSize = reg(%BX)
- if x% = 1 then HandleSize = HandleSize + 1
- print using "Handle:## Pages in use:###";x%,HandleSize
- next x%
-
- 'As to why I add 1 to the size of the first handle, I can only say that
- 'other programs of this type always reported the first handle as being one
- 'larger than my program did until I added the part to add 1 to its size.
- 'Also, this makes the numbers of pages in use per handle add up to the
- 'total number of pages in use as reported by the EMS manager. Given that
- 'I know little/nothing about EMS, it could very well be that the EMS manager
- 'uses 1 page (the page frame?) for overhead. -Robert Barrett
-
- '***************************************************************************
- ' END OF ADDED CODE
- '***************************************************************************
- end
-
- NoEMS:
-
- print "Your system does not appear to contain any EMS memory."
- end