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

From: Ullrich von Bassewitz <>
Date: 2011-02-10 18:12:08

On Thu, Feb 10, 2011 at 12:56:09PM +0100, Oliver Schmidt wrote:
> There are several targets that need a small loader stub to be placed
> somewhere safe which is than jumped to in order to load the new
> program. However we surely don't want to introduced yet another linker
> segment for that purpose ;-) On the other hand it is likely that one
> needs absolute references into that loader stub. My solution goes like
> this, using a JSR just as a simple example for an absolute reference:

I've created myself a solution for the several extended memory drivers that
were contributed some time ago, and I have to say that I like my solution more
than yours:-) The basic code is of course the same but it differs in details.

See c64-c256k.s for a larger example.


TARGETLOC               = $200          ; Target location for exec stub

.proc   execstub
.org    ::TARGETLOC
entry:  ...
        jsr    mysub
        jmp    <new program>

.proc   _exec
        ldx  	#.sizeof (stub) - 1
@L1:    lda    	execstub::source,x
        sta  	execstub::entry,x
        bpl  	@L1
        jmp     execstub::entry


A disadvantage of this approach is that placing the code at the end of the
area doesn't work easily.



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Feb 10 18:12:16 2011

This archive was generated by hypermail 2.1.8 : 2011-02-10 18:12:19 CET