Solved

Memory handling

Posted on 1998-10-12
11
222 Views
Last Modified: 2010-04-16
Does anybody know how to handle large amounts of memory
(maybe almost all) in DOS program under WINdows?
Send me some unit or give some link to related site.
Thanx
0
Comment
Question by:jack_p50
11 Comments
 
LVL 2

Expert Comment

by:omsec
ID: 1215769
can you be a bit more clear ?
what exactly should your program do ? fe. load huge files, or need big arrays ? and what compiler do you use ?

i think, anyway programming with pointers will be good...
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1215770
I use BP 7.0 and Lower-memory is to small - i'm writing Graphics editor, and it need big
swap space - more than 1.5 Mb. So i need some stuff to use not only lower memory,
I tryed flat mode but it doesn't work under Windows, and i want to run my program
only under windows(i'll write a game with same format and i don't want people to run it
under dos-emulation). You can contact me by ICQ: 17635851.
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1215771
btw, thanx for drives routings
0
 
LVL 2

Expert Comment

by:omsec
ID: 1215772
Well, the perfect Way to do so, is to use a "real" 32bit protected Mode Compiler, such as FPK-Pascal which is Freeware, where you have the Possibility to use a Dos-Extender and to set maximum SWAP-Memory for your Application easily, directly using a Compiler Switch. (Just for Example, the default Value there is 4MB).

Aince, Borland PAscal 7 is a 16bit Compiler, (even in protected Mode) you might have to use your own Technique and Way to manage your SWAP-Files. I don't know that much about the internal Informations of your Program, but I would move large Objects using BLockWrite/BlockRead Procedures and dynamic Pointers to the Hard Disk and load them when needed.

For Example, this is how i would manage the SWAP-File of the current Configuration :
(Flags, Settings, Program Variables)

Type
  PConfig = ^TConfig;
  TConfig = Record
                    ID : String[9]; // Swap-File
                    EditorFiles : Array [1..10] of String[50];
                    SaveChangesAuto : Byte;
                    { This Record defines Information you "need" in this Example to save the
                      Configuration Data, such as File Names, Flags like "UseThisFunction :                       Byte" 0 = no, 1 = yes etc.}
                  End;

Var
  ConfigFileTempFile : File;
  ConfigHeader : PConfig;

Begin
  New(ConfigHeader);
  ... {Assign/Open/Create the File here}
  BlockRead(ConfigTempFile, ConfigHeader^, SizeOf(ConfigHeader^));
  ... {Use/Change the Data}
  BlockWrite...{Swap the Data to Disk, Params as above}
  Dispose(ConfigHeader); {givew this MEmory free for other stuff
End.

Hoping you understand my general SWAP-Manage-Idea :)

greets, Roger

btw: for more info bout FPK-Padscal or anything else you may find my addresses on my User Profile, just lick on 'omsec' link...
0
 

Expert Comment

by:flobecker
ID: 1215773
Hello jack_p50,

what about using XMS-Memory? I wrote some short progs in ASM accessing the XMS. It should be possible in PAS, too! Tell me, when you're interested, so I can give you more information.
Just to give you an idea of XMS and how it works (maybe you don't want do use such a thing): A XMS-driver like HIMEM.SYS has to be installed. Then you reserve a part (or all) of the available XMS (can't remember what's the maximum, 1GByte or so!). You may copy data-blocks between conventional memory (640k)and XMS or back and even between XMS and XMS, just using the XMS-driver's API (no protected mode, it's easy!). Ok, maybe a few lines of ASM have to be included, but i think that's easy!

FloBecker

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 4

Author Comment

by:jack_p50
ID: 1215774
 I already tried XMS-driver, but it doesn't work - it causes windows memory protection
fault - and program termination, so i don't know why?
  Hi, Omsec, i'm d/loading FPK now, so wait a little to me to see what's it.
0
 
LVL 2

Expert Comment

by:omsec
ID: 1215775
does the XMS-Solution also not work, if you do any changes in the PIF-File of the shortcut ?
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1215776
XMS don't work under windows some cause, but i have some mod-player that uses it
and works good. Any ideas?(i have the unit similar to that in mod-player)
Sorry, but it seems i can't use FPK coz it have some different syntax, so many
of the units i use can't be compiled(FPK's ASM isn't the same, and there're some more
differences, but it seems that FPK is in general better than BP).
So maybe you'll try to help me with XMS???
Thanx.
0
 
LVL 2

Expert Comment

by:omsec
ID: 1215777
FPK uses Unix (AT&A) Assembler-Style, use the -rIntel Switch to compile Intel Style ASM
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1215778
Thanx, Omsec, i'll do it if anyone willn't find problem wtih XMS int 2-3 days, if not
post your answer again.
0
 

Accepted Solution

by:
Raid earned 10 total points
ID: 1215779
Hey Jack_p50, this is Raid:
if you are looking to use EMS memory in Turbo Pascal 6.0,
here it is:

uses
 crt, objects;

var
 a: byte;
 emsmem: temsstream;

begin
 emsmem.init(500, 500); { Init memory to 500 bytes, can be                           anything }
 emsmem.seek(0); { seek the top of the ems }
 emsmem.write(a, 1); { write variable to ems }
 emsmem.seek(0); { seek the top of the ems again }
 emsmem.read(a, 1); { read variable from ems }
 writeln(a); { write it to screen }
 emsmem.done; { De-Initialize }
 repeat until keypressed;
end.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now