[net.micro.pc] "Re: Mem. Alloc. in DOS?????

dap1@ihlpf.UUCP (darrell plank) (11/15/83)

#R:ihlpf:17100016:ihlpf:17100017:000:1844
ihlpf!dap1    Nov 14 23:47:00 1983

Well, I have figured out some stuff since last night when I posted the original
note.  I got my exec() system call for Lattice C working, but only on .com
files (generated under Lattice by linking with cc.obj rather than c.obj).
I could not get function 4a to work in a .EXE file.  In a .com file you
just pass the value of the ES register upon entry and the size in paragraphs
in the BX register.  I haven't the foggiest what goes in the ES register
for .exe files.  I tried sending the segment with the PSP, the CS segment
and finally, the segment just beyond all the memory I was using (although I
don't see how DOS could distinguish that, so it didn't surprise me that it
didn't work).  None of them worked.  I always got an error code 7 back which
means "Memory control blocks destroyed".  It seems as though the note on
P. D-47 of the DOS Manual which says "When your program received control,
all of available memory was allocated to it" only applies to .com files.
The only hint that the manual makes of this distinction is on PPs. E-6
and E-7 where the fact that all the memory is allocated to the program seems
to apply only to .com files.
	What is going on here?  If there is a distinction, why didn't they
mention it in the function calls???  Why does such a distinction exist?
Is it totally impossible to deallocate memory from a .exe file and hence
to exec from it???  Whatever the case, I think they did a lousy job of
documenting this feature.

                                              Darrell Plank
                                              BTL-IH

P.S.  I got a request to post the "exec" function which is modified from a
macro put up by Brad Davis a while back.  I'll do this shortly so maybe
I can save other people the headache of trying to figure out the difference
between the DOS documentation and DOS itself.