Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

Memory handling

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
jack_p50
Asked:
jack_p50
1 Solution
 
omsecCommented:
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
 
jack_p50Author Commented:
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
 
jack_p50Author Commented:
btw, thanx for drives routings
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
omsecCommented:
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
 
flobeckerCommented:
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
 
jack_p50Author Commented:
 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
 
omsecCommented:
does the XMS-Solution also not work, if you do any changes in the PIF-File of the shortcut ?
0
 
jack_p50Author Commented:
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
 
omsecCommented:
FPK uses Unix (AT&A) Assembler-Style, use the -rIntel Switch to compile Intel Style ASM
0
 
jack_p50Author Commented:
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
 
RaidCommented:
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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now