Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!think.com!snorkelwacker.mit.edu!hsdndev!dartvax!eleazar.dartmouth.edu!crystal From: crystal@eleazar.dartmouth.edu (Richard Brittain) Newsgroups: comp.os.msdos.programmer Subject: Help in relocating a program in DOS memory Message-ID: <1991Jun21.111320.3481@dartvax.dartmouth.edu> Date: 21 Jun 91 11:13:20 GMT Sender: news@dartvax.dartmouth.edu (The News Manager) Organization: Dartmouth College, Hanover, NH Lines: 26 Originator: crystal@eleazar.dartmouth.edu Hello, I'm trying to make a small (actually tiny model) C program relocate itself to the top of the 640k memory space in order to prevent fragmentation later on. What I naively tried was: - find out how big the current program is from the MCB - set the DOS allocation strategy to last-fit - allocate the same size block at the top of memory - deallocate my own environment since I don't need it - copy myself from here to there - deallocate myself - set all the segment registers equal to the new segment address + 100h I crash and burn at the last two steps. The program has no separately allocated memory, is tiny model and has no hooked interrupts. What else do I need to do - any suggestions? The better way to do this of course would be for DOS to respect the exe header blocks saying how much memory a program needs and then allocate only that much to it - I presume setting last-fit strategy before doing a spawn() would then achieve what I'm trying to do. Is there some magic flag to make the exec service work like this ? Thanks a lot, Richard Brittain, richard@einstein.dartmouth.edu