[net.micro.atari] calling programs

eli@cvl.UUCP (Eli Liang) (01/19/86)

*** REPLACE THIS LINE WITH YOUR MESSAGE ***

Anyone out there used the gemdos Pexec command?  It supposedly allows one
to call other programs from a main program.  I've tried everything I could
think of to get it to work, but I've had no luck.  It keeps returning error
code -39.  According to the gemdos manual, this indicates not enough memory.
But I know I've got enough memory, becase the main program is about ten
lines long and the sub-program is about five lines long and I have a one-
megabyte machine!  This is terribly frustrating!  If anyone can offer any
suggestions or perhaps a solution, I will greatly appreciate it.
-- 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Eli Liang  ---
        University of Maryland Computer Vision Lab, (301) 454-4526
        ARPA: eli@cvl, eli@lemuria, eli@asgard, eli@mit-mc, eli@mit-prep
        CSNET: eli@cvl  UUCP: {seismo,allegra,brl-bmd}!umcp-cs!cvl!eli

randy@nlm-vax.ARPA (Rand Huntzinger) (01/21/86)

In article <1122@cvl.UUCP> eli@cvl.UUCP (Eli Liang) writes:
>*** REPLACE THIS LINE WITH YOUR MESSAGE ***
>
>Anyone out there used the gemdos Pexec command?  It supposedly allows one
>to call other programs from a main program.  I've tried everything I could
>think of to get it to work, but I've had no luck.  It keeps returning error
>code -39.  According to the gemdos manual, this indicates not enough memory.
>But I know I've got enough memory, becase the main program is about ten
>lines long and the sub-program is about five lines long and I have a one-
>megabyte machine!  This is terribly frustrating!  If anyone can offer any
>suggestions or perhaps a solution, I will greatly appreciate it.
>-- 
I usually reply to such things privately, but this frustrating problem comes
up with the developer's kit enough to warrant posting a reply.  For those
without the developer's kit, I beg your patience.

For some reason, the "gemstart.o" (or gems.o) module deallocates all but about
1K of user stack/heap space.  Thus, you can have a 1 meg machine with 3/4 meg
free, and still get the out of memory message.  I ran into the same problem
with Pexec() and had other problems as well, until I modified gemstart.s to
allocate more space.  Then the problems went away and I could get on with my
work.  I don't have the code at hand, so I can't give the exact fix.  But
somewhere there is a constant (400 or 500 hex) which gets added to the end of
the program area.  The stack is reset at this point and the rest of memory is
deallocated.  You get to use the space between the end of your code and the
stack pointer.  (400 or 500hex bytes)

					Randy Huntzinger

nigel@minster.UUCP (nigel) (01/23/86)

In article <1122@cvl.UUCP> eli@cvl.UUCP writes:
>
>Anyone out there used the gemdos Pexec command?  It supposedly allows one
>to call other programs from a main program.  I've tried everything I could
>think of to get it to work, but I've had no luck.  It keeps returning error
>code -39.  According to the gemdos manual, this indicates not enough memory.


A CPM 68K program has all the memory allocated to it, so there is none
left when you try to do a Pexec(). I suspect you have used gems.o, rather
than gemstart.o (if you have the ISV development system), as the latter
reallocates memory for you. Alternatively, use the Mshrink() command.

daemon@houligan.UUCP (01/28/86)

>    Anyone out there used the gemdos Pexec command?  It supposedly allows one
>    to call other programs from a main program.  I've tried everything I could
>    think of to get it to work, but I've had no luck.  It keeps returning error
>    code -39.  According to the gemdos manual, this indicates not enough memory.
>    But I know I've got enough memory, becase the main program is about ten
>    lines long and the sub-program is about five lines long and I have a one-
>    megabyte machine!  This is terribly frustrating!  If anyone can offer any
>    suggestions or perhaps a solution, I will greatly appreciate it.
>    -- 
>    
I notice another response to this problem which may or may not be accurate.
According to the spec for Gemdos in the developers kit, when a program is
loaded into memory, the stack pointer is set to point to the top of the TPA.
This means that the program will use all available memory for its heap space.
To make room for a program to be pexec(), the spec says that you should
reduce your stack/heap space by changing the stack pointer to a more reasonable
offset from the end of the bss and free the memory above the new stack pointer
using mfree().  This makes memory available for the pexec()ed program to use.
I believe this is done in gemstart or gems, but I don't have my documentation
with me so I can't be sure.