Re: [cc65] Calling another program: exec() ?

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2011-01-24 16:03:39
On Mon, Jan 24, 2011 at 03:34:26PM +0100, silverdr@wfmh.org.pl wrote:
> Depends how we define "nasty" ;-) My definition would apply if we would like
> to account for _every_ possible combination of load addresses/starting
> methods. If we come up with sensible convention for the external prgs to be
> started, it could fit into "reasonable" pool of tricks.

Ok, lets say it this way: If we find an area of reasonable size that is "safe"
to use, it's doable. Unfortunately the chance of collisions is very high,
because there are not that many free code locations.

> > The best idea would probably be to actually terminate the running program and
> > run a new one instead, eventually passing some arguments as if they were
> > passed on the "command line". This is the easiest and cleanest solution.
>
> This seem to fit into the same place as the stub-loader you mentioned. Get
> into "safe" place then exit the caller plus load'n run the callee.

Yes, exactly. It needs such a stub loader.

Provided that we find such a place, how about the following: The startup code
writes an RTS to the start of this memory area and jumps to it after the
program terminates. This means 8 bytes overhead of the startup code. Or it
could even be placed into a constructor. An "exec" module can then replace the
RTS by code loading and starting another app, and simply terminate using
exit(). The startup code then jumps to the replacement code after all of the
termination code has been run.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Jan 24 16:03:48 2011

This archive was generated by hypermail 2.1.8 : 2011-01-24 16:03:51 CET