1. Free XMS
- Posted by Greg Harris <blackdog at CDC.NET> Aug 13, 1997
- 634 views
- Last edited Aug 14, 1997
Hello all, I need a function to detect the amount of free xms memory during a program. I know how to detect if XMS driver is loaded and to get the driver Entry Point using interrupt 2Fh, however I do not know how to do a assembly function in Euphoria. The assembly looks something like this xmaadress is the 32 bit address of the entry point. dx stores the amount of free xms in K pushad mov ah, 08h call [xmaadress] mov [freemem], dx popad ret I need to be able to return the freemem value. Thanks for the help in advance, Greg Harris
2. Re: Free XMS
- Posted by Jacques Deschenes <desja at GLOBETROTTER.QC.CA> Aug 13, 1997
- 621 views
- Last edited Aug 14, 1997
At 20:37 13-08-97 -0400, you wrote: >Hello all, > >I need a function to detect the amount of free xms memory during a program. >I know how to detect if XMS driver is loaded and to get the driver Entry >Point using interrupt 2Fh, however I do not know how to do a assembly >function in Euphoria. The assembly looks something >like this > >xmaadress is the 32 bit address of the entry point. >dx stores the amount of free xms in K > >pushad >mov ah, 08h >call [xmaadress] >mov [freemem], dx >popad >ret > >I need to be able to return the freemem value. > >Thanks for the help in advance, > >Greg Harris > > from inside an euphoria program it's better to use DPMI services to get information about available memory. The following code is the demo for that. ----------------- clip here ------------------------------- -- demo: getting information about available memory. -- -- organisation of data_struct filled by DPMI service #500 -- -- Offset Description -- -- 00h Largest available free block in -- bytes -- -- 04h Maximum unlocked page allocation -- -- 08h Maximum locked page allocation -- -- 0Ch Linear addr space size in pages -- -- 10h Total number of unlocked pages -- -- 14h Number of free pages -- -- 18h Total number of physical pages -- -- 1Ch Free linear address space in pages -- -- 20h Size of paging file/partition in -- pages include machine.e atom data_struct data_struct = allocate(#30) if not data_struct then abort(1) end if mem_set(data_struct,0,#30) constant sFree_mem = { #60, -- pushad #06, -- push es #1E, -- push ds #07, -- pop es #BF}&int_to_bytes(data_struct)&{ -- mov edi, data_struct #B8,0,5,0,0, -- mov eax, #500 #CD,#31, -- int #31 #07, -- pop es #61, -- popad #C3 -- ret } atom cFree_mem cFree_mem = allocate(length(sFree_mem)) if not cFree_mem then free(data_struct) abort(1) end if poke(cFree_mem,sFree_mem) call(cFree_mem) atom free_block, max_unlocked, page_size, total_free, max_locked, total_virtual, total_number_unlocked, total_physical, free_linear, paging_file free_block = bytes_to_int(peek({data_struct,4})) max_unlocked = bytes_to_int(peek({data_struct+4,4})) page_size = free_block/max_unlocked max_locked = bytes_to_int(peek({data_struct+8,4})) total_virtual = bytes_to_int(peek({data_struct+#C,4}))*page_size total_number_unlocked = bytes_to_int(peek({data_struct+#10,4})) total_free = bytes_to_int(peek({data_struct+#14,4})) total_physical = bytes_to_int(peek({data_struct+#18,4})) free_linear = bytes_to_int(peek({data_struct+#1C,4})) paging_file = bytes_to_int(peek({data_struct+#20,4})) printf(1,"00h Largest available free block = %10d bytes\n", {free_block}) printf(1,"04h Maximum unlocked pages allocation = %5d pages\n", {max_unlocked}) printf(1,"08h Maximum locked pages allocation = %5d pages\n",{max_locked}) printf(1,"0Ch total virtual memory = %10d\n",{total_virtual}) printf(1,"10h Total number of unlocked pages = %5d\n",{total_number_unlocked}) printf(1,"14h Number of free pages = %d\n",{total_free}) printf(1,"18h Total number of physical pages= %5d (%10d bytes)\n", {total_physical,total_physical*page_size}) printf(1,"1Ch free linear address space = %5d pages\n",{free_linear}) printf(1,"20h size of paging file = %10d pages\n",{paging_file}) free(cFree_mem) free(data_struct) ------ clip here -------------------------------------- Jacques Deschenes Baie-Comeau, Quebec Canada desja at globetrotter.qc.ca
3. Re: Free XMS
- Posted by Greg Harris <blackdog at CDC.NET> Aug 14, 1997
- 608 views
- Last edited Aug 15, 1997
Jacques, > from inside an euphoria program it's better to use DPMI services to get > information > about available memory. The following code is the demo for that. > Jacques Deschenes > Baie-Comeau, Quebec > Canada > desja at globetrotter.qc.ca Thanks a lot!! Works great. I was having problems allocating a lot of memory in DOS but in Windows it was working fine. Got it plugged into the program and have no problems with crashing now. Thanks again! Greg Harris