Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!imagen!atari!apratt From: apratt@atari.UUCP (Allan Pratt) Newsgroups: comp.sys.atari.st Subject: Re: Loading programs. Message-ID: <848@atari.UUCP> Date: Mon, 21-Sep-87 15:27:16 EDT Article-I.D.: atari.848 Posted: Mon Sep 21 15:27:16 1987 Date-Received: Wed, 23-Sep-87 05:12:56 EDT References: <1322@dasys1.UUCP> Organization: Atari Corp., Sunnyvale CA Lines: 37 in article <1322@dasys1.UUCP>, stevef@dasys1.UUCP (Steve A. Feinstein) says: > Does anyone know > if there is anyway to, say load a program into the top of the TPA > and execute it up there. So that when it exits, there won't be any holes? There is one way to do this with Pexec, but it requires knowing how much memory the program will need (lots of heuristics here). long topPexec(cmd,args,env,size) char *cmd, *args, *env; unsigned long size; { unsigned long blocksize; char *addr; long ret; blocksize = Malloc(-1L); /* find out size of largest block */ if (block < size) { return ENSMEM; /* largest block not big enough! */ } addr = Malloc(blocksize); /* allocate that block */ Mshrink(addr,blocksize-size); /* shrink it by size TSR needs */ ret = Pexec(0,cmd,args,env); /* exec the TSR */ Mfree(addr); /* free the padding */ return ret; /* return the exit code */ } This procedure takes a "size" argument which is the amount of memory the program in question will need for its text, data, bss, basepage, environment, and stack/heap. This is not a computable number: you have to figure it out empirically. text+data+bss+env+10K or so should work, but you will always leave a small hole at the top of memory, because TSR's always Mshrink a little bit. ============================================ Opinions expressed above do not necessarily -- Allan Pratt, Atari Corp. reflect those of Atari Corp. or anyone else. ...ames!atari!apratt