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

From: Oliver Schmidt <ol.sc1web.de>
Date: 2011-01-24 18:36:09
Hi,

> 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.

The current Apple II startup code uses a similar - but I think a
little smaller and more robust - approach:

The last statement of the code isn't an RTS but a indirect JMP. The
location for the JMP is exported so "everybody" can patch it's own
handler in there. The default handler is just an RTS.

This way I implemented rebootafterexit(). It patches in its own "final
JMP" handler.

Regards,
Oliver
----------------------------------------------------------------------
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 18:36:20 2011

This archive was generated by hypermail 2.1.8 : 2011-01-24 18:36:23 CET